62 #define assert(expression) ((void)sizeof(expression))
69 #ifdef SBG_COMMON_STATIC_USE
70 #define SBG_COMMON_LIB_API
72 #ifdef SBG_COMMON_LIB_API_EXPORT
73 #define SBG_COMMON_LIB_API __declspec(dllexport)
75 #define SBG_COMMON_LIB_API __declspec(dllimport)
79 #define SBG_COMMON_LIB_API
86 #define SBG_DISABLE (0)
90 #define SBG_ENABLE (1)
105 #ifndef SBG_INVALID_HANDLE
106 #define SBG_INVALID_HANDLE (NULL)
109 #ifndef SBG_ARRAY_SIZE
110 #define SBG_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
114 #define SBG_STRLEN(s) (sizeof(s) - 1)
118 #define SBG_QUOTE_NX(x) #x
122 #define SBG_QUOTE(x) SBG_QUOTE_NX(x)
125 #ifndef SBG_CONCAT_NX
126 #define SBG_CONCAT_NX(a, b) a ## b
130 #define SBG_CONCAT(a, b) SBG_CONCAT_NX(a, b)
134 #define SBG_UNPACK(...) __VA_ARGS__
137 #ifndef SBG_CONTAINER_OF
138 #define SBG_CONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member)))
142 #if defined(__GNUC__) || defined(__clang__)
143 #define SBG_LIKELY(expr) __builtin_expect((bool)(expr), true)
145 #define SBG_LIKELY(expr) (expr)
150 #if defined(__GNUC__) || defined(__clang__)
151 #define SBG_UNLIKELY(expr) __builtin_expect((bool)(expr), false)
153 #define SBG_UNLIKELY(expr) (expr)
157 #ifndef SBG_CHECK_FORMAT
158 #if defined(__GNUC__) || defined(__clang__)
159 #define SBG_CHECK_FORMAT(style, format_index, va_args) __attribute__((format(style, format_index, va_args)))
161 #define SBG_CHECK_FORMAT(style, format_index, va_args)
173 #define __SBG_TYPEOF(x) decltype(x)
174 #elif defined(__GNUC__) || defined(__clang__) || defined(__TI_COMPILER_VERSION__)
175 #define __SBG_TYPEOF(x) typeof(x)
179 #ifndef SBG_CONST_CAST_AA
181 #define SBG_CONST_CAST_AA(x) ((const __SBG_TYPEOF((x)[0][0])(*)[SBG_ARRAY_SIZE((x)[0])])(x))
183 #define SBG_CONST_CAST_AA(x) x
187 #ifndef SBG_CONST_CAST_PP
189 #define SBG_CONST_CAST_PP(x) ((const __SBG_TYPEOF(**(x))**)(x))
191 #define SBG_CONST_CAST_PP(x) x
198 #if !defined(__GNUC__) && !defined(__clang__)
199 #ifndef __BASE_FILE__
200 #define __BASE_FILE__ __FILE__
205 #define SBG_DELETE(p) if (p){delete (p); (p) = NULL;}
206 #define SBG_DELETE_ARRAY(p) if (p){delete[] (p); (p) = NULL;}
207 #define SBG_FREE(p) if (p){free(p); (p) = NULL;}
208 #define SBG_FREE_ARRAY(p) if (p){free(p); (p) = NULL;}
210 #define SBG_DELETE if (p){free(p); (p) = NULL;}
211 #define SBG_DELETE_ARRAY if (p){free(p); (p) = NULL;}
212 #define SBG_FREE(p) if (p){free(p); (p) = NULL;}
213 #define SBG_FREE_ARRAY(p) if (p){free(p); (p) = NULL;}
224 #if defined(_MSC_VER)
225 #define SBG_INLINE __inline
227 #define SBG_INLINE static inline
234 #ifndef SBG_UNUSED_PARAMETER
235 #define SBG_UNUSED_PARAMETER(x) (void)(x)
244 #ifndef SBG_FALLTHROUGH
245 #if __cplusplus >= 201703L
246 #define SBG_FALLTHROUGH [[fallthrough]]
247 #elif defined(__GNUC__) || defined(__clang__)
248 #if (__GNUC__ >= 7) || defined(__clang__)
249 #define SBG_FALLTHROUGH __attribute__((fallthrough))
251 #define SBG_FALLTHROUGH ((void)0)
254 #define SBG_FALLTHROUGH
268 #if defined(__GNUC__) || defined(__clang__) || defined(__TI_COMPILER_VERSION__)
269 #define SBG_BEGIN_PACKED()
270 #elif defined(_MSC_VER)
271 #define SBG_BEGIN_PACKED() __pragma(pack(push, 1))
273 #error you must byte-align these structures with the appropriate compiler directives
281 #if defined(__GNUC__) || defined(__clang__) || defined(__TI_COMPILER_VERSION__)
282 #define SBG_PACKED __attribute__((packed))
283 #elif defined(_MSC_VER)
286 #error you must byte-align these structures with the appropriate compiler directives
294 #if defined(__GNUC__) || defined(__clang__) || defined(__TI_COMPILER_VERSION__)
295 #define SBG_END_PACKED()
296 #elif defined(_MSC_VER)
297 #define SBG_END_PACKED() __pragma(pack(pop))
299 #error you must byte-align these structures with the appropriate compiler directives
309 #if defined(__GNUC__) || defined(__clang__)
310 #define SBG_DEPRECATED(func) __attribute__((deprecated)) func
311 #elif defined(__TI_COMPILER_VERSION__)
312 #define SBG_DEPRECATED(func) func __attribute__((deprecated))
313 #elif defined(_MSC_VER)
314 #define SBG_DEPRECATED(func) __declspec(deprecated) func
316 #define SBG_DEPRECATED(func) func
322 #if defined(__GNUC__) || defined(__clang__)
323 #define SBG_DEPRECATED_MACRO(func) __pragma(deprecated(func))
324 #elif defined(_MSC_VER)
325 #define SBG_DEPRECATED_MACRO(func) __pragma(deprecated(func))
327 #define SBG_DEPRECATED_MACRO(func) func
333 #ifndef SBG_CONFIG_WARN_ABOUT_DEPRECATED_TYPES
334 #define SBG_CONFIG_WARN_ABOUT_DEPRECATED_TYPES (1)
343 #if SBG_CONFIG_WARN_ABOUT_DEPRECATED_TYPES != 0
344 #if defined(__GNUC__) || defined(__clang__)
345 #define SBG_DEPRECATED_TYPEDEF(decl) decl __attribute__((deprecated))
346 #elif defined(_MSC_VER)
347 #define SBG_DEPRECATED_TYPEDEF(decl) __declspec(deprecated) decl
349 #define SBG_DEPRECATED_TYPEDEF(decl) decl
352 #define SBG_DEPRECATED_TYPEDEF(decl) decl
359 #define SBG_PI 3.14159265358979323846
363 #define SBG_PI_F 3.14159265358979323846f
373 #define sbgAbs(x) (((x) < 0) ? -(x) : (x))
384 #define sbgMax(a,b) (((a) > (b)) ? (a) : (b))
395 #define sbgMin(a,b) (((a) < (b)) ? (a) : (b))
407 #define sbgClamp(value, minValue, maxValue) (((value) < (minValue))?(minValue): ((value) > (maxValue)?maxValue:value))
418 #define sbgDivCeil(n, d) (((n) + (d) - 1) / (d))
429 return angle * 180.0 / SBG_PI;
440 return angle * SBG_PI / 180.0;
451 return angle * 180.0f / SBG_PI_F;
462 return angle * SBG_PI_F / 180.0f;
477 if (isnan(leftValue) || isnan(rightValue))
485 if (fabsf(leftValue - rightValue) < FLT_EPSILON)
507 if (isnan(leftValue) || isnan(rightValue))
515 if (fabs(leftValue - rightValue) < DBL_EPSILON)
Header file used to configure the framework.
SBG_INLINE float sbgRadToDegf(float angle)
Definition: sbgDefines.h:449
#define SBG_INLINE
Definition: sbgDefines.h:227
SBG_INLINE double sbgDegToRadd(double angle)
Definition: sbgDefines.h:438
SBG_INLINE double sbgRadToDegd(double angle)
Definition: sbgDefines.h:427
SBG_INLINE float sbgDegToRadf(float angle)
Definition: sbgDefines.h:460
SBG_INLINE bool sbgAlmostEqualsFloat(float leftValue, float rightValue)
Definition: sbgDefines.h:472
SBG_INLINE bool sbgAlmostEqualsDouble(double leftValue, double rightValue)
Definition: sbgDefines.h:502