orx  1.14
Portable Game Engine
orxDecl.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2022 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 #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  #else
207 
208  #error "Couldn't guess platform define. Please provide it (__orxWINDOWS__/__orxMAC__/__orxLINUX__/__orxIOS__/__orxANDROID__)"
209 
210  #endif
211 
212 #endif /* !__orxWINDOWS__ && !__orxMAC__ && !__orxLINUX__ && !__orxIOS__ && !__orxANDROID__ */
213 
214 
215 #ifdef __cplusplus
216 
217  #define orxIMPORT "C"
218  #define __orxCPP__
219 
220 #else /* __cplusplus */
221 
222  #define orxIMPORT
223  #undef __orxCPP__
224 
225 #endif /* __cplusplus */
226 
227 #ifdef __OBJC__
228 
229  #define __orxOBJC__
230 
231 #else /* __OBJC__ */
232 
233  #undef __orxOBJC__
234 
235 #endif /* __OBJC__ */
236 
237 
238 /* Windows */
239 #ifdef __orxWINDOWS__
240 
241  #ifndef orxFASTCALL
242 
243  #define orxFASTCALL __fastcall
244 
245  #endif /* !orxFASTCALL */
246 
247  #define orxSTDCALL __stdcall
248 
249  #define orxCDECL __cdecl
250 
252  #define orxDLLEXPORT __declspec(dllexport)
253 
255  #define orxDLLIMPORT __declspec(dllimport)
256 
258  #define orxNULL (0)
259 
261  #ifndef orxINLINE
262 
263  /* *** Compiler specific *** */
264  #if defined(__orxGCC__) || defined(__orxLLVM__)
265 
267  #define orxINLINE inline
268 
269  #elif defined(__orxMSVC__)
270 
272  #define orxINLINE __inline
273 
274  #endif
275 
276  #endif /* !orxINLINE */
277 
278 #else /* __orxWINDOWS__ */
279 
280  /* Linux / Mac / iOS / Android */
281  #if defined(__orxLINUX__) || defined(__orxMAC__) || defined(__orxIOS__) || defined(__orxANDROID__)
282 
283  /* ARM / ARM64 / LLVM / PPC / PPC64 / X86_64 / iOS / Android */
284  #if defined(__orxARM__) || defined(__orxLLVM__) || defined(__orxPPC__) || defined(__orxPPC64__) || defined(__orxX86_64__) || defined(__orxIOS__) || defined(__orxANDROID__) || defined(__orxARM64__)
285 
286  #ifndef orxFASTCALL
287 
288  #define orxFASTCALL
289 
290  #endif /* !orxFASTCALL */
291 
292  #define orxSTDCALL
293 
294  #define orxCDECL
295 
296  #else /* __orxARM__ || __orxLLVM__ || __orxPPC__ || __orxPPC64__ || __orxX86_64__ || __orxIOS__ || __orxANDROID__ || __orxARM64__ */
297 
298  #ifndef orxFASTCALL
299 
300  #define orxFASTCALL __attribute__ ((fastcall))
301 
302  #endif /* !orxFASTCALL */
303 
304  #define orxSTDCALL __attribute__ ((stdcall))
305 
306  #define orxCDECL __attribute__ ((cdecl))
307 
308  #endif /* __orxARM__ || __orxLLVM__ || __orxPPC__ || __orxPPC64__ || __orxX86_64__ || __orxIOS__ || __orxANDROID__ || __orxARM64__ */
309 
311  #define orxDLLEXPORT __attribute__ ((visibility("default")))
312 
314  #define orxDLLIMPORT
315 
316  #ifndef orxINLINE
317 
319  #define orxINLINE inline
320 
321  #endif /* !orxINLINE */
322 
324  #define orxNULL (0)
325 
326  #if defined(__orxIOS__) || defined(__orxANDROID__)
327 
328  /* iOS versions can only be embedded due to the lack of dlfcn presence */
329  #define __orxEMBEDDED__
330 
331  /* Always use static on iOS and Android */
332  #define __orxSTATIC__
333 
334  #endif /* __orxIOS__ || __orxANDROID__ */
335 
336  #endif /* __orxLINUX__ || __orxMAC__ || __orxIOS__ || __orxANDROID__ */
337 
338 #endif /* __orxWINDOWS__ */
339 
340 
341 /* Plugin include? */
342 #if defined(__orxPLUGIN__)
343 
344  #ifdef __orxEMBEDDED__
345 
346  #define orxDLLAPI orxIMPORT /* Compiling embedded plug-in => API doesn't need to be imported */
347 
348  #else
349 
350  #define orxDLLAPI orxIMPORT orxDLLIMPORT /* Compiling plug-in => API needs to be imported */
351 
352  #endif /* __orxEMBEDDED__ */
353 
354 /* External include? */
355 #elif defined(__orxEXTERN__)
356 
357  #ifdef __orxSTATIC__
358 
359  #define orxDLLAPI orxIMPORT /* Linking executable against orx static library */
360 
361  #else /* __orxSTATIC__ */
362 
363  #define orxDLLAPI orxIMPORT orxDLLIMPORT /* Linking executable against orx dynamic library */
364 
365  #endif /* __orxSTATIC__ */
366 
367 /* Internal (library) include */
368 #else
369 
370  #define orxDLLAPI orxIMPORT orxDLLEXPORT /* Compiling orx library => API needs to be exported */
371 
372 #endif
373 
374 
376 #define orxALIGN(VALUE, BLOCK_SIZE) (((orxUPTR)(VALUE) + ((orxUPTR)(BLOCK_SIZE) - 1)) & (~((orxUPTR)(BLOCK_SIZE) - 1)))
377 
378 #define orxALIGN8(VALUE) orxALIGN(VALUE, 8)
379 #define orxALIGN16(VALUE) orxALIGN(VALUE, 16)
380 #define orxALIGN32(VALUE) orxALIGN(VALUE, 32)
381 #define orxALIGN64(VALUE) orxALIGN(VALUE, 64)
382 
383 
385 #define orxSTRUCT_GET_FROM_FIELD(TYPE, FIELD, POINTER) ((TYPE *)((orxU8 *)(POINTER) - offsetof(TYPE, FIELD)))
386 
387 
389 #define orxARRAY_GET_ITEM_COUNT(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0]))
390 
391 
399 #define orxFLAG_TEST_ALL(X, F) (((X) & (F)) == (F))
400 
406 #define orxFLAG_TEST(X, F) (((X) & (F)) != 0)
407 
413 #define orxFLAG_GET(X, M) ((X) & (M))
414 
420 #define orxFLAG_SET(X, A, R) \
421 do \
422 { \
423  (X) &= ~(R); \
424  (X) |= (A); \
425 } while(orxFALSE)
426 
431 #define orxFLAG_SWAP(X, S) ((X) ^= (S))
432 
433 
436 #define orxANSI_KC_MARKER '\x1b'
437 
438 #define orxANSI_KZ_COLOR_RESET "\x1b[0m"
439 
440 #define orxANSI_KZ_COLOR_BOLD_ON "\x1b[1m"
441 #define orxANSI_KZ_COLOR_ITALICS_ON "\x1b[3m"
442 #define orxANSI_KZ_COLOR_UNDERLINE_ON "\x1b[4m"
443 #define orxANSI_KZ_COLOR_BLINK_ON "\x1b[5m"
444 #define orxANSI_KZ_COLOR_INVERSE_ON "\x1b[7m"
445 #define orxANSI_KZ_COLOR_STRIKETHROUGH_ON "\x1b[9m"
446 
447 #define orxANSI_KZ_COLOR_BOLD_OFF "\x1b[22m"
448 #define orxANSI_KZ_COLOR_ITALICS_OFF "\x1b[23m"
449 #define orxANSI_KZ_COLOR_UNDERLINE_OFF "\x1b[24m"
450 #define orxANSI_KZ_COLOR_BLINK_OFF "\x1b[25m"
451 #define orxANSI_KZ_COLOR_INVERSE_OFF "\x1b[27m"
452 #define orxANSI_KZ_COLOR_STRIKETHROUGH_OFF "\x1b[29m"
453 
454 #define orxANSI_KZ_COLOR_FG_BLACK "\x1b[30m"
455 #define orxANSI_KZ_COLOR_FG_RED "\x1b[31m"
456 #define orxANSI_KZ_COLOR_FG_GREEN "\x1b[32m"
457 #define orxANSI_KZ_COLOR_FG_YELLOW "\x1b[33m"
458 #define orxANSI_KZ_COLOR_FG_BLUE "\x1b[34m"
459 #define orxANSI_KZ_COLOR_FG_MAGENTA "\x1b[35m"
460 #define orxANSI_KZ_COLOR_FG_CYAN "\x1b[36m"
461 #define orxANSI_KZ_COLOR_FG_WHITE "\x1b[37m"
462 #define orxANSI_KZ_COLOR_FG_DEFAULT "\x1b[39m"
463 
464 #define orxANSI_KZ_COLOR_BG_BLACK "\x1b[40m"
465 #define orxANSI_KZ_COLOR_BG_RED "\x1b[41m"
466 #define orxANSI_KZ_COLOR_BG_GREEN "\x1b[42m"
467 #define orxANSI_KZ_COLOR_BG_YELLOW "\x1b[43m"
468 #define orxANSI_KZ_COLOR_BG_BLUE "\x1b[44m"
469 #define orxANSI_KZ_COLOR_BG_MAGENTA "\x1b[45m"
470 #define orxANSI_KZ_COLOR_BG_CYAN "\x1b[46m"
471 #define orxANSI_KZ_COLOR_BG_WHITE "\x1b[47m"
472 #define orxANSI_KZ_COLOR_BG_DEFAULT "\x1b[49m"
473 
474 
475 #endif /*_orxDECL_H_*/
476 

Generated for orx by doxygen 1.8.11