orx  stable
Portable Game Engine
orxDecl.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2017 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 
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 #ifdef TARGET_OS_ANDROID_NATIVE
64 
65  #include <android/api-level.h>
66 
67 #endif /* TARGET_OS_ANDROID_NATIVE */
68 
69 #include <stddef.h>
70 
71 
72 /* *** Platform dependent base declarations */
73 
74 /* No processor defines? */
75 #if !defined(__orxARM__) && !defined(__orxPPC__) && !defined(__orxPPC64__) && !defined(__orxX86_64__) && !defined(__orxX86__) && !defined(__orxARM64__)
76 
77  /* ARM? */
78  #if defined(__arm__) || defined(__ARMEL__) || defined(__ARM_EABI__)
79 
80  #define __orxARM__
81 
82  /* ARM64? */
83  #elif defined(__arm64) || defined(__aarch64__)
84 
85  #define __orxARM64__
86 
87  /* PowerPC? */
88  #elif defined(__ppc__) || defined(PPC) || defined(__PPC) || defined(__POWERPC__) || defined(__powerpc__)
89 
90  #define __orxPPC__
91 
92  /* PowerPC 64? */
93  #elif defined(__powerpc64__) || defined(__POWERPC64__)
94 
95  #define __orxPPC64__
96 
97  /* x86_64? */
98  #elif defined(__x86_64) || defined(_M_X64) || defined(__ia64__)
99 
100  #define __orxX86_64__
101 
102  /* x86 */
103  #else
104 
105  #define __orxX86__
106 
107  #endif
108 
109 #endif /* !__orxARM__ && !__orxPPC__ && !__orxPPC64__ && !__orxX86_64__ && !__orxX86__ && !__orxARM64__ */
110 
111 /* Has byte order? */
112 #if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
113 
114  #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
115 
116  #define __orxBIG_ENDIAN__
117  #undef __orxLITTLE_ENDIAN__
118 
119  #else /* (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) */
120 
121  #define __orxLITTLE_ENDIAN__
122  #undef __orxBIG_ENDIAN__
123 
124  #endif /* (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) */
125 
126 #else /* __BYTE_ORDER__ && __ORDER_BIG_ENDIAN__ */
127 
128  /* Power PC? */
129  #ifdef __orxPPC__
130 
131  #define __orxBIG_ENDIAN__
132  #undef __orxLITTLE_ENDIAN__
133 
134  #else /* __orxPPC__ */
135 
136  #define __orxLITTLE_ENDIAN__
137  #undef __orxBIG_ENDIAN__
138 
139  #endif /* __orxPPC__ */
140 
141 #endif /* __BYTE_ORDER__ && __ORDER_BIG_ENDIAN__ */
142 
143 /* No compiler defines? */
144 #if !defined(__orxLLVM__) && !defined(__orxGCC__) && !defined(__orxMSVC__)
145 
146  /* LLVM? */
147  #if defined(__llvm__)
148 
149  #define __orxLLVM__
150 
151  /* GCC? */
152  #elif defined(__GNUC__)
153 
154  #define __orxGCC__
155 
156  /* MSVC? */
157  #elif defined(_MSC_VER)
158 
159  #define __orxMSVC__
160 
161  #else
162 
163  #error "Couldn't guess compiler define. Please provide it (__orxLLVM__/__orxGCC__/__orxMSVC__)"
164 
165  #endif
166 
167 #endif /* !__orxLLVM__ && !__orxGCC__ && !__orxMSVC__ */
168 
169 
170 /* No platform defines? */
171 #if !defined(__orxWINDOWS__) && !defined(__orxMAC__) && !defined(__orxLINUX__) && !defined(__orxIOS__) && !defined(__orxANDROID__) && !defined(__orxANDROID_NATIVE__)&& !defined(__orxRASPBERRY_PI__)
172 
173  /* Windows? */
174  #if defined(_WIN32) || defined(WIN32)
175 
176  #define __orxWINDOWS__
177 
178  /* iOS? */
179  #elif TARGET_OS_IPHONE
180 
181  #define __orxIOS__
182 
183  /* Android */
184  #elif defined(TARGET_OS_ANDROID)
185 
186  #define __orxANDROID__
187 
188  /* Android Native */
189  #elif defined(TARGET_OS_ANDROID_NATIVE)
190 
191  #define __orxANDROID_NATIVE__
192 
193  /* Raspberry Pi */
194  #elif defined(__orxARM__)
195 
196  #define __orxRASPBERRY_PI__
197 
198  /* Linux? */
199  #elif defined(linux) || defined(__linux__)
200 
201  #define __orxLINUX__
202 
203  #pragma GCC diagnostic ignored "-Wunused-function"
204 
205  /* Mac? */
206  #elif TARGET_OS_MAC
207 
208  #define __orxMAC__
209 
210  #else
211 
212  #error "Couldn't guess platform define. Please provide it (__orxWINDOWS__/__orxMAC__/__orxLINUX__/__orxIOS__/__orxANDROID__/__orxANDROID_NATIVE__/__orxRASPBERRY_PI__)"
213 
214  #endif
215 
216 #endif /* !__orxWINDOWS__ && !__orxMAC__ && !__orxLINUX__ && !__orxIOS__ && !__orxANDROID__ && !__orxANDROID_NATIVE__ && !__orxRASPBERRY_PI__ */
217 
218 
219 #ifdef __cplusplus
220 
221  #define orxIMPORT "C"
222  #define __orxCPP__
223 
224 #else /* __cplusplus */
225 
226  #define orxIMPORT
227  #undef __orxCPP__
228 
229 #endif /* __cplusplus */
230 
231 #ifdef __OBJC__
232 
233  #define __orxOBJC__
234 
235 #else /* __OBJC__ */
236 
237  #undef __orxOBJC__
238 
239 #endif /* __OBJC__ */
240 
241 
242 /* Windows */
243 #ifdef __orxWINDOWS__
244 
245  #ifdef __orxFREEBASIC__
246 
247  #define orxFASTCALL __stdcall
248 
249  #else /* __orxFREEBASIC__ */
250 
251  #define orxFASTCALL __fastcall
252 
253  #endif /* __orxFREEBASIC__ */
254 
255  #define orxSTDCALL __stdcall
256 
257  #define orxCDECL __cdecl
258 
260  #define orxDLLEXPORT __declspec(dllexport)
261 
263  #define orxDLLIMPORT __declspec(dllimport)
264 
266  #define orxNULL (0)
267 
268  /* *** Compiler specific *** */
269  #if defined(__orxFREEBASIC__)
270 
272  #define orxINLINE
273 
274  #elif defined(__orxGCC__)
275 
277  #define orxINLINE inline
278 
279  #elif defined(__orxLLVM__)
280 
282  #define orxINLINE inline
283 
284  #elif defined(__orxMSVC__)
285 
287  #define orxINLINE __inline
288 
289  #endif
290 
291 #else /* __orxWINDOWS__ */
292 
293  /* Linux / Mac / iOS / Android */
294  #if defined(__orxLINUX__) || defined(__orxMAC__) || defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxANDROID_NATIVE__)
295 
296  #if defined(__orxARM__) || defined(__orxLLVM__) || defined(__orxPPC__) || defined(__orxPPC64__) || defined(__orxX86_64__) || defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxANDROID_NATIVE__) || defined(__orxRASPBERRY_PI__) || defined(__orxARM64__)
297 
298  #define orxFASTCALL
299 
300  #define orxSTDCALL
301 
302  #define orxCDECL
303 
304  #else /* __orxARM__ || __orxLLVM__ || __orxPPC__ || __orxPPC64__ || __orxX86_64__ || __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ || __orxRASPBERRY_PI__ || __orxARM64__ */
305 
306  #ifdef __orxFREEBASIC__
307 
308  #define orxFASTCALL __attribute__ ((stdcall))
309 
310  #else /* __orxFREEBASIC__ */
311 
312  #define orxFASTCALL __attribute__ ((fastcall))
313 
314  #endif /* __orxFREEBASIC__ */
315 
316  #define orxSTDCALL __attribute__ ((stdcall))
317 
318  #define orxCDECL __attribute__ ((cdecl))
319 
320  #endif /* __orxARM__ || __orxLLVM__ || __orxPPC__ || __orxPPC64__ || __orxX86_64__ || __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ || __orxRASPBERRY_PI__ || __orxARM64__ */
321 
323  #define orxDLLEXPORT __attribute__ ((visibility("default")))
324 
326  #define orxDLLIMPORT
327 
328  #ifdef __orxFREEBASIC__
329 
331  #define orxINLINE
332 
333  #else /* __orxFREEBASIC__ */
334 
336  #define orxINLINE inline
337 
338  #endif /* __orxFREEBASIC__ */
339 
341  #define orxNULL (0)
342 
343  #if defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxANDROID_NATIVE__) || defined(__orxRASPBERRY_PI__)
344 
345  /* iOS versions can only be embedded due to the lack of dlfcn presence */
346  #define __orxEMBEDDED__
347 
348  /* always use static on iOS, Android and Raspberry */
349  #define __orxSTATIC__
350 
351  #endif /* __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ || __orxRASPBERRY_PI__ */
352 
353  #endif /* __orxLINUX__ || __orxMAC__ || __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ || __orxRASPBERRY_PI__ */
354 
355 #endif /* __orxWINDOWS__ */
356 
357 
358 /* Plugin include? */
359 #if defined(__orxPLUGIN__)
360 
361  #ifdef __orxEMBEDDED__
362 
363  #define orxDLLAPI orxIMPORT /* Compiling embedded plug-in => API doesn't need to be imported */
364 
365  #else
366 
367  #define orxDLLAPI orxIMPORT orxDLLIMPORT /* Compiling plug-in => API needs to be imported */
368 
369  #endif /* __orxEMBEDDED__ */
370 
371 /* External include? */
372 #elif defined(__orxEXTERN__)
373 
374  #ifdef __orxSTATIC__
375 
376  #define orxDLLAPI orxIMPORT /* Linking executable against orx static library */
377 
378  #else /* __orxSTATIC__ */
379 
380  #define orxDLLAPI orxIMPORT orxDLLIMPORT /* Linking executable against orx dynamic library */
381 
382  #endif /* __orxSTATIC__ */
383 
384 /* Internal (library) include */
385 #else
386 
387  #define orxDLLAPI orxIMPORT orxDLLEXPORT /* Compiling orx library => API needs to be exported */
388 
389 #endif
390 
391 
393 #define orxALIGN(ADDRESS, BLOCK_SIZE) (((size_t)(ADDRESS) + ((size_t)(BLOCK_SIZE) - 1)) & (~((size_t)(BLOCK_SIZE) - 1)))
394 
395 #define orxALIGN16(ADDRESS) orxALIGN(ADDRESS, 16)
396 #define orxALIGN32(ADDRESS) orxALIGN(ADDRESS, 32)
397 #define orxALIGN64(ADDRESS) orxALIGN(ADDRESS, 64)
398 
399 
401 #define orxSTRUCT_GET_FROM_FIELD(TYPE, FIELD, POINTER) ((TYPE *)((orxU8 *)(POINTER) - offsetof(TYPE, FIELD)))
402 
403 
405 #define orxARRAY_GET_ITEM_COUNT(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0]))
406 
407 
415 #define orxFLAG_TEST_ALL(X, F) (((X) & (F)) == (F))
416 
422 #define orxFLAG_TEST(X, F) (((X) & (F)) != 0)
423 
429 #define orxFLAG_GET(X, M) ((X) & (M))
430 
436 #define orxFLAG_SET(X, A, R) \
437 do \
438 { \
439  (X) &= ~(R); \
440  (X) |= (A); \
441 } while(orxFALSE)
442 
447 #define orxFLAG_SWAP(X, S) ((X) ^= (S))
448 
449 
452 #define orxANSI_KC_MARKER '\x1b'
453 
454 #define orxANSI_KZ_COLOR_RESET "\x1b[0m"
455 
456 #define orxANSI_KZ_COLOR_BOLD_ON "\x1b[1m"
457 #define orxANSI_KZ_COLOR_ITALICS_ON "\x1b[3m"
458 #define orxANSI_KZ_COLOR_UNDERLINE_ON "\x1b[4m"
459 #define orxANSI_KZ_COLOR_BLINK_ON "\x1b[5m"
460 #define orxANSI_KZ_COLOR_INVERSE_ON "\x1b[7m"
461 #define orxANSI_KZ_COLOR_STRIKETHROUGH_ON "\x1b[9m"
462 
463 #define orxANSI_KZ_COLOR_BOLD_OFF "\x1b[22m"
464 #define orxANSI_KZ_COLOR_ITALICS_OFF "\x1b[23m"
465 #define orxANSI_KZ_COLOR_UNDERLINE_OFF "\x1b[24m"
466 #define orxANSI_KZ_COLOR_BLINK_OFF "\x1b[25m"
467 #define orxANSI_KZ_COLOR_INVERSE_OFF "\x1b[27m"
468 #define orxANSI_KZ_COLOR_STRIKETHROUGH_OFF "\x1b[29m"
469 
470 #define orxANSI_KZ_COLOR_FG_BLACK "\x1b[30m"
471 #define orxANSI_KZ_COLOR_FG_RED "\x1b[31m"
472 #define orxANSI_KZ_COLOR_FG_GREEN "\x1b[32m"
473 #define orxANSI_KZ_COLOR_FG_YELLOW "\x1b[33m"
474 #define orxANSI_KZ_COLOR_FG_BLUE "\x1b[34m"
475 #define orxANSI_KZ_COLOR_FG_MAGENTA "\x1b[35m"
476 #define orxANSI_KZ_COLOR_FG_CYAN "\x1b[36m"
477 #define orxANSI_KZ_COLOR_FG_WHITE "\x1b[37m"
478 #define orxANSI_KZ_COLOR_FG_DEFAULT "\x1b[39m"
479 
480 #define orxANSI_KZ_COLOR_BG_BLACK "\x1b[40m"
481 #define orxANSI_KZ_COLOR_BG_RED "\x1b[41m"
482 #define orxANSI_KZ_COLOR_BG_GREEN "\x1b[42m"
483 #define orxANSI_KZ_COLOR_BG_YELLOW "\x1b[43m"
484 #define orxANSI_KZ_COLOR_BG_BLUE "\x1b[44m"
485 #define orxANSI_KZ_COLOR_BG_MAGENTA "\x1b[45m"
486 #define orxANSI_KZ_COLOR_BG_CYAN "\x1b[46m"
487 #define orxANSI_KZ_COLOR_BG_WHITE "\x1b[47m"
488 #define orxANSI_KZ_COLOR_BG_DEFAULT "\x1b[49m"
489 
490 
491 #endif /*_orxDECL_H_*/
492 

Generated for orx by doxygen 1.5.6