orx  1.10
Portable Game Engine
orxDecl.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2019 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  #ifndef orxFASTCALL
253 
254  #define orxFASTCALL __fastcall
255 
256  #endif /* !orxFASTCALL */
257 
258  #define orxSTDCALL __stdcall
259 
260  #define orxCDECL __cdecl
261 
263  #define orxDLLEXPORT __declspec(dllexport)
264 
266  #define orxDLLIMPORT __declspec(dllimport)
267 
269  #define orxNULL (0)
270 
272  #ifndef orxINLINE
273 
274  /* *** Compiler specific *** */
275  #if defined(__orxGCC__) || defined(__orxLLVM__)
276 
278  #define orxINLINE inline
279 
280  #elif defined(__orxMSVC__)
281 
283  #define orxINLINE __inline
284 
285  #endif
286 
287  #endif /* !orxINLINE */
288 
289 #else /* __orxWINDOWS__ */
290 
291  /* Linux / Mac / iOS / Android */
292  #if defined(__orxLINUX__) || defined(__orxMAC__) || defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxANDROID_NATIVE__)
293 
294  /* ARM / ARM64 / LLVM / PPC / PPC64 / X86_64 / iOS / Android */
295  #if defined(__orxARM__) || defined(__orxLLVM__) || defined(__orxPPC__) || defined(__orxPPC64__) || defined(__orxX86_64__) || defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxANDROID_NATIVE__) || defined(__orxARM64__)
296 
297  #ifndef orxFASTCALL
298 
299  #define orxFASTCALL
300 
301  #endif /* !orxFASTCALL */
302 
303  #define orxSTDCALL
304 
305  #define orxCDECL
306 
307  #else /* __orxARM__ || __orxLLVM__ || __orxPPC__ || __orxPPC64__ || __orxX86_64__ || __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ || __orxARM64__ */
308 
309  #ifndef orxFASTCALL
310 
311  #define orxFASTCALL __attribute__ ((fastcall))
312 
313  #endif /* !orxFASTCALL */
314 
315  #define orxSTDCALL __attribute__ ((stdcall))
316 
317  #define orxCDECL __attribute__ ((cdecl))
318 
319  #endif /* __orxARM__ || __orxLLVM__ || __orxPPC__ || __orxPPC64__ || __orxX86_64__ || __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ || __orxARM64__ */
320 
322  #define orxDLLEXPORT __attribute__ ((visibility("default")))
323 
325  #define orxDLLIMPORT
326 
327  #ifndef orxINLINE
328 
330  #define orxINLINE inline
331 
332  #endif /* !orxINLINE */
333 
335  #define orxNULL (0)
336 
337  #if defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxANDROID_NATIVE__)
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 and Android */
343  #define __orxSTATIC__
344 
345  #endif /* __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ */
346 
347  #endif /* __orxLINUX__ || __orxMAC__ || __orxIOS__ || __orxANDROID__ || __orxANDROID_NATIVE__ */
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(ADDRESS, BLOCK_SIZE) (((size_t)(ADDRESS) + ((size_t)(BLOCK_SIZE) - 1)) & (~((size_t)(BLOCK_SIZE) - 1)))
388 
389 #define orxALIGN16(ADDRESS) orxALIGN(ADDRESS, 16)
390 #define orxALIGN32(ADDRESS) orxALIGN(ADDRESS, 32)
391 #define orxALIGN64(ADDRESS) orxALIGN(ADDRESS, 64)
392 
393 
395 #define orxSTRUCT_GET_FROM_FIELD(TYPE, FIELD, POINTER) ((TYPE *)((orxU8 *)(POINTER) - offsetof(TYPE, FIELD)))
396 
397 
399 #define orxARRAY_GET_ITEM_COUNT(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0]))
400 
401 
409 #define orxFLAG_TEST_ALL(X, F) (((X) & (F)) == (F))
410 
416 #define orxFLAG_TEST(X, F) (((X) & (F)) != 0)
417 
423 #define orxFLAG_GET(X, M) ((X) & (M))
424 
430 #define orxFLAG_SET(X, A, R) \
431 do \
432 { \
433  (X) &= ~(R); \
434  (X) |= (A); \
435 } while(orxFALSE)
436 
441 #define orxFLAG_SWAP(X, S) ((X) ^= (S))
442 
443 
446 #define orxANSI_KC_MARKER '\x1b'
447 
448 #define orxANSI_KZ_COLOR_RESET "\x1b[0m"
449 
450 #define orxANSI_KZ_COLOR_BOLD_ON "\x1b[1m"
451 #define orxANSI_KZ_COLOR_ITALICS_ON "\x1b[3m"
452 #define orxANSI_KZ_COLOR_UNDERLINE_ON "\x1b[4m"
453 #define orxANSI_KZ_COLOR_BLINK_ON "\x1b[5m"
454 #define orxANSI_KZ_COLOR_INVERSE_ON "\x1b[7m"
455 #define orxANSI_KZ_COLOR_STRIKETHROUGH_ON "\x1b[9m"
456 
457 #define orxANSI_KZ_COLOR_BOLD_OFF "\x1b[22m"
458 #define orxANSI_KZ_COLOR_ITALICS_OFF "\x1b[23m"
459 #define orxANSI_KZ_COLOR_UNDERLINE_OFF "\x1b[24m"
460 #define orxANSI_KZ_COLOR_BLINK_OFF "\x1b[25m"
461 #define orxANSI_KZ_COLOR_INVERSE_OFF "\x1b[27m"
462 #define orxANSI_KZ_COLOR_STRIKETHROUGH_OFF "\x1b[29m"
463 
464 #define orxANSI_KZ_COLOR_FG_BLACK "\x1b[30m"
465 #define orxANSI_KZ_COLOR_FG_RED "\x1b[31m"
466 #define orxANSI_KZ_COLOR_FG_GREEN "\x1b[32m"
467 #define orxANSI_KZ_COLOR_FG_YELLOW "\x1b[33m"
468 #define orxANSI_KZ_COLOR_FG_BLUE "\x1b[34m"
469 #define orxANSI_KZ_COLOR_FG_MAGENTA "\x1b[35m"
470 #define orxANSI_KZ_COLOR_FG_CYAN "\x1b[36m"
471 #define orxANSI_KZ_COLOR_FG_WHITE "\x1b[37m"
472 #define orxANSI_KZ_COLOR_FG_DEFAULT "\x1b[39m"
473 
474 #define orxANSI_KZ_COLOR_BG_BLACK "\x1b[40m"
475 #define orxANSI_KZ_COLOR_BG_RED "\x1b[41m"
476 #define orxANSI_KZ_COLOR_BG_GREEN "\x1b[42m"
477 #define orxANSI_KZ_COLOR_BG_YELLOW "\x1b[43m"
478 #define orxANSI_KZ_COLOR_BG_BLUE "\x1b[44m"
479 #define orxANSI_KZ_COLOR_BG_MAGENTA "\x1b[45m"
480 #define orxANSI_KZ_COLOR_BG_CYAN "\x1b[46m"
481 #define orxANSI_KZ_COLOR_BG_WHITE "\x1b[47m"
482 #define orxANSI_KZ_COLOR_BG_DEFAULT "\x1b[49m"
483 
484 
485 #endif /*_orxDECL_H_*/
486 

Generated for orx by doxygen 1.8.11