orx  1.9
Portable Game Engine
orxDecl.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2018 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 /* Instruction size */
170 #if defined(__orxX86_64__) || defined(__orxPPC64__) || defined(__orxARM64__)
171 
172  /* 64 bits */
173  #define __orx64__
174 
175 #else /* __orxX86_64__ || __orxPPC64__ || __orxARM64__ */
176 
177  /* 32 bits */
178  #define __orx32__
179 
180 #endif /* __orxX86_64__ || __orxPPC64__ || __orxARM64__ */
181 
182 /* No platform defines? */
183 #if !defined(__orxWINDOWS__) && !defined(__orxMAC__) && !defined(__orxLINUX__) && !defined(__orxIOS__) && !defined(__orxANDROID__) && !defined(__orxANDROID_NATIVE__)
184 
185  /* Windows? */
186  #if defined(_WIN32) || defined(WIN32)
187 
188  #define __orxWINDOWS__
189 
190  /* iOS? */
191  #elif TARGET_OS_IPHONE
192 
193  #define __orxIOS__
194 
195  /* Android */
196  #elif defined(TARGET_OS_ANDROID)
197 
198  #define __orxANDROID__
199 
200  /* Android Native */
201  #elif defined(TARGET_OS_ANDROID_NATIVE)
202 
203  #define __orxANDROID_NATIVE__
204 
205  /* Linux? */
206  #elif defined(linux) || defined(__linux__)
207 
208  #define __orxLINUX__
209 
210  #pragma GCC diagnostic ignored "-Wunused-function"
211 
212  /* Mac? */
213  #elif TARGET_OS_MAC
214 
215  #define __orxMAC__
216 
217  #else
218 
219  #error "Couldn't guess platform define. Please provide it (__orxWINDOWS__/__orxMAC__/__orxLINUX__/__orxIOS__/__orxANDROID__/__orxANDROID_NATIVE__)"
220 
221  #endif
222 
223 #endif /* !__orxWINDOWS__ && !__orxMAC__ && !__orxLINUX__ && !__orxIOS__ && !__orxANDROID__ && !__orxANDROID_NATIVE__ */
224 
225 
226 #ifdef __cplusplus
227 
228  #define orxIMPORT "C"
229  #define __orxCPP__
230 
231 #else /* __cplusplus */
232 
233  #define orxIMPORT
234  #undef __orxCPP__
235 
236 #endif /* __cplusplus */
237 
238 #ifdef __OBJC__
239 
240  #define __orxOBJC__
241 
242 #else /* __OBJC__ */
243 
244  #undef __orxOBJC__
245 
246 #endif /* __OBJC__ */
247 
248 
249 /* Windows */
250 #ifdef __orxWINDOWS__
251 
252  #ifdef __orxFREEBASIC__
253 
254  #define orxFASTCALL __stdcall
255 
256  #else /* __orxFREEBASIC__ */
257 
258  #define orxFASTCALL __fastcall
259 
260  #endif /* __orxFREEBASIC__ */
261 
262  #define orxSTDCALL __stdcall
263 
264  #define orxCDECL __cdecl
265 
267  #define orxDLLEXPORT __declspec(dllexport)
268 
270  #define orxDLLIMPORT __declspec(dllimport)
271 
273  #define orxNULL (0)
274 
275  /* *** Compiler specific *** */
276  #if defined(__orxFREEBASIC__)
277 
279  #define orxINLINE
280 
281  #elif defined(__orxGCC__)
282 
284  #define orxINLINE inline
285 
286  #elif defined(__orxLLVM__)
287 
289  #define orxINLINE inline
290 
291  #elif defined(__orxMSVC__)
292 
294  #define orxINLINE __inline
295 
296  #endif
297 
298 #else /* __orxWINDOWS__ */
299 
300  /* Linux / Mac / iOS / Android */
301  #if defined(__orxLINUX__) || defined(__orxMAC__) || defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxANDROID_NATIVE__)
302 
303  #if defined(__orxARM__) || defined(__orxLLVM__) || defined(__orxPPC__) || defined(__orxPPC64__) || defined(__orxX86_64__) || defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxANDROID_NATIVE__) || defined(__orxARM64__)
304 
305  #define orxFASTCALL
306 
307  #define orxSTDCALL
308 
309  #define orxCDECL
310 
311  #else /* __orxARM__ || __orxLLVM__ || __orxPPC__ || __orxPPC64__ || __orxX86_64__ || __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ || __orxARM64__ */
312 
313  #ifdef __orxFREEBASIC__
314 
315  #define orxFASTCALL __attribute__ ((stdcall))
316 
317  #else /* __orxFREEBASIC__ */
318 
319  #define orxFASTCALL __attribute__ ((fastcall))
320 
321  #endif /* __orxFREEBASIC__ */
322 
323  #define orxSTDCALL __attribute__ ((stdcall))
324 
325  #define orxCDECL __attribute__ ((cdecl))
326 
327  #endif /* __orxARM__ || __orxLLVM__ || __orxPPC__ || __orxPPC64__ || __orxX86_64__ || __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ || __orxARM64__ */
328 
330  #define orxDLLEXPORT __attribute__ ((visibility("default")))
331 
333  #define orxDLLIMPORT
334 
335  #ifdef __orxFREEBASIC__
336 
338  #define orxINLINE
339 
340  #else /* __orxFREEBASIC__ */
341 
343  #define orxINLINE inline
344 
345  #endif /* __orxFREEBASIC__ */
346 
348  #define orxNULL (0)
349 
350  #if defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxANDROID_NATIVE__)
351 
352  /* iOS versions can only be embedded due to the lack of dlfcn presence */
353  #define __orxEMBEDDED__
354 
355  /* Always use static on iOS and Android */
356  #define __orxSTATIC__
357 
358  #endif /* __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ */
359 
360  #endif /* __orxLINUX__ || __orxMAC__ || __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ */
361 
362 #endif /* __orxWINDOWS__ */
363 
364 
365 /* Plugin include? */
366 #if defined(__orxPLUGIN__)
367 
368  #ifdef __orxEMBEDDED__
369 
370  #define orxDLLAPI orxIMPORT /* Compiling embedded plug-in => API doesn't need to be imported */
371 
372  #else
373 
374  #define orxDLLAPI orxIMPORT orxDLLIMPORT /* Compiling plug-in => API needs to be imported */
375 
376  #endif /* __orxEMBEDDED__ */
377 
378 /* External include? */
379 #elif defined(__orxEXTERN__)
380 
381  #ifdef __orxSTATIC__
382 
383  #define orxDLLAPI orxIMPORT /* Linking executable against orx static library */
384 
385  #else /* __orxSTATIC__ */
386 
387  #define orxDLLAPI orxIMPORT orxDLLIMPORT /* Linking executable against orx dynamic library */
388 
389  #endif /* __orxSTATIC__ */
390 
391 /* Internal (library) include */
392 #else
393 
394  #define orxDLLAPI orxIMPORT orxDLLEXPORT /* Compiling orx library => API needs to be exported */
395 
396 #endif
397 
398 
400 #define orxALIGN(ADDRESS, BLOCK_SIZE) (((size_t)(ADDRESS) + ((size_t)(BLOCK_SIZE) - 1)) & (~((size_t)(BLOCK_SIZE) - 1)))
401 
402 #define orxALIGN16(ADDRESS) orxALIGN(ADDRESS, 16)
403 #define orxALIGN32(ADDRESS) orxALIGN(ADDRESS, 32)
404 #define orxALIGN64(ADDRESS) orxALIGN(ADDRESS, 64)
405 
406 
408 #define orxSTRUCT_GET_FROM_FIELD(TYPE, FIELD, POINTER) ((TYPE *)((orxU8 *)(POINTER) - offsetof(TYPE, FIELD)))
409 
410 
412 #define orxARRAY_GET_ITEM_COUNT(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0]))
413 
414 
422 #define orxFLAG_TEST_ALL(X, F) (((X) & (F)) == (F))
423 
429 #define orxFLAG_TEST(X, F) (((X) & (F)) != 0)
430 
436 #define orxFLAG_GET(X, M) ((X) & (M))
437 
443 #define orxFLAG_SET(X, A, R) \
444 do \
445 { \
446  (X) &= ~(R); \
447  (X) |= (A); \
448 } while(orxFALSE)
449 
454 #define orxFLAG_SWAP(X, S) ((X) ^= (S))
455 
456 
459 #define orxANSI_KC_MARKER '\x1b'
460 
461 #define orxANSI_KZ_COLOR_RESET "\x1b[0m"
462 
463 #define orxANSI_KZ_COLOR_BOLD_ON "\x1b[1m"
464 #define orxANSI_KZ_COLOR_ITALICS_ON "\x1b[3m"
465 #define orxANSI_KZ_COLOR_UNDERLINE_ON "\x1b[4m"
466 #define orxANSI_KZ_COLOR_BLINK_ON "\x1b[5m"
467 #define orxANSI_KZ_COLOR_INVERSE_ON "\x1b[7m"
468 #define orxANSI_KZ_COLOR_STRIKETHROUGH_ON "\x1b[9m"
469 
470 #define orxANSI_KZ_COLOR_BOLD_OFF "\x1b[22m"
471 #define orxANSI_KZ_COLOR_ITALICS_OFF "\x1b[23m"
472 #define orxANSI_KZ_COLOR_UNDERLINE_OFF "\x1b[24m"
473 #define orxANSI_KZ_COLOR_BLINK_OFF "\x1b[25m"
474 #define orxANSI_KZ_COLOR_INVERSE_OFF "\x1b[27m"
475 #define orxANSI_KZ_COLOR_STRIKETHROUGH_OFF "\x1b[29m"
476 
477 #define orxANSI_KZ_COLOR_FG_BLACK "\x1b[30m"
478 #define orxANSI_KZ_COLOR_FG_RED "\x1b[31m"
479 #define orxANSI_KZ_COLOR_FG_GREEN "\x1b[32m"
480 #define orxANSI_KZ_COLOR_FG_YELLOW "\x1b[33m"
481 #define orxANSI_KZ_COLOR_FG_BLUE "\x1b[34m"
482 #define orxANSI_KZ_COLOR_FG_MAGENTA "\x1b[35m"
483 #define orxANSI_KZ_COLOR_FG_CYAN "\x1b[36m"
484 #define orxANSI_KZ_COLOR_FG_WHITE "\x1b[37m"
485 #define orxANSI_KZ_COLOR_FG_DEFAULT "\x1b[39m"
486 
487 #define orxANSI_KZ_COLOR_BG_BLACK "\x1b[40m"
488 #define orxANSI_KZ_COLOR_BG_RED "\x1b[41m"
489 #define orxANSI_KZ_COLOR_BG_GREEN "\x1b[42m"
490 #define orxANSI_KZ_COLOR_BG_YELLOW "\x1b[43m"
491 #define orxANSI_KZ_COLOR_BG_BLUE "\x1b[44m"
492 #define orxANSI_KZ_COLOR_BG_MAGENTA "\x1b[45m"
493 #define orxANSI_KZ_COLOR_BG_CYAN "\x1b[46m"
494 #define orxANSI_KZ_COLOR_BG_WHITE "\x1b[47m"
495 #define orxANSI_KZ_COLOR_BG_DEFAULT "\x1b[49m"
496 
497 
498 #endif /*_orxDECL_H_*/
499 

Generated for orx by doxygen 1.8.11