Main Page
Namespaces
Namespace List
Namespace Members
All
Functions
Typedefs
Enumerations
Classes
Class List
Class Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
y
z
~
Functions
a
c
d
e
f
g
i
l
m
o
p
r
s
t
u
w
~
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
y
z
Files
File List
File Members
All
_
c
d
f
g
i
m
n
s
t
u
Functions
m
s
t
Variables
Typedefs
d
f
i
s
u
Enumerations
_
Enumerator
s
Macros
_
c
f
i
n
s
t
external
sbgECom
common
sbgDefines.h
Go to the documentation of this file.
1
20
#ifndef SBG_DEFINES_H
21
#define SBG_DEFINES_H
22
23
// Standard headers
24
#include <
assert.h
>
25
#include <errno.h>
26
#include <limits.h>
27
#include <stdarg.h>
28
#include <stdbool.h>
29
#include <stddef.h>
30
#include <stdlib.h>
31
#include <stdio.h>
32
#include <stdint.h>
33
#include <string.h>
34
#include <
time.h
>
35
36
//
37
// XXX If NDEBUG is defined, most libraries define assert() as ((void)0), which may
38
// cause "defined but not used" warnings. Redefine assert() in a way that safely
39
// prevents this warning, i.e. without triggering the expression side effects.
40
//
41
#ifdef NDEBUG
42
#undef assert
43
#define assert(expression) ((void)sizeof(expression))
44
#endif // NDEBUG
45
49
#ifdef _MSC_VER
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)
54
#else
55
#define SBG_COMMON_LIB_API
56
#endif
57
#else
58
#define SBG_COMMON_LIB_API
59
#endif
60
61
//----------------------------------------------------------------------//
62
//- Global definitions -//
63
//----------------------------------------------------------------------//
64
#ifndef SBG_DISABLE
65
#define SBG_DISABLE (0)
66
#endif
67
68
#ifndef SBG_ENABLE
69
#define SBG_ENABLE (1)
70
#endif
71
72
#ifndef FALSE
73
#define FALSE (0)
74
#endif
75
76
#ifndef TRUE
77
#define TRUE (1)
78
#endif
79
80
#ifndef NULL
81
#define NULL (0)
82
#endif
83
84
#ifndef SBG_INVALID_HANDLE
85
#define SBG_INVALID_HANDLE (0x00000000u)
86
#endif
87
88
#ifndef SBG_NOT_FOUND
89
#define SBG_NOT_FOUND (0xFFFFFFFFu)
90
#endif
91
92
#ifndef SBG_UNDEFINED
93
#define SBG_UNDEFINED (0xFFFFFFFFu)
94
#endif
95
96
#ifndef SBG_ARRAY_SIZE
97
#define SBG_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
98
#endif
99
100
#ifndef SBG_STRLEN
101
#define SBG_STRLEN(s) (sizeof(s) - 1)
102
#endif
103
104
#ifndef SBG_CONTAINER_OF
105
#define SBG_CONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member)))
106
#endif
107
108
#ifndef SBG_LIKELY
109
#if defined(__GNUC__)
110
#define SBG_LIKELY(expr) __builtin_expect((bool)(expr), true)
111
#else
112
#define SBG_LIKELY(expr) (expr)
113
#endif
114
#endif
115
116
#ifndef SBG_UNLIKELY
117
#if defined(__GNUC__)
118
#define SBG_UNLIKELY(expr) __builtin_expect((bool)(expr), false)
119
#else
120
#define SBG_UNLIKELY(expr) (expr)
121
#endif
122
#endif
123
128
#ifndef __SBG_TYPEOF
129
#ifdef __cplusplus
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)
135
#endif
136
#endif
137
138
#ifndef SBG_CONST_CAST_AA
139
#ifdef __SBG_TYPEOF
140
#define SBG_CONST_CAST_AA(x) ((const __SBG_TYPEOF((x)[0][0])(*)[SBG_ARRAY_SIZE((x)[0])])(x))
141
#else
142
#define SBG_CONST_CAST_AA(x) x
143
#endif
144
#endif
145
146
#ifndef SBG_CONST_CAST_PP
147
#ifdef __SBG_TYPEOF
148
#define SBG_CONST_CAST_PP(x) ((const __SBG_TYPEOF(**(x))**)(x))
149
#else
150
#define SBG_CONST_CAST_PP(x) x
151
#endif
152
#endif
153
157
#ifndef __GNUC__
158
#ifndef __BASE_FILE__
159
#define __BASE_FILE__ __FILE__
160
#endif
161
#endif
162
163
#ifdef __cplusplus
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;}
168
#else
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;}
173
#endif
174
175
//----------------------------------------------------------------------//
176
//- Compiler definitions -//
177
//----------------------------------------------------------------------//
178
182
#ifndef SBG_INLINE
183
#if defined(_MSC_VER)
184
#define SBG_INLINE __inline
185
#else
186
#define SBG_INLINE static inline
187
#endif
188
#endif
189
193
#ifndef SBG_UNUSED_PARAMETER
194
#define SBG_UNUSED_PARAMETER(x) (void)(x)
195
#endif
196
201
#ifndef SBG_FALLTHROUGH
202
#if __cplusplus >= 201703L
203
#define SBG_FALLTHROUGH [[fallthrough]]
/* introduced in C++ 17 */
204
#elif defined(__GNUC__)
205
#define SBG_FALLTHROUGH __attribute__ ((fallthrough))
206
#else
207
#define SBG_FALLTHROUGH
208
#endif
209
#endif
210
211
//----------------------------------------------------------------------//
212
//- Macro used to defined packed structures -//
213
//----------------------------------------------------------------------//
214
219
#ifdef __GNUC__
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))
225
#else
226
#error you must byte-align these structures with the appropriate compiler directives
227
#endif
228
232
#ifdef __GNUC__
233
#define SBG_PACKED __attribute__((packed))
234
#elif defined(__TI_COMPILER_VERSION__)
235
#define SBG_PACKED __attribute__((packed))
236
#elif defined(_MSC_VER)
237
#define SBG_PACKED
238
#else
239
#error you must byte-align these structures with the appropriate compiler directives
240
#endif
241
245
#ifdef __GNUC__
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))
251
#else
252
#error you must byte-align these structures with the appropriate compiler directives
253
#endif
254
255
//----------------------------------------------------------------------//
256
//- Deprecation definitions -//
257
//----------------------------------------------------------------------//
258
262
#ifdef __GNUC__
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
268
#else
269
//#warning "WARNING: You need to implement SBG_DEPRECATED for this compiler"
270
#define SBG_DEPRECATED(func) func
271
#endif
272
276
#ifdef __GNUC__
277
#define SBG_DEPRECATED_MACRO(func) __pragma(deprecated(func))
278
#elif defined(_MSC_VER)
279
#define SBG_DEPRECATED_MACRO(func) __pragma(deprecated(func))
280
#else
281
//#warning "WARNING: You need to implement SBG_DEPRECATED_MACRO for this compiler"
282
#define SBG_DEPRECATED_MACRO(func) func
283
#endif
284
285
//----------------------------------------------------------------------//
286
//- Basic maths definitions -//
287
//----------------------------------------------------------------------//
288
#ifndef SBG_PI
289
#define SBG_PI 3.14159265358979323846
290
#endif
291
292
#ifndef SBG_PI_F
293
#define SBG_PI_F 3.14159265358979323846f
294
#endif
295
302
#ifndef sbgAbs
303
#define sbgAbs(x) (((x) < 0) ? -(x) : (x))
304
#endif
305
312
#ifndef sbgMax
313
#define sbgMax(a,b) (((a) > (b)) ? (a) : (b))
314
#endif
315
322
#ifndef sbgMin
323
#define sbgMin(a,b) (((a) < (b)) ? (a) : (b))
324
#endif
325
333
#ifndef sbgClamp
334
#define sbgClamp(value, minValue, maxValue) (((value) < (minValue))?(minValue): ((value) > (maxValue)?maxValue:value))
335
#endif
336
342
#ifndef sbgDivCeil
343
#define sbgDivCeil(n, d) (((n) + (d) - 1) / (d))
344
#endif
345
351
SBG_INLINE
double
sbgRadToDegD
(
double
angle)
352
{
353
return
angle
* 180.0 /
SBG_PI
;
354
}
355
361
SBG_INLINE
double
sbgDegToRadD
(
double
angle)
362
{
363
return
angle
*
SBG_PI
/ 180.0;
364
}
365
371
SBG_INLINE
float
sbgRadToDegF
(
float
angle)
372
{
373
return
angle
* 180.0f /
SBG_PI_F
;
374
}
375
381
SBG_INLINE
float
sbgDegToRadF
(
float
angle)
382
{
383
return
angle
*
SBG_PI_F
/ 180.0f;
384
}
385
386
#endif
/* __SBG_DEFINES_H__ */
time.h
sbgDegToRadD
SBG_INLINE double sbgDegToRadD(double angle)
Definition:
sbgDefines.h:361
sbgRadToDegF
SBG_INLINE float sbgRadToDegF(float angle)
Definition:
sbgDefines.h:371
SBG_INLINE
#define SBG_INLINE
Definition:
sbgDefines.h:186
SBG_PI
#define SBG_PI
Definition:
sbgDefines.h:289
SBG_PI_F
#define SBG_PI_F
Definition:
sbgDefines.h:293
angle
TF2SIMD_FORCE_INLINE tf2Scalar angle(const Quaternion &q1, const Quaternion &q2)
sbgRadToDegD
SBG_INLINE double sbgRadToDegD(double angle)
Definition:
sbgDefines.h:351
assert.h
sbgDegToRadF
SBG_INLINE float sbgDegToRadF(float angle)
Definition:
sbgDefines.h:381
sbg_driver
Author(s): SBG Systems
autogenerated on Fri Oct 11 2024 02:13:40