ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
as_config.h
1 /*
2  AngelCode Scripting Library
3  Copyright (c) 2003-2021 Andreas Jonsson
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
7  damages arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any
10  purpose, including commercial applications, and to alter it and
11  redistribute it freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you
14  must not claim that you wrote the original software. If you use
15  this software in a product, an acknowledgment in the product
16  documentation would be appreciated but is not required.
17 
18  2. Altered source versions must be plainly marked as such, and
19  must not be misrepresented as being the original software.
20 
21  3. This notice may not be removed or altered from any source
22  distribution.
23 
24  The original version of this library can be located at:
25  http://www.angelcode.com/angelscript/
26 
27  Andreas Jonsson
28  andreas@angelcode.com
29 */
30 
31 
32 
33 //
34 // as_config.h
35 //
36 // this file is used for configuring the compilation of the library
37 //
38 
39 #ifndef AS_CONFIG_H
40 #define AS_CONFIG_H
41 
42 
43 
44 //
45 // Features
46 //-----------------------------------------
47 
48 #define AS_NO_THREADS
49 // Turns off support for multithreading. By turning off
50 // this when it's not needed a bit of performance is gained.
51 
52 // AS_WINDOWS_THREADS
53 // If the library should be compiled using windows threads.
54 
55 // AS_POSIX_THREADS
56 // If the library should be compiled using posix threads.
57 
58 // AS_NO_ATOMIC
59 // If the compiler/platform doesn't support atomic instructions
60 // then this should be defined to use critical sections instead.
61 
62 // AS_DEBUG
63 // This flag can be defined to make the library write some extra output when
64 // compiling and executing scripts.
65 
66 // AS_DEPRECATED
67 // If this flag is defined then some backwards compatibility is maintained.
68 // There is no guarantee for how well deprecated functionality will work though
69 // so it is best to exchange it for the new functionality as soon as possible.
70 
71 #define AS_NO_CLASS_METHODS
72 // Disables the possibility to add class methods. Can increase the
73 // portability of the library.
74 
75 #define AS_MAX_PORTABILITY
76 // Disables all platform specific code. Only the asCALL_GENERIC calling
77 // convention will be available in with this flag set.
78 
79 // AS_DOUBLEBYTE_CHARSET
80 // When this flag is defined, the parser will treat all characters in strings
81 // that are greater than 127 as lead characters and automatically include the
82 // next character in the script without checking its value. This should be
83 // compatible with common encoding schemes, e.g. Big5. Shift-JIS is not compatible
84 // though as it encodes some single byte characters above 127.
85 //
86 // If support for international text is desired, it is recommended that UTF-8
87 // is used as this is supported natively by the compiler without the use for this
88 // preprocessor flag.
89 
90 // AS_NO_COMPILER
91 // Compiles the library without support for compiling scripts. This is intended
92 // for those applications that will load pre-compiled bytecode and wants to decrease
93 // the size of the executable.
94 
95 #define AS_NO_EXCEPTIONS
96 // Define this if exception handling is turned off or not available on the target platform.
97 
98 // AS_NO_MEMBER_INIT
99 // Disable the support for initialization of class members directly in the declaration.
100 // This was as a form to maintain backwards compatibility with versions before 2.26.0
101 // if the new order of the member initialization caused null pointer exceptions in older
102 // scripts (e.g. if a base class accessed members of a derived class through a virtual method).
103 
104 // AS_USE_NAMESPACE
105 // Adds the AngelScript namespace on the declarations.
106 
107 
108 
109 //
110 // Library usage
111 //------------------------------------------
112 
113 // ANGELSCRIPT_EXPORT
114 // This flag should be defined when compiling the library as a lib or dll.
115 
116 // ANGELSCRIPT_DLL_LIBRARY_IMPORT
117 // This flag should be defined when using AngelScript as a dll with automatic
118 // library import.
119 
120 // ANGELSCRIPT_DLL_MANUAL_IMPORT
121 // This flag should be defined when using AngelScript as a dll with manual
122 // loading of the library.
123 
124 
125 
126 
127 //
128 // Compiler differences
129 //-----------------------------------------
130 
131 // asVSNPRINTF(a,b,c,d)
132 // Some compilers use different names for this function. You must
133 // define this macro to map to the proper function.
134 
135 // ASM_AT_N_T or ASM_INTEL
136 // You should choose what inline assembly syntax to use when compiling.
137 
138 // VALUE_OF_BOOLEAN_TRUE
139 // This flag allows to customize the exact value of boolean true.
140 
141 // AS_SIZEOF_BOOL
142 // On some target platforms the sizeof(bool) is 4, but on most it is 1.
143 
144 // STDCALL
145 // This is used to declare a function to use the stdcall calling convention.
146 
147 // AS_NO_MEMORY_H
148 // Some compilers don't come with the memory.h header file.
149 
150 // AS_NO_THISCALL_FUNCTOR_METHOD
151 // Defined if the support for functor methods hasn't been implemented on the platform.
152 
153 
154 
155 //
156 // How to identify different compilers
157 //-----------------------------------------
158 // Ref: http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
159 
160 // MS Visual C++
161 // _MSC_VER is defined
162 // __MWERKS__ is not defined
163 
164 // Metrowerks
165 // _MSC_VER is defined
166 // __MWERKS__ is defined
167 
168 // GNU C based compilers
169 // __GNUC__ is defined
170 
171 // CLang/LLVM
172 // __clang__ is defined
173 
174 // Embarcadero C++Builder
175 // __BORLANDC__ is defined
176 
177 // Oracle Solaris Studio (previously known as Sun CC compiler)
178 // __SUNPRO_CC is defined
179 
180 // Local (or Little) C Compiler
181 // __LCC__ is defined
182 // __e2k__ is not defined
183 
184 // MCST eLbrus C Compiler
185 // __LCC__ is defined
186 // __e2k__ is defined
187 
188 
189 
190 //
191 // CPU differences
192 //---------------------------------------
193 
194 // AS_USE_DOUBLE_AS_FLOAT
195 // If there is no 64 bit floating point type, then this constant can be defined
196 // to treat double like normal floats.
197 
198 // AS_X86
199 // Use assembler code for the x86 CPU family
200 
201 // AS_SH4
202 // Use assembler code for the SH4 CPU family
203 
204 // AS_MIPS
205 // Use assembler code for the MIPS CPU family
206 
207 // AS_PPC
208 // Use assembler code for the 32bit PowerPC CPU family
209 
210 // AS_PPC_64
211 // Use assembler code for the 64bit PowerPC CPU family
212 
213 // AS_XENON
214 // Use assembler code for the Xenon (XBOX360) CPU family
215 
216 // AS_ARM
217 // Use assembler code for the ARM CPU family
218 
219 // AS_ARM64
220 // Use assembler code for the ARM64/AArch64 CPU family
221 
222 // AS_SOFTFP
223 // Use to tell compiler that ARM soft-float ABI
224 // should be used instead of ARM hard-float ABI
225 
226 // AS_X64_GCC
227 // Use GCC assembler code for the X64 AMD/Intel CPU family
228 
229 // AS_X64_MSVC
230 // Use MSVC assembler code for the X64 AMD/Intel CPU family
231 
232 // AS_64BIT_PTR
233 // Define this to make the engine store all pointers in 64bit words.
234 
235 // AS_BIG_ENDIAN
236 // Define this for CPUs that use big endian memory layout, e.g. PPC
237 
238 // AS_SPARC
239 // Define this for SPARC CPU family
240 
241 // AS_E2K
242 // Define this for MCST Elbrus 2000 CPU family
243 
244 
245 
246 
247 //
248 // Target systems
249 //--------------------------------
250 // This group shows a few of the flags used to identify different target systems.
251 // Sometimes there are differences on different target systems, while both CPU and
252 // compiler is the same for both, when this is so these flags are used to produce the
253 // right code.
254 
255 // AS_WIN - Microsoft Windows
256 // AS_LINUX - Linux
257 // AS_MAC - Apple Macintosh
258 // AS_BSD - BSD based OS (FreeBSD, DragonFly, OpenBSD, etc)
259 // AS_XBOX - Microsoft XBox
260 // AS_XBOX360 - Microsoft XBox 360
261 // AS_PSP - Sony Playstation Portable
262 // AS_PSVITA - Sony Playstation Vita
263 // AS_PS2 - Sony Playstation 2
264 // AS_PS3 - Sony Playstation 3
265 // AS_DC - Sega Dreamcast
266 // AS_GC - Nintendo GameCube
267 // AS_WII - Nintendo Wii
268 // AS_WIIU - Nintendo Wii U
269 // AS_NINTENDOSWITCH - Nintendo Switch
270 // AS_IPHONE - Apple IPhone
271 // AS_ANDROID - Android
272 // AS_HAIKU - Haiku
273 // AS_ILLUMOS - Illumos like (OpenSolaris, OpenIndiana, NCP, etc)
274 // AS_MARMALADE - Marmalade cross platform SDK (a layer on top of the OS)
275 // AS_SUN - Sun UNIX
276 
277 
278 
279 
280 //
281 // Calling conventions
282 //-----------------------------------------
283 
284 // GNU_STYLE_VIRTUAL_METHOD
285 // This constant should be defined if method pointers store index for virtual
286 // functions in the same location as the function pointer. In such cases the method
287 // is identified as virtual if the least significant bit is set.
288 
289 // MULTI_BASE_OFFSET(x)
290 // This macro is used to retrieve the offset added to the object pointer in order to
291 // implicitly cast the object to the base object. x is the method pointer received by
292 // the register function.
293 
294 // HAVE_VIRTUAL_BASE_OFFSET
295 // Define this constant if the compiler stores the virtual base offset in the method
296 // pointers. If it is not stored in the pointers then AngelScript have no way of
297 // identifying a method as coming from a class with virtual inheritance.
298 
299 // VIRTUAL_BASE_OFFSET(x)
300 // This macro is used to retrieve the offset added to the object pointer in order to
301 // find the virtual base object. x is the method pointer received by the register
302 // function;
303 
304 // COMPLEX_RETURN_MASK
305 // This constant shows what attributes determine if an object is returned in memory
306 // or in the registers as normal structures
307 
308 // COMPLEX_MASK
309 // This constant shows what attributes determine if an object is implicitly passed
310 // by reference or not, even if the argument is declared by value
311 
312 // THISCALL_RETURN_SIMPLE_IN_MEMORY
313 // CDECL_RETURN_SIMPLE_IN_MEMORY
314 // STDCALL_RETURN_SIMPLE_IN_MEMORY
315 // When these constants are defined then the corresponding calling convention always
316 // return classes/structs in memory regardless of size or complexity.
317 
318 // THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
319 // STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
320 // CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
321 // Specifies the minimum size in dwords a class/struct needs to be to be passed in memory
322 
323 // CALLEE_POPS_HIDDEN_RETURN_POINTER
324 // This constant should be defined if the callee pops the hidden return pointer,
325 // used when returning an object in memory.
326 
327 // THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
328 // This constant should be defined if the callee pops the hidden return pointer
329 // for thiscall functions; used when returning an object in memory.
330 
331 // THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
332 // With this constant defined AngelScript will pass the object pointer on the stack
333 
334 // THISCALL_CALLEE_POPS_ARGUMENTS
335 // If the callee pops arguments for class methods then define this constant
336 
337 // COMPLEX_OBJS_PASSED_BY_REF
338 // Some compilers always pass certain objects by reference. GNUC for example does
339 // this if the the class has a defined destructor.
340 
341 // AS_LARGE_OBJS_PASSED_BY_REF
342 // If this is defined large objects are passed by reference, whether they are complex or not
343 
344 // AS_LARGE_OBJ_MIN_SIZE
345 // This is the size of objects determined as large ones
346 
347 // AS_CALLEE_DESTROY_OBJ_BY_VAL
348 // When an object is passed by value the called function is the one responsible
349 // for calling the destructor before returning.
350 
351 // HAS_128_BIT_PRIMITIVES
352 // 64bit processors often support 128bit primitives. These may require special
353 // treatment when passed in function arguments or returned by functions.
354 
355 // SPLIT_OBJS_BY_MEMBER_TYPES
356 // On some platforms objects with primitive members are split over different
357 // register types when passed by value to functions.
358 
359 
360 
361 
362 
363 //
364 // Detect compiler
365 //------------------------------------------------
366 
367 
368 #define VALUE_OF_BOOLEAN_TRUE 1
369 #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
370 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
371 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
372 #define THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
373 
374 // Not implemented by default. Undefined with tested platforms.
375 #define AS_NO_THISCALL_FUNCTOR_METHOD
376 
377 
378 // Emscripten compiler toolchain
379 // ref: https://emscripten.org/
380 #if defined(__EMSCRIPTEN__)
381 #define AS_MAX_PORTABILITY
382 #endif
383 
384 
385 
386 // Embarcadero C++Builder
387 #if defined(__BORLANDC__)
388 #ifndef _Windows
389 #error "Configuration doesn't yet support BCC for Linux or Mac OS."
390 #endif
391 #if defined(_M_X64)
392 #error "Configuration doesn't yet support BCC for AMD64."
393 #endif
394 
395 #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
396 #define HAVE_VIRTUAL_BASE_OFFSET
397 #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+2))
398 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
399 #define CDECL_RETURN_SIMPLE_IN_MEMORY
400 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
401 #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
402 #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
403 #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
404 #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
405 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
406 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
407 
408 #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
409 #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR)
410 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR)
411 #define STDCALL __stdcall
412 #define AS_SIZEOF_BOOL 1
413 #define AS_WINDOWS_THREADS
414 #undef THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
415 
416 #define AS_WIN
417 #define AS_X86
418 #define ASM_INTEL
419 
420 #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
421 
422 #define fmodf(a,b) fmod(a,b)
423 
424 #define UNREACHABLE_RETURN
425 #endif
426 
427 // Microsoft Visual C++
428 // Ref: http://msdn.microsoft.com/en-us/library/b0084kay.aspx
429 #if defined(_MSC_VER) && !defined(__MWERKS__)
430 
431 #if _MSC_VER <= 1200 // MSVC6
432 // Disable the useless warnings about truncated symbol names for template instances
433 #pragma warning( disable : 4786 )
434 #endif
435 
436 #ifdef _M_X64
437 #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+2))
438 #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+4))
439 #else
440 #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
441 #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+3))
442 #endif
443 #define HAVE_VIRTUAL_BASE_OFFSET
444 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
445 #define THISCALL_PASS_OBJECT_POINTER_IN_ECX
446 
447 // http://www.madewithmarmalade.com/
448 #if defined(__S3E__)
449 #ifndef AS_MARMALADE
450 // From now on we'll use the below define
451 #define AS_MARMALADE
452 #endif
453 
454 // Marmalade doesn't use the Windows libraries
455 #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
456 
457 // Marmalade doesn't seem to have proper support for
458 // atomic instructions or read/write locks, so we turn off
459 // multithread support
460 //#define AS_POSIX_THREADS
461 #define AS_NO_THREADS
462 #define AS_NO_ATOMIC
463 
464 // Marmalade has it's own way of identifying the CPU target
465 // Note, when building for ARM, the gnuc compiler will always
466 // be used so we don't need to check for it here
467 #if defined(I3D_ARCH_X86)
468 #define AS_X86
469 #endif
470 #else
471 #if _MSC_VER < 1500 // MSVC++ 9 (aka MSVC++ .NET 2008)
472 #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
473 #else
474 #define asVSNPRINTF(a, b, c, d) vsnprintf_s(a, b, _TRUNCATE, c, d)
475 #endif
476 
477 #define AS_WINDOWS_THREADS
478 #endif
479 
480 #define THISCALL_CALLEE_POPS_ARGUMENTS
481 #define STDCALL __stdcall
482 #define AS_SIZEOF_BOOL 1
483 #define COMPLEX_OBJS_PASSED_BY_REF
484 
485 #define ASM_INTEL // Intel style for inline assembly on microsoft compilers
486 
487 #if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
488 #define AS_WIN
489 #endif
490 
491 #if _XBOX_VER >= 200
492 // 360 uses a Xenon processor (which is a modified 64bit PPC)
493 #define AS_XBOX360
494 #define AS_XENON
495 #define AS_BIG_ENDIAN
496 #else
497 #if defined(_XBOX) || (defined(_M_IX86) && !defined(__LP64__))
498 #define AS_X86
499 #ifndef _XBOX
500 // Not tested with xbox (only enabled if is Windows)
501 #undef AS_NO_THISCALL_FUNCTOR_METHOD
502 #endif
503 #elif defined(_M_X64)
504 #define AS_X64_MSVC
505 #undef AS_NO_THISCALL_FUNCTOR_METHOD
506 #define AS_CALLEE_DESTROY_OBJ_BY_VAL
507 #define AS_LARGE_OBJS_PASSED_BY_REF
508 #define AS_LARGE_OBJ_MIN_SIZE 3
509 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY | asOBJ_APP_CLASS_MORE_CONSTRUCTORS)
510 #define COMPLEX_MASK (asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
511 #endif
512 #endif
513 
514 #if defined(_ARM_) || defined(_M_ARM)
515 #define AS_ARM
516 #define AS_CALLEE_DESTROY_OBJ_BY_VAL
517 #define CDECL_RETURN_SIMPLE_IN_MEMORY
518 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
519 #define COMPLEX_MASK (asOBJ_APP_CLASS_ASSIGNMENT | asOBJ_APP_ARRAY)
520 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_ASSIGNMENT | asOBJ_APP_ARRAY)
521 
522 // Windows CE uses softfp calling convention, while Windows RT uses hardfp calling convention
523 // ref: http://stackoverflow.com/questions/16375355/what-is-the-windows-rt-on-arm-native-code-calling-convention
524 #if defined(_WIN32_WCE)
525 #define AS_SOFTFP
526 #endif
527 #endif
528 
529 #if defined(_M_ARM64)
530 #define AS_ARM64
531 
532 // TODO: MORE HERE
533 #endif
534 
535 #ifndef COMPLEX_MASK
536 #define COMPLEX_MASK (asOBJ_APP_ARRAY)
537 #endif
538 
539 #ifndef COMPLEX_RETURN_MASK
540 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT | asOBJ_APP_ARRAY | asOBJ_APP_CLASS_MORE_CONSTRUCTORS)
541 #endif
542 
543 #define UNREACHABLE_RETURN
544 #endif
545 
546 // Metrowerks CodeWarrior (experimental, let me know if something isn't working)
547 #if defined(__MWERKS__) && !defined(EPPC) // JWC -- If Wii DO NOT use this even when using Metrowerks Compiler. Even though they are called Freescale...
548 #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
549 #define HAVE_VIRTUAL_BASE_OFFSET
550 #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+3))
551 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
552 #define THISCALL_PASS_OBJECT_POINTER_IN_ECX
553 #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
554 #define THISCALL_CALLEE_POPS_ARGUMENTS
555 #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
556 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
557 #define AS_SIZEOF_BOOL 1
558 #define AS_WINDOWS_THREADS
559 #define STDCALL __stdcall
560 
561 // Support native calling conventions on x86, but not 64bit yet
562 #if defined(_M_IX86) && !defined(__LP64__)
563 #define AS_X86
564 #define ASM_INTEL // Intel style for inline assembly
565 #endif
566 
567 #define UNREACHABLE_RETURN
568 #endif
569 
570 // SN Systems ProDG
571 #if defined(__SNC__) || defined(SNSYS)
572 #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
573 #define CALLEE_POPS_HIDDEN_RETURN_POINTER
574 #define COMPLEX_OBJS_PASSED_BY_REF
575 
576 #ifdef __psp2__
577 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
578 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
579 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
580 #define CDECL_RETURN_SIMPLE_IN_MEMORY
581 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
582 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
583 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
584 #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
585 #else
586 #define GNU_STYLE_VIRTUAL_METHOD
587 #define ASM_AT_N_T // AT&T style inline assembly
588 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
589 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
590 #endif
591 
592 #define AS_SIZEOF_BOOL 1
593 #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
594 
595 // SN doesnt seem to like STDCALL.
596 // Maybe it can work with some fiddling, but I can't imagine linking to
597 // any STDCALL functions with a console anyway...
598 #define STDCALL
599 
600 // Linux specific
601 #ifdef __linux__
602 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
603 #define CDECL_RETURN_SIMPLE_IN_MEMORY
604 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
605 #endif
606 
607 // Support native calling conventions on x86, but not 64bit yet
608 #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
609 #define AS_X86
610 // PS3
611 #elif (defined(__PPC__) || defined(__ppc__)) && defined(__PPU__)
612 // Support native calling conventions on PS3
613 #define AS_PS3
614 #define AS_PPC_64
615 #define AS_NO_MEMORY_H
616 #define AS_NO_EXCEPTIONS
617 #include <stdlib.h>
618 // PSP
619 #elif defined(__psp__)
620 #define AS_NO_MEMORY_H
621 #define AS_MIPS
622 #define AS_PSP
623 #define AS_USE_DOUBLE_AS_FLOAT
624 // PSVita
625 #elif defined(__psp2__)
626 #define AS_PSVITA
627 #define AS_ARM
628 #define AS_NO_MEMORY_H
629 #define AS_NO_EXCEPTIONS
630 #define AS_CALLEE_DESTROY_OBJ_BY_VAL
631 #undef AS_NO_THISCALL_FUNCTOR_METHOD
632 #endif
633 
634 #define UNREACHABLE_RETURN
635 #endif
636 
637 // GNU C (and MinGW or Cygwin on Windows)
638 // Use the following command to determine predefined macros: echo . | g++ -dM -E -
639 // MSVC2015 can now use CLang too, but it shouldn't go in here
640 #if (defined(__GNUC__) && !defined(__SNC__) && !defined(_MSC_VER)) || defined(EPPC) || defined(__CYGWIN__) // JWC -- use this instead for Wii
641 #define GNU_STYLE_VIRTUAL_METHOD
642 #define MULTI_BASE_OFFSET(x) (*((const asPWORD*)(&x)+1))
643 #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
644 #define CALLEE_POPS_HIDDEN_RETURN_POINTER
645 #define COMPLEX_OBJS_PASSED_BY_REF
646 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_ARRAY)
647 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_ARRAY)
648 #define AS_NO_MEMORY_H
649 #define AS_SIZEOF_BOOL 1
650 #define STDCALL __attribute__((stdcall))
651 #define ASM_AT_N_T
652 
653 // WII U
654 #if defined(__ghs__)
655 #define AS_WIIU
656 
657 // Native calling conventions are not yet supported
658 #define AS_MAX_PORTABILITY
659 
660 // Nintendo Switch
661 // Note, __SWITCH__ is not an official define in the Nintendo dev kit.
662 // You need to manually add this to the project when compiling for Switch.
663 #elif defined(__SWITCH__)
664 #define AS_NINTENDOSWITCH
665 
666 #if (!defined(__LP64__))
667 #error write me
668 #else
669 #define AS_ARM64
670 #undef STDCALL
671 #define STDCALL
672 
673 #undef GNU_STYLE_VIRTUAL_METHOD
674 #undef AS_NO_THISCALL_FUNCTOR_METHOD
675 
676 #define HAS_128_BIT_PRIMITIVES
677 
678 #define CDECL_RETURN_SIMPLE_IN_MEMORY
679 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
680 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
681 
682 #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
683 #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
684 #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
685 
686 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 5
687 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 5
688 #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 5
689 #endif
690 
691 // Marmalade is a cross platform SDK. It uses g++ to compile for iOS and Android
692 #elif defined(__S3E__)
693 #ifndef AS_MARMALADE
694 // From now on we'll use the below define
695 #define AS_MARMALADE
696 #endif
697 
698 // STDCALL is not available on Marmalade when compiled for iOS or Android
699 #undef STDCALL
700 #define STDCALL
701 
702 // Marmalade doesn't seem to have proper support for
703 // atomic instructions or read/write locks
704 #define AS_NO_THREADS
705 #define AS_NO_ATOMIC
706 
707 // Identify for which CPU the library is being built
708 #if defined(I3D_ARCH_X86)
709 #define AS_X86
710 #elif defined(I3D_ARCH_ARM)
711 #define AS_ARM
712 
713 #define AS_SOFTFP
714 
715 // Marmalade appear to use the same ABI as Android when built for ARM
716 #define CDECL_RETURN_SIMPLE_IN_MEMORY
717 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
718 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
719 
720 #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
721 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
722 
723 #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
724 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
725 
726 #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
727 #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
728 
729 #undef GNU_STYLE_VIRTUAL_METHOD
730 
731 #undef COMPLEX_MASK
732 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
733 #undef COMPLEX_RETURN_MASK
734 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
735 
736 #define AS_CALLEE_DESTROY_OBJ_BY_VAL
737 #endif
738 
739 // MacOSX and IPhone
740 #elif defined(__APPLE__)
741 
742 #include <TargetConditionals.h>
743 
744 // Is this a Mac or an IPhone (or other iOS device)?
745 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1
746 #define AS_IPHONE
747 #else
748 #define AS_MAC
749 #endif
750 
751 // The sizeof bool is different depending on the target CPU
752 #undef AS_SIZEOF_BOOL
753 #if defined(__ppc__)
754 #define AS_SIZEOF_BOOL 4
755 // STDCALL is not available on PPC
756 #undef STDCALL
757 #define STDCALL
758 #else
759 #define AS_SIZEOF_BOOL 1
760 #endif
761 
762 #if (defined(_ARM_) || defined(__arm__))
763 // iOS use ARM processor
764 #define AS_ARM
765 #undef AS_NO_THISCALL_FUNCTOR_METHOD
766 #define CDECL_RETURN_SIMPLE_IN_MEMORY
767 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
768 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
769 
770 #undef GNU_STYLE_VIRTUAL_METHOD
771 
772 #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
773 #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
774 #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
775 
776 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
777 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
778 #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
779 #define COMPLEX_OBJS_PASSED_BY_REF
780 #undef COMPLEX_MASK
781 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
782 #undef COMPLEX_RETURN_MASK
783 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
784 
785 // iOS uses soft-float ABI
786 #define AS_SOFTFP
787 
788 // STDCALL is not available on ARM
789 #undef STDCALL
790 #define STDCALL
791 
792 #elif (defined(__aarch64__))
793 // The IPhone 5S+ uses an ARM64 processor
794 
795 // AngelScript currently doesn't support native calling
796 // for 64bit ARM processors so it's necessary to turn on
797 // portability mode
798 #define AS_MAX_PORTABILITY
799 
800 // STDCALL is not available on ARM
801 #undef STDCALL
802 #define STDCALL
803 
804 #elif (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
805 // Support native calling conventions on Mac OS X + Intel 32bit CPU
806 #define AS_X86
807 #undef AS_NO_THISCALL_FUNCTOR_METHOD
808 #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
809 #undef COMPLEX_MASK
810 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
811 #undef COMPLEX_RETURN_MASK
812 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
813 
814 #elif defined(__LP64__) && !defined(__ppc__) && !defined(__PPC__) && !defined(__aarch64__)
815 // http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/LowLevelABI/140-x86-64_Function_Calling_Conventions/x86_64.html#//apple_ref/doc/uid/TP40005035-SW1
816 #define AS_X64_GCC
817 #undef AS_NO_THISCALL_FUNCTOR_METHOD
818 #define HAS_128_BIT_PRIMITIVES
819 #define SPLIT_OBJS_BY_MEMBER_TYPES
820 #undef COMPLEX_MASK
821 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
822 #undef COMPLEX_RETURN_MASK
823 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
824 #define AS_LARGE_OBJS_PASSED_BY_REF
825 #define AS_LARGE_OBJ_MIN_SIZE 5
826 // STDCALL is not available on 64bit Mac
827 #undef STDCALL
828 #define STDCALL
829 
830 #elif (defined(__ppc__) || defined(__PPC__)) && !defined(__LP64__)
831 // Support native calling conventions on Mac OS X + PPC 32bit CPU
832 #define AS_PPC
833 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
834 #define CDECL_RETURN_SIMPLE_IN_MEMORY
835 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
836 #undef COMPLEX_MASK
837 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
838 #undef COMPLEX_RETURN_MASK
839 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
840 
841 #elif (defined(__ppc__) || defined(__PPC__)) && defined(__LP64__)
842 #define AS_PPC_64
843 #else
844 // Unknown CPU type
845 #define AS_MAX_PORTABILITY
846 #endif
847 #define AS_POSIX_THREADS
848 
849 // Windows
850 #elif defined(WIN32) || defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
851 // On Windows the simple classes are returned in the EAX:EDX registers
852 //#define THISCALL_RETURN_SIMPLE_IN_MEMORY
853 //#define CDECL_RETURN_SIMPLE_IN_MEMORY
854 //#define STDCALL_RETURN_SIMPLE_IN_MEMORY
855 
856 #undef COMPLEX_MASK
857 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
858 #undef COMPLEX_RETURN_MASK
859 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
860 
861 #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
862 // Support native calling conventions on Intel 32bit CPU
863 #define AS_X86
864 #undef AS_NO_THISCALL_FUNCTOR_METHOD
865 
866 // As of version 4.7 MinGW changed the ABI, presumably
867 // to be better aligned with how MSVC works
868 #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || __GNUC__ > 4
869 #define AS_MINGW47
870 #endif
871 
872 #if (__clang_major__ == 3 && __clang_minor__ > 4) || __clang_major > 3
873 #define AS_MINGW47
874 #endif
875 
876 #ifdef AS_MINGW47
877 #undef CALLEE_POPS_HIDDEN_RETURN_POINTER
878 #define THISCALL_CALLEE_POPS_ARGUMENTS
879 #else
880 // Earlier versions than 4.7
881 #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
882 #endif
883 
884 #elif defined(__x86_64__)
885 #define AS_X64_MINGW
886 #undef AS_NO_THISCALL_FUNCTOR_METHOD
887 #define AS_LARGE_OBJS_PASSED_BY_REF
888 #define AS_LARGE_OBJ_MIN_SIZE 3
889 #define COMPLEX_OBJS_PASSED_BY_REF
890 #else
891 #define AS_MAX_PORTABILITY
892 #endif
893 #define AS_WIN
894 #define AS_WINDOWS_THREADS
895 
896 // Linux
897 #elif defined(__linux__) && !defined(ANDROID) && !defined(__ANDROID__)
898 
899 #undef COMPLEX_MASK
900 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
901 #undef COMPLEX_RETURN_MASK
902 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
903 
904 #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
905 // x86 32bit
906 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
907 #define CDECL_RETURN_SIMPLE_IN_MEMORY
908 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
909 
910 // Support native calling conventions on Intel 32bit CPU
911 #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
912 #define AS_X86
913 #undef AS_NO_THISCALL_FUNCTOR_METHOD
914 #elif defined(__x86_64__)
915 // x86 64bit
916 #define AS_X64_GCC
917 #undef AS_NO_THISCALL_FUNCTOR_METHOD
918 #define HAS_128_BIT_PRIMITIVES
919 #define SPLIT_OBJS_BY_MEMBER_TYPES
920 #define AS_LARGE_OBJS_PASSED_BY_REF
921 #define AS_LARGE_OBJ_MIN_SIZE 5
922 // STDCALL is not available on 64bit Linux
923 #undef STDCALL
924 #define STDCALL
925 #elif defined(__ARMEL__) || defined(__arm__) || defined(__aarch64__) || defined(__AARCH64EL__)
926 // arm
927 
928 // The assembler code currently doesn't support arm v4
929 #if !defined(__ARM_ARCH_4__) && !defined(__ARM_ARCH_4T__) && !defined(__LP64__)
930 #define AS_ARM
931 
932 // TODO: The stack unwind on exceptions currently fails due to the assembler code in as_callfunc_arm_gcc.S
933 #define AS_NO_EXCEPTIONS
934 
935 #undef STDCALL
936 #define STDCALL
937 
938 #define CDECL_RETURN_SIMPLE_IN_MEMORY
939 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
940 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
941 
942 #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
943 #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
944 #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
945 
946 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
947 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
948 #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
949 
950 #ifndef AS_MAX_PORTABILITY
951 // Make a few checks against incompatible ABI combinations
952 #if defined(__FAST_MATH__) && __FAST_MATH__ == 1
953 #error -ffast-math is not supported with native calling conventions
954 #endif
955 #endif
956 
957 // Verify if soft-float or hard-float ABI is used
958 #if (defined(__SOFTFP__) && __SOFTFP__ == 1) || defined(__ARM_PCS)
959 // -ffloat-abi=softfp or -ffloat-abi=soft
960 #define AS_SOFTFP
961 #endif
962 
963 // Tested with both hard float and soft float abi
964 #undef AS_NO_THISCALL_FUNCTOR_METHOD
965 #elif defined(__LP64__) || defined(__aarch64__)
966 #define AS_ARM64
967 
968 #undef STDCALL
969 #define STDCALL
970 
971 #undef GNU_STYLE_VIRTUAL_METHOD
972 #undef AS_NO_THISCALL_FUNCTOR_METHOD
973 
974 #define HAS_128_BIT_PRIMITIVES
975 
976 #define CDECL_RETURN_SIMPLE_IN_MEMORY
977 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
978 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
979 
980 #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
981 #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
982 #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
983 
984 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 5
985 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 5
986 #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 5
987 #endif
988 
989 #elif defined(__mips__)
990 // mips
991 #define AS_MIPS
992 #undef STDCALL
993 #define STDCALL
994 
995 #ifdef _ABIO32
996 // 32bit O32 ABI
997 #define AS_MIPS
998 
999 // All structures are returned in memory regardless of size or complexity
1000 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
1001 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
1002 #define CDECL_RETURN_SIMPLE_IN_MEMORY
1003 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
1004 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
1005 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
1006 #undef AS_NO_THISCALL_FUNCTOR_METHOD
1007 #else
1008 // For other ABIs the native calling convention is not available (yet)
1009 #define AS_MAX_PORTABILITY
1010 #endif
1011 #elif defined(__PPC64__)
1012 // PPC 64bit
1013 
1014 // The code in as_callfunc_ppc_64.cpp was built for PS3 and XBox 360, that
1015 // although use 64bit PPC only uses 32bit pointers.
1016 // TODO: Add support for native calling conventions on Linux with PPC 64bit
1017 #define AS_MAX_PORTABILITY
1018 #elif defined(__e2k__)
1019 // 64bit MCST Elbrus 2000
1020 // ref: https://en.wikipedia.org/wiki/Elbrus_2000
1021 #define AS_E2K
1022 // AngelScript currently doesn't support native calling
1023 // for MCST Elbrus 2000 processor so it's necessary to turn on
1024 // portability mode
1025 #define AS_MAX_PORTABILITY
1026 // STDCALL is not available on 64bit Linux
1027 #undef STDCALL
1028 #define STDCALL
1029 #else
1030 #define AS_MAX_PORTABILITY
1031 #endif
1032 #define AS_LINUX
1033 #define AS_POSIX_THREADS
1034 
1035 #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
1036 // Only with GCC 4.1 was the atomic instructions available
1037 #define AS_NO_ATOMIC
1038 #endif
1039 
1040 // Free BSD
1041 #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
1042 #define AS_BSD
1043 #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
1044 #undef COMPLEX_MASK
1045 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
1046 #undef COMPLEX_RETURN_MASK
1047 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
1048 #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
1049 #define AS_X86
1050 #elif defined(__x86_64__)
1051 #define AS_X64_GCC
1052 #define HAS_128_BIT_PRIMITIVES
1053 #define SPLIT_OBJS_BY_MEMBER_TYPES
1054 #undef COMPLEX_MASK
1055 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
1056 #undef COMPLEX_RETURN_MASK
1057 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
1058 #define AS_LARGE_OBJS_PASSED_BY_REF
1059 #define AS_LARGE_OBJ_MIN_SIZE 5
1060 #undef STDCALL
1061 #define STDCALL
1062 #else
1063 #define AS_MAX_PORTABILITY
1064 #endif
1065 #define AS_POSIX_THREADS
1066 #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
1067 // Only with GCC 4.1 was the atomic instructions available
1068 #define AS_NO_ATOMIC
1069 #endif
1070 
1071 // PSP and PS2
1072 #elif defined(__PSP__) || defined(__psp__) || defined(_EE_) || defined(_PSP) || defined(_PS2)
1073 // Support native calling conventions on MIPS architecture
1074 #if (defined(_MIPS_ARCH) || defined(_mips) || defined(__MIPSEL__)) && !defined(__LP64__)
1075 #define AS_MIPS
1076 #define AS_USE_DOUBLE_AS_FLOAT
1077 #else
1078 #define AS_MAX_PORTABILITY
1079 #endif
1080 
1081 // PS3
1082 #elif (defined(__PPC__) || defined(__ppc__)) && defined(__PPU__)
1083 // Support native calling conventions on PS3
1084 #define AS_PS3
1085 #define AS_PPC_64
1086 #define SPLIT_OBJS_BY_MEMBER_TYPES
1087 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
1088 #define CDECL_RETURN_SIMPLE_IN_MEMORY
1089 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
1090 // PS3 doesn't have STDCALL
1091 #undef STDCALL
1092 #define STDCALL
1093 
1094 // Dreamcast
1095 #elif __SH4_SINGLE_ONLY__
1096 // Support native calling conventions on Dreamcast
1097 #define AS_DC
1098 #define AS_SH4
1099 
1100 // Wii JWC - Close to PS3 just no PPC_64 and AS_PS3
1101 #elif defined(EPPC)
1102 #define AS_WII
1103 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
1104 #define CDECL_RETURN_SIMPLE_IN_MEMORY
1105 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
1106 #undef STDCALL
1107 #define STDCALL
1108 
1109 // Android
1110 #elif defined(ANDROID) || defined(__ANDROID__)
1111 #define AS_ANDROID
1112 
1113 // Android 2.3+ supports posix threads
1114 #define AS_POSIX_THREADS
1115 
1116 // Common configuration with Android arm and x86
1117 #define CDECL_RETURN_SIMPLE_IN_MEMORY
1118 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
1119 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
1120 
1121 #undef COMPLEX_MASK
1122 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
1123 #undef COMPLEX_RETURN_MASK
1124 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
1125 
1126 #if (defined(_ARM_) || defined(__arm__) || defined(__aarch64__) || defined(__AARCH64EL__))
1127 // Android ARM
1128 
1129 #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
1130 #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
1131 #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
1132 
1133 // The stdcall calling convention is not used on the arm cpu
1134 #undef STDCALL
1135 #define STDCALL
1136 
1137 #undef GNU_STYLE_VIRTUAL_METHOD
1138 #undef AS_NO_THISCALL_FUNCTOR_METHOD
1139 
1140 #if (!defined(__LP64__))
1141 // TODO: The stack unwind on exceptions currently fails due to the assembler code in as_callfunc_arm_gcc.S
1142 #define AS_NO_EXCEPTIONS
1143 
1144 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
1145 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
1146 #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
1147 
1148 #define AS_ARM
1149 #define AS_SOFTFP
1150 #define AS_CALLEE_DESTROY_OBJ_BY_VAL
1151 #elif (defined(__LP64__) || defined(__aarch64__))
1152 #define AS_ARM64
1153 
1154 #define HAS_128_BIT_PRIMITIVES
1155 
1156 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 5
1157 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 5
1158 #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 5
1159 #endif
1160 #elif (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
1161 // Android Intel x86 (same config as Linux x86). Tested with Intel x86 Atom System Image.
1162 
1163 // Support native calling conventions on Intel 32bit CPU
1164 #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
1165 #define AS_X86
1166 #undef AS_NO_THISCALL_FUNCTOR_METHOD
1167 #elif defined(__mips__)
1168 #define AS_MIPS
1169 #undef STDCALL
1170 #define STDCALL
1171 
1172 #ifdef _ABIO32
1173 #define AS_MIPS
1174 
1175 // All structures are returned in memory regardless of size or complexity
1176 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
1177 #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
1178 #define CDECL_RETURN_SIMPLE_IN_MEMORY
1179 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
1180 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
1181 #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
1182 #undef AS_NO_THISCALL_FUNCTOR_METHOD
1183 #else
1184 // For other ABIs the native calling convention is not available (yet)
1185 #define AS_MAX_PORTABILITY
1186 #endif
1187 #endif
1188 
1189 // Haiku OS
1190 #elif __HAIKU__
1191 #define AS_HAIKU
1192 #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
1193 #define AS_X86
1194 #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
1195 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
1196 #define CDECL_RETURN_SIMPLE_IN_MEMORY
1197 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
1198 #elif defined(__x86_64__)
1199 #define AS_X64_GCC
1200 #define HAS_128_BIT_PRIMITIVES
1201 #define SPLIT_OBJS_BY_MEMBER_TYPES
1202 #undef COMPLEX_MASK
1203 #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
1204 #undef COMPLEX_RETURN_MASK
1205 #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
1206 #define AS_LARGE_OBJS_PASSED_BY_REF
1207 #define AS_LARGE_OBJ_MIN_SIZE 5
1208 #undef STDCALL
1209 #define STDCALL
1210 #else
1211 #define AS_MAX_PORTABILITY
1212 #endif
1213 
1214 // Illumos
1215 #elif defined(__sun)
1216 #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
1217 #define THISCALL_RETURN_SIMPLE_IN_MEMORY
1218 #define CDECL_RETURN_SIMPLE_IN_MEMORY
1219 #define STDCALL_RETURN_SIMPLE_IN_MEMORY
1220 
1221 // Support native calling conventions on Intel 32bit CPU
1222 #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
1223 #define AS_X86
1224 #elif defined(__x86_64__)
1225 #define AS_X64_GCC
1226 #define HAS_128_BIT_PRIMITIVES
1227 #define SPLIT_OBJS_BY_MEMBER_TYPES
1228 // STDCALL is not available on 64bit Linux
1229 #undef STDCALL
1230 #define STDCALL
1231 #else
1232 #define AS_MAX_PORTABILITY
1233 #endif
1234 #define AS_ILLUMOS
1235 #define AS_POSIX_THREADS
1236 
1237 #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
1238 // Only with GCC 4.1 was the atomic instructions available
1239 #define AS_NO_ATOMIC
1240 #endif
1241 #endif
1242 
1243 #define UNREACHABLE_RETURN
1244 #endif
1245 
1246 // Sun CC
1247 // Initial information provided by Andrey Bergman
1248 #if defined(__SUNPRO_CC)
1249 #if defined(__sparc)
1250 #define AS_SPARC
1251 #endif
1252 
1253 #if defined(__sun)
1254 #define AS_SUN
1255 #endif
1256 
1257 // Native calling conventions is not yet supported for Sun CC
1258 #if !defined(AS_MAX_PORTABILITY)
1259 #define AS_MAX_PORTABILITY
1260 #endif
1261 
1262 // I presume Sun CC uses a similar structure of method pointers as gnuc
1263 #define MULTI_BASE_OFFSET(x) (*((asPWORD*)(&x)+1))
1264 
1265 #if !defined(AS_SIZEOF_BOOL)
1266 #define AS_SIZEOF_BOOL 1 // sizeof(bool) == 1
1267 #endif
1268 #if !defined(UNREACHABLE_RETURN)
1269 #define UNREACHABLE_RETURN
1270 #endif
1271 #if !defined(STDCALL)
1272 #define STDCALL // There is no stdcall on Solaris/SunPro/SPARC
1273 #endif
1274 #if !defined(asVSNPRINTF)
1275 #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
1276 #endif
1277 #endif
1278 
1279 
1280 //
1281 // Detect target hardware
1282 //------------------------------------------------
1283 
1284 // Big endian CPU target?
1285 // see: http://sourceforge.net/p/predef/wiki/Endianness/
1286 #if !defined(AS_BIG_ENDIAN) && \
1287  defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \
1288  defined(__BIG_ENDIAN__) || \
1289  defined(__ARMEB__) || \
1290  defined(__THUMBEB__) || \
1291  defined(__AARCH64EB__) || \
1292  defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__)
1293 #define AS_BIG_ENDIAN
1294 #endif
1295 
1296 // Dreamcast and Gamecube use only 32bit floats, so treat doubles as floats
1297 #if defined(__SH4_SINGLE_ONLY__) || defined(_GC)
1298 #define AS_USE_DOUBLE_AS_FLOAT // use 32bit floats instead of doubles
1299 #endif
1300 
1301 // If there are no current support for native calling
1302 // conventions, then compile with AS_MAX_PORTABILITY
1303 #if (!defined(AS_X86) && !defined(AS_SH4) && !defined(AS_MIPS) && !defined(AS_PPC) && !defined(AS_PPC_64) && !defined(AS_XENON) && !defined(AS_X64_GCC) && !defined(AS_X64_MSVC) && !defined(AS_ARM) && !defined(AS_ARM64) && !defined(AS_X64_MINGW))
1304 #ifndef AS_MAX_PORTABILITY
1305 #define AS_MAX_PORTABILITY
1306 #endif
1307 #endif
1308 
1309 // If the platform doesn't support atomic instructions we can't allow
1310 // multithreading as the reference counters won't be threadsafe
1311 #if defined(AS_NO_ATOMIC) && !defined(AS_NO_THREADS)
1312 #define AS_NO_THREADS
1313 #endif
1314 
1315 // If the form of threads to use hasn't been chosen
1316 // then the library will be compiled without support
1317 // for multithreading
1318 #if !defined(AS_POSIX_THREADS) && !defined(AS_WINDOWS_THREADS)
1319 #define AS_NO_THREADS
1320 #endif
1321 
1322 
1323 // The assert macro
1324 #if defined(ANDROID)
1325 #if defined(AS_DEBUG)
1326 #include <android/log.h>
1327 #include <stdlib.h>
1328 #define asASSERT(x) \
1329  do { \
1330  if (!(x)) { \
1331  __android_log_print(ANDROID_LOG_ERROR, "AngelScript", "Assert failed at %s:%d - %s", __FILE__, __LINE__, #x); \
1332  exit(1); \
1333  } \
1334  } while (0)
1335 #else
1336 #define asASSERT(x)
1337 #endif
1338 #else
1339 #include <assert.h>
1340 #define asASSERT(x) assert(x)
1341 #endif
1342 
1343 
1344 
1345 //
1346 // Internal defines (do not change these)
1347 //----------------------------------------------------------------
1348 
1349 #define ARG_W(b) ((asWORD*)&b)
1350 #define ARG_DW(b) ((asDWORD*)&b)
1351 #define ARG_QW(b) ((asQWORD*)&b)
1352 #define ARG_PTR(b) ((asPWORD*)&b)
1353 #define BCARG_W(b) ((asWORD*)&(b)[1])
1354 #define BCARG_DW(b) ((asDWORD*)&(b)[1])
1355 #define BCARG_QW(b) ((asQWORD*)&(b)[1])
1356 #define BCARG_PTR(b) ((asPWORD*)&(b)[1])
1357 
1358 // This macro is used to avoid warnings about unused variables.
1359 // Usually where the variables are only used in debug mode.
1360 #define UNUSED_VAR(x) (void)(x)
1361 
1362 #include "hpl1/engine/libraries/angelscript/angelscript.h"
1363 
1364 #ifdef AS_USE_NAMESPACE
1365 using namespace AngelScript;
1366 #endif
1367 
1368 #endif