orx 1.16
Portable Game Engine
Loading...
Searching...
No Matches
orxDecl.h
Go to the documentation of this file.
1/* Orx - Portable Game Engine
2 *
3 * Copyright (c) 2008- Orx-Project
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source
22 * distribution.
23 */
24
32
40
41
42#ifndef _orxDECL_H_
43#define _orxDECL_H_
44
45#ifdef __orxDEBUG__
46
47 #define __orxPROFILER__
48
49#endif /* __orxDEBUG__ */
50
51#ifdef __APPLE__
52
53 #include "TargetConditionals.h"
54
55#endif /* __APPLE__ */
56
57#ifdef TARGET_OS_ANDROID
58
59 #include <android/api-level.h>
60
61#endif /* TARGET_OS_ANDROID */
62
63#include <stddef.h>
64
65
66/* *** Platform dependent base declarations */
67
68/* No processor defines? */
69#if !defined(__orxARM__) && !defined(__orxPPC__) && !defined(__orxPPC64__) && !defined(__orxX86_64__) && !defined(__orxX86__) && !defined(__orxARM64__)
70
71 /* ARM? */
72 #if defined(__arm__) || defined(__ARMEL__) || defined(__ARM_EABI__)
73
74 #define __orxARM__
75
76 /* ARM64? */
77 #elif defined(__arm64) || defined(__aarch64__)
78
79 #define __orxARM64__
80
81 /* PowerPC? */
82 #elif defined(__ppc__) || defined(PPC) || defined(__PPC) || defined(__POWERPC__) || defined(__powerpc__)
83
84 #define __orxPPC__
85
86 /* PowerPC 64? */
87 #elif defined(__powerpc64__) || defined(__POWERPC64__)
88
89 #define __orxPPC64__
90
91 /* x86_64? */
92 #elif defined(__x86_64) || defined(_M_X64) || defined(__ia64__)
93
94 #define __orxX86_64__
95
96 /* x86 */
97 #else
98
99 #define __orxX86__
100
101 #endif
102
103#endif /* !__orxARM__ && !__orxPPC__ && !__orxPPC64__ && !__orxX86_64__ && !__orxX86__ && !__orxARM64__ */
104
105/* Has byte order? */
106#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
107
108 #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
109
110 #define __orxBIG_ENDIAN__
111 #undef __orxLITTLE_ENDIAN__
112
113 #else /* (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) */
114
115 #define __orxLITTLE_ENDIAN__
116 #undef __orxBIG_ENDIAN__
117
118 #endif /* (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) */
119
120#else /* __BYTE_ORDER__ && __ORDER_BIG_ENDIAN__ */
121
122 /* Power PC? */
123 #ifdef __orxPPC__
124
125 #define __orxBIG_ENDIAN__
126 #undef __orxLITTLE_ENDIAN__
127
128 #else /* __orxPPC__ */
129
130 #define __orxLITTLE_ENDIAN__
131 #undef __orxBIG_ENDIAN__
132
133 #endif /* __orxPPC__ */
134
135#endif /* __BYTE_ORDER__ && __ORDER_BIG_ENDIAN__ */
136
137/* No compiler defines? */
138#if !defined(__orxLLVM__) && !defined(__orxGCC__) && !defined(__orxMSVC__)
139
140 /* LLVM? */
141 #if defined(__llvm__)
142
143 #define __orxLLVM__
144
145 /* GCC? */
146 #elif defined(__GNUC__)
147
148 #define __orxGCC__
149
150 /* MSVC? */
151 #elif defined(_MSC_VER)
152
153 #define __orxMSVC__
154
155 #else
156
157 #error "Couldn't guess compiler define. Please provide it (__orxLLVM__/__orxGCC__/__orxMSVC__)"
158
159 #endif
160
161#endif /* !__orxLLVM__ && !__orxGCC__ && !__orxMSVC__ */
162
163/* Instruction size */
164#if defined(__orxX86_64__) || defined(__orxPPC64__) || defined(__orxARM64__)
165
166 /* 64 bits */
167 #define __orx64__
168
169#else /* __orxX86_64__ || __orxPPC64__ || __orxARM64__ */
170
171 /* 32 bits */
172 #define __orx32__
173
174#endif /* __orxX86_64__ || __orxPPC64__ || __orxARM64__ */
175
176/* No platform defines? */
177#if !defined(__orxWINDOWS__) && !defined(__orxMAC__) && !defined(__orxLINUX__) && !defined(__orxIOS__) && !defined(__orxANDROID__)
178
179 /* Windows? */
180 #if defined(_WIN32) || defined(WIN32)
181
182 #define __orxWINDOWS__
183
184 /* iOS? */
185 #elif TARGET_OS_IPHONE
186
187 #define __orxIOS__
188
189 /* Android */
190 #elif defined(TARGET_OS_ANDROID)
191
192 #define __orxANDROID__
193
194 /* Linux? */
195 #elif defined(linux) || defined(__linux__)
196
197 #define __orxLINUX__
198
199 #pragma GCC diagnostic ignored "-Wunused-function"
200
201 /* Mac? */
202 #elif TARGET_OS_MAC
203
204 #define __orxMAC__
205
206 /* Web? */
207 #elif defined(EMSCRIPTEN) || defined(__EMSCRIPTEN__)
208
209 #define __orxWEB__
210
211 #else
212
213 #error "Couldn't guess platform define. Please provide it (__orxWINDOWS__/__orxMAC__/__orxLINUX__/__orxIOS__/__orxANDROID__/__orxWEB__)"
214
215 #endif
216
217#endif /* !__orxWINDOWS__ && !__orxMAC__ && !__orxLINUX__ && !__orxIOS__ && !__orxANDROID__ && !__orxWEB__ */
218
219
220#ifdef __cplusplus
221
222 #define orxIMPORT "C"
223 #define __orxCPP__
224
225#else /* __cplusplus */
226
227 #define orxIMPORT
228 #undef __orxCPP__
229
230#endif /* __cplusplus */
231
232#ifdef __OBJC__
233
234 #define __orxOBJC__
235
236#else /* __OBJC__ */
237
238 #undef __orxOBJC__
239
240#endif /* __OBJC__ */
241
242
243/* Windows */
244#ifdef __orxWINDOWS__
245
246 #ifndef orxFASTCALL
247
248 #define orxFASTCALL __fastcall
249
250 #endif /* !orxFASTCALL */
251
252 #define orxSTDCALL __stdcall
253
254 #define orxCDECL __cdecl
255
257 #define orxDLLEXPORT __declspec(dllexport)
258
260 #define orxDLLIMPORT __declspec(dllimport)
261
263 #define orxNULL (0)
264
266 #ifndef orxINLINE
267
268 /* *** Compiler specific *** */
269 #if defined(__orxGCC__) || defined(__orxLLVM__)
270
272 #define orxINLINE inline
273
274 #elif defined(__orxMSVC__)
275
277 #define orxINLINE __inline
278
279 #endif
280
281 #endif /* !orxINLINE */
282
283#else /* __orxWINDOWS__ */
284
285 /* Linux / Mac / iOS / Android / Web */
286 #if defined(__orxLINUX__) || defined(__orxMAC__) || defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxWEB__)
287
288 /* ARM / ARM64 / LLVM / PPC / PPC64 / X86_64 / iOS / Android / Web */
289 #if defined(__orxARM__) || defined(__orxLLVM__) || defined(__orxPPC__) || defined(__orxPPC64__) || defined(__orxX86_64__) || defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxARM64__) || defined(__orxWEB__)
290
291 #ifndef orxFASTCALL
292
293 #define orxFASTCALL
294
295 #endif /* !orxFASTCALL */
296
297 #define orxSTDCALL
298
299 #define orxCDECL
300
301 #else /* __orxARM__ || __orxLLVM__ || __orxPPC__ || __orxPPC64__ || __orxX86_64__ || __orxIOS__ || __orxANDROID__ || __orxARM64__ || __orxWEB__ */
302
303 #ifndef orxFASTCALL
304
305 #define orxFASTCALL __attribute__ ((fastcall))
306
307 #endif /* !orxFASTCALL */
308
309 #define orxSTDCALL __attribute__ ((stdcall))
310
311 #define orxCDECL __attribute__ ((cdecl))
312
313 #endif /* __orxARM__ || __orxLLVM__ || __orxPPC__ || __orxPPC64__ || __orxX86_64__ || __orxIOS__ || __orxANDROID__ || __orxARM64__ || __orxWEB__ */
314
316 #define orxDLLEXPORT __attribute__ ((visibility("default")))
317
319 #define orxDLLIMPORT
320
321 #ifndef orxINLINE
322
324 #define orxINLINE inline
325
326 #endif /* !orxINLINE */
327
329 #define orxNULL (0)
330
331 #if defined(__orxWEB__)
332
333 #define __orxSTATIC__
334
335 #endif /* __orxWEB__ */
336
337 #if defined(__orxIOS__) || defined(__orxANDROID__)
338
339 /* iOS versions can only be embedded due to the lack of dlfcn presence */
340 #define __orxEMBEDDED__
341
342 /* Always use static on iOS & Android */
343 #define __orxSTATIC__
344
345 #endif /* __orxIOS__ || __orxANDROID__ */
346
347 #endif /* __orxLINUX__ || __orxMAC__ || __orxIOS__ || __orxANDROID__ || __orxWEB__ */
348
349#endif /* __orxWINDOWS__ */
350
351
352/* Plugin include? */
353#if defined(__orxPLUGIN__)
354
355 #ifdef __orxEMBEDDED__
356
357 #define orxDLLAPI orxIMPORT /* Compiling embedded plug-in => API doesn't need to be imported */
358
359 #else
360
361 #define orxDLLAPI orxIMPORT orxDLLIMPORT /* Compiling plug-in => API needs to be imported */
362
363 #endif /* __orxEMBEDDED__ */
364
365/* External include? */
366#elif defined(__orxEXTERN__)
367
368 #ifdef __orxSTATIC__
369
370 #define orxDLLAPI orxIMPORT /* Linking executable against orx static library */
371
372 #else /* __orxSTATIC__ */
373
374 #define orxDLLAPI orxIMPORT orxDLLIMPORT /* Linking executable against orx dynamic library */
375
376 #endif /* __orxSTATIC__ */
377
378/* Internal (library) include */
379#else
380
381 #define orxDLLAPI orxIMPORT orxDLLEXPORT /* Compiling orx library => API needs to be exported */
382
383#endif
384
385
387#define orxALIGN(VALUE, BLOCK_SIZE) (((orxUPTR)(VALUE) + ((orxUPTR)(BLOCK_SIZE) - 1)) & (~((orxUPTR)(BLOCK_SIZE) - 1)))
388
389#define orxALIGN8(VALUE) orxALIGN(VALUE, 8)
390#define orxALIGN16(VALUE) orxALIGN(VALUE, 16)
391#define orxALIGN32(VALUE) orxALIGN(VALUE, 32)
392#define orxALIGN64(VALUE) orxALIGN(VALUE, 64)
393
394
396#define orxSTRUCT_GET_FROM_FIELD(TYPE, FIELD, POINTER) ((TYPE *)((orxU8 *)(POINTER) - offsetof(TYPE, FIELD)))
397
398
400#define orxARRAY_GET_ITEM_COUNT(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0]))
401
402
404
410#define orxFLAG_TEST_ALL(X, F) (((X) & (F)) == (F))
411
417#define orxFLAG_TEST(X, F) (((X) & (F)) != 0)
418
424#define orxFLAG_GET(X, M) ((X) & (M))
425
431#define orxFLAG_SET(X, A, R) \
432do \
433{ \
434 (X) &= ~(R); \
435 (X) |= (A); \
436} while(orxFALSE)
437
442#define orxFLAG_SWAP(X, S) ((X) ^= (S))
443
444
446
447#define orxANSI_KC_MARKER '\x1b'
448
449#define orxANSI_KZ_COLOR_RESET "\x1b[0m"
450
451#define orxANSI_KZ_COLOR_BOLD_ON "\x1b[1m"
452#define orxANSI_KZ_COLOR_ITALICS_ON "\x1b[3m"
453#define orxANSI_KZ_COLOR_UNDERLINE_ON "\x1b[4m"
454#define orxANSI_KZ_COLOR_BLINK_ON "\x1b[5m"
455#define orxANSI_KZ_COLOR_INVERSE_ON "\x1b[7m"
456#define orxANSI_KZ_COLOR_STRIKETHROUGH_ON "\x1b[9m"
457
458#define orxANSI_KZ_COLOR_BOLD_OFF "\x1b[22m"
459#define orxANSI_KZ_COLOR_ITALICS_OFF "\x1b[23m"
460#define orxANSI_KZ_COLOR_UNDERLINE_OFF "\x1b[24m"
461#define orxANSI_KZ_COLOR_BLINK_OFF "\x1b[25m"
462#define orxANSI_KZ_COLOR_INVERSE_OFF "\x1b[27m"
463#define orxANSI_KZ_COLOR_STRIKETHROUGH_OFF "\x1b[29m"
464
465#define orxANSI_KZ_COLOR_FG_BLACK "\x1b[30m"
466#define orxANSI_KZ_COLOR_FG_RED "\x1b[31m"
467#define orxANSI_KZ_COLOR_FG_GREEN "\x1b[32m"
468#define orxANSI_KZ_COLOR_FG_YELLOW "\x1b[33m"
469#define orxANSI_KZ_COLOR_FG_BLUE "\x1b[34m"
470#define orxANSI_KZ_COLOR_FG_MAGENTA "\x1b[35m"
471#define orxANSI_KZ_COLOR_FG_CYAN "\x1b[36m"
472#define orxANSI_KZ_COLOR_FG_WHITE "\x1b[37m"
473#define orxANSI_KZ_COLOR_FG_DEFAULT "\x1b[39m"
474
475#define orxANSI_KZ_COLOR_BG_BLACK "\x1b[40m"
476#define orxANSI_KZ_COLOR_BG_RED "\x1b[41m"
477#define orxANSI_KZ_COLOR_BG_GREEN "\x1b[42m"
478#define orxANSI_KZ_COLOR_BG_YELLOW "\x1b[43m"
479#define orxANSI_KZ_COLOR_BG_BLUE "\x1b[44m"
480#define orxANSI_KZ_COLOR_BG_MAGENTA "\x1b[45m"
481#define orxANSI_KZ_COLOR_BG_CYAN "\x1b[46m"
482#define orxANSI_KZ_COLOR_BG_WHITE "\x1b[47m"
483#define orxANSI_KZ_COLOR_BG_DEFAULT "\x1b[49m"
484
485
486#endif /*_orxDECL_H_*/
487

Generated for orx by doxygen 1.8.11