43 #define assert(expression) ((void)sizeof(expression)) 50 #if defined(SBG_COMMON_LIB_API_EXPORT) 51 #define SBG_COMMON_LIB_API __declspec(dllexport) 52 #elif defined(SBG_COMMON_LIB_API_IMPORT) 53 #define SBG_COMMON_LIB_API __declspec(dllimport) 55 #define SBG_COMMON_LIB_API 58 #define SBG_COMMON_LIB_API 65 #define SBG_DISABLE (0) 69 #define SBG_ENABLE (1) 84 #ifndef SBG_INVALID_HANDLE 85 #define SBG_INVALID_HANDLE (0x00000000u) 89 #define SBG_NOT_FOUND (0xFFFFFFFFu) 93 #define SBG_UNDEFINED (0xFFFFFFFFu) 96 #ifndef SBG_ARRAY_SIZE 97 #define SBG_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) 101 #define SBG_STRLEN(s) (sizeof(s) - 1) 104 #ifndef SBG_CONTAINER_OF 105 #define SBG_CONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member))) 109 #if defined(__GNUC__) 110 #define SBG_LIKELY(expr) __builtin_expect((bool)(expr), true) 112 #define SBG_LIKELY(expr) (expr) 117 #if defined(__GNUC__) 118 #define SBG_UNLIKELY(expr) __builtin_expect((bool)(expr), false) 120 #define SBG_UNLIKELY(expr) (expr) 130 #define __SBG_TYPEOF(x) decltype(x) 131 #elif defined(__GNUC__) 132 #define __SBG_TYPEOF(x) typeof(x) 133 #elif defined(__TI_COMPILER_VERSION__) 134 #define __SBG_TYPEOF(x) typeof(x) 138 #ifndef SBG_CONST_CAST_AA 140 #define SBG_CONST_CAST_AA(x) ((const __SBG_TYPEOF((x)[0][0])(*)[SBG_ARRAY_SIZE((x)[0])])(x)) 142 #define SBG_CONST_CAST_AA(x) x 146 #ifndef SBG_CONST_CAST_PP 148 #define SBG_CONST_CAST_PP(x) ((const __SBG_TYPEOF(**(x))**)(x)) 150 #define SBG_CONST_CAST_PP(x) x 158 #ifndef __BASE_FILE__ 159 #define __BASE_FILE__ __FILE__ 164 #define SBG_DELETE(p) if (p){delete (p); (p) = NULL;} 165 #define SBG_DELETE_ARRAY(p) if (p){delete[] (p); (p) = NULL;} 166 #define SBG_FREE(p) if (p){free(p); (p) = NULL;} 167 #define SBG_FREE_ARRAY(p) if (p){free(p); (p) = NULL;} 169 #define SBG_DELETE if (p){free(p); (p) = NULL;} 170 #define SBG_DELETE_ARRAY if (p){free(p); (p) = NULL;} 171 #define SBG_FREE(p) if (p){free(p); (p) = NULL;} 172 #define SBG_FREE_ARRAY(p) if (p){free(p); (p) = NULL;} 183 #if defined(_MSC_VER) 184 #define SBG_INLINE __inline 186 #define SBG_INLINE static inline 193 #ifndef SBG_UNUSED_PARAMETER 194 #define SBG_UNUSED_PARAMETER(x) (void)(x) 201 #ifndef SBG_FALLTHROUGH 202 #if __cplusplus >= 201703L 203 #define SBG_FALLTHROUGH [[fallthrough]] 204 #elif defined(__GNUC__) 205 #define SBG_FALLTHROUGH __attribute__ ((fallthrough)) 207 #define SBG_FALLTHROUGH 220 #define SBG_BEGIN_PACKED() 221 #elif defined(__TI_COMPILER_VERSION__) 222 #define SBG_BEGIN_PACKED() 223 #elif defined(_MSC_VER) 224 #define SBG_BEGIN_PACKED() __pragma(pack(push, 1)) 226 #error you must byte-align these structures with the appropriate compiler directives 233 #define SBG_PACKED __attribute__((packed)) 234 #elif defined(__TI_COMPILER_VERSION__) 235 #define SBG_PACKED __attribute__((packed)) 236 #elif defined(_MSC_VER) 239 #error you must byte-align these structures with the appropriate compiler directives 246 #define SBG_END_PACKED() 247 #elif defined(__TI_COMPILER_VERSION__) 248 #define SBG_END_PACKED() 249 #elif defined(_MSC_VER) 250 #define SBG_END_PACKED() __pragma(pack(pop)) 252 #error you must byte-align these structures with the appropriate compiler directives 263 #define SBG_DEPRECATED(func) func __attribute__ ((deprecated)) 264 #elif defined(__TI_COMPILER_VERSION__) 265 #define SBG_DEPRECATED(func) func __attribute__ ((deprecated)) 266 #elif defined(_MSC_VER) 267 #define SBG_DEPRECATED(func) __declspec(deprecated) func 270 #define SBG_DEPRECATED(func) func 277 #define SBG_DEPRECATED_MACRO(func) __pragma(deprecated(func)) 278 #elif defined(_MSC_VER) 279 #define SBG_DEPRECATED_MACRO(func) __pragma(deprecated(func)) 282 #define SBG_DEPRECATED_MACRO(func) func 289 #define SBG_PI 3.14159265358979323846 293 #define SBG_PI_F 3.14159265358979323846f 303 #define sbgAbs(x) (((x) < 0) ? -(x) : (x)) 313 #define sbgMax(a,b) (((a) > (b)) ? (a) : (b)) 323 #define sbgMin(a,b) (((a) < (b)) ? (a) : (b)) 334 #define sbgClamp(value, minValue, maxValue) (((value) < (minValue))?(minValue): ((value) > (maxValue)?maxValue:value)) 343 #define sbgDivCeil(n, d) (((n) + (d) - 1) / (d)) 353 return angle * 180.0 /
SBG_PI;
363 return angle *
SBG_PI / 180.0;
SBG_INLINE float sbgRadToDegF(float angle)
SBG_INLINE float sbgDegToRadF(float angle)
SBG_INLINE double sbgRadToDegD(double angle)
SBG_INLINE double sbgDegToRadD(double angle)