as_config.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. /*
  2. AngelCode Scripting Library
  3. Copyright (c) 2003-2014 Andreas Jonsson
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any
  6. damages arising from the use of this software.
  7. Permission is granted to anyone to use this software for any
  8. purpose, including commercial applications, and to alter it and
  9. redistribute it freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you
  11. must not claim that you wrote the original software. If you use
  12. this software in a product, an acknowledgment in the product
  13. documentation would be appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and
  15. must not be misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source
  17. distribution.
  18. The original version of this library can be located at:
  19. http://www.angelcode.com/angelscript/
  20. Andreas Jonsson
  21. [email protected]
  22. */
  23. //
  24. // as_config.h
  25. //
  26. // this file is used for configuring the compilation of the library
  27. //
  28. #ifndef AS_CONFIG_H
  29. #define AS_CONFIG_H
  30. //
  31. // Features
  32. //-----------------------------------------
  33. // AS_NO_THREADS
  34. // Turns off support for multithreading. By turning off
  35. // this when it's not needed a bit of performance is gained.
  36. // AS_WINDOWS_THREADS
  37. // If the library should be compiled using windows threads.
  38. // AS_POSIX_THREADS
  39. // If the library should be compiled using posix threads.
  40. // AS_NO_ATOMIC
  41. // If the compiler/platform doesn't support atomic instructions
  42. // then this should be defined to use critical sections instead.
  43. // AS_DEBUG
  44. // This flag can be defined to make the library write some extra output when
  45. // compiling and executing scripts.
  46. // AS_DEPRECATED
  47. // If this flag is defined then some backwards compatibility is maintained.
  48. // There is no guarantee for how well deprecated functionality will work though
  49. // so it is best to exchange it for the new functionality as soon as possible.
  50. // AS_NO_CLASS_METHODS
  51. // Disables the possibility to add class methods. Can increase the
  52. // portability of the library.
  53. // AS_MAX_PORTABILITY
  54. // Disables all platform specific code. Only the asCALL_GENERIC calling
  55. // convention will be available in with this flag set.
  56. // AS_DOUBLEBYTE_CHARSET
  57. // When this flag is defined, the parser will treat all characters in strings
  58. // that are greater than 127 as lead characters and automatically include the
  59. // next character in the script without checking its value. This should be
  60. // compatible with common encoding schemes, e.g. Big5. Shift-JIS is not compatible
  61. // though as it encodes some single byte characters above 127.
  62. //
  63. // If support for international text is desired, it is recommended that UTF-8
  64. // is used as this is supported natively by the compiler without the use for this
  65. // preprocessor flag.
  66. // AS_NO_COMPILER
  67. // Compiles the library without support for compiling scripts. This is intended
  68. // for those applications that will load pre-compiled bytecode and wants to decrease
  69. // the size of the executable.
  70. // AS_NO_EXCEPTIONS
  71. // Define this if exception handling is turned off or not available on the target platform.
  72. // AS_NO_MEMBER_INIT
  73. // Disable the support for initialization of class members directly in the declaration.
  74. // This was as a form to maintain backwards compatibility with versions before 2.26.0
  75. // if the new order of the member initialization caused null pointer exceptions in older
  76. // scripts (e.g. if a base class accessed members of a derived class through a virtual method).
  77. //
  78. // Library usage
  79. //------------------------------------------
  80. // ANGELSCRIPT_EXPORT
  81. // This flag should be defined when compiling the library as a lib or dll.
  82. // ANGELSCRIPT_DLL_LIBRARY_IMPORT
  83. // This flag should be defined when using AngelScript as a dll with automatic
  84. // library import.
  85. // ANGELSCRIPT_DLL_MANUAL_IMPORT
  86. // This flag should be defined when using AngelScript as a dll with manual
  87. // loading of the library.
  88. //
  89. // Compiler differences
  90. //-----------------------------------------
  91. // asVSNPRINTF(a,b,c,d)
  92. // Some compilers use different names for this function. You must
  93. // define this macro to map to the proper function.
  94. // ASM_AT_N_T or ASM_INTEL
  95. // You should choose what inline assembly syntax to use when compiling.
  96. // VALUE_OF_BOOLEAN_TRUE
  97. // This flag allows to customize the exact value of boolean true.
  98. // AS_SIZEOF_BOOL
  99. // On some target platforms the sizeof(bool) is 4, but on most it is 1.
  100. // STDCALL
  101. // This is used to declare a function to use the stdcall calling convention.
  102. // AS_USE_NAMESPACE
  103. // Adds the AngelScript namespace on the declarations.
  104. // AS_NO_MEMORY_H
  105. // Some compilers don't come with the memory.h header file.
  106. //
  107. // How to identify different compilers
  108. //-----------------------------------------
  109. // MS Visual C++
  110. // _MSC_VER is defined
  111. // __MWERKS__ is not defined
  112. // Metrowerks
  113. // _MSC_VER is defined
  114. // __MWERKS__ is defined
  115. // GNU C based compilers
  116. // __GNUC__ is defined
  117. // Embarcadero C++Builder
  118. // __BORLANDC__ is defined
  119. //
  120. // CPU differences
  121. //---------------------------------------
  122. // AS_USE_DOUBLE_AS_FLOAT
  123. // If there is no 64 bit floating point type, then this constant can be defined
  124. // to treat double like normal floats.
  125. // AS_X86
  126. // Use assembler code for the x86 CPU family
  127. // AS_SH4
  128. // Use assembler code for the SH4 CPU family
  129. // AS_MIPS
  130. // Use assembler code for the MIPS CPU family
  131. // AS_PPC
  132. // Use assembler code for the 32bit PowerPC CPU family
  133. // AS_PPC_64
  134. // Use assembler code for the 64bit PowerPC CPU family
  135. // AS_XENON
  136. // Use assembler code for the Xenon (XBOX360) CPU family
  137. // AS_ARM
  138. // Use assembler code for the ARM CPU family
  139. // AS_SOFTFP
  140. // Use to tell compiler that ARM soft-float ABI
  141. // should be used instead of ARM hard-float ABI
  142. // AS_X64_GCC
  143. // Use GCC assembler code for the X64 AMD/Intel CPU family
  144. // AS_X64_MSVC
  145. // Use MSVC assembler code for the X64 AMD/Intel CPU family
  146. // AS_64BIT_PTR
  147. // Define this to make the engine store all pointers in 64bit words.
  148. // AS_BIG_ENDIAN
  149. // Define this for CPUs that use big endian memory layout, e.g. PPC
  150. //
  151. // Target systems
  152. //--------------------------------
  153. // This group shows a few of the flags used to identify different target systems.
  154. // Sometimes there are differences on different target systems, while both CPU and
  155. // compiler is the same for both, when this is so these flags are used to produce the
  156. // right code.
  157. // AS_WIN - Microsoft Windows
  158. // AS_LINUX - Linux
  159. // AS_MAC - Apple Macintosh
  160. // AS_BSD - BSD based OS (FreeBSD, DragonFly, OpenBSD, etc)
  161. // AS_XBOX - Microsoft XBox
  162. // AS_XBOX360 - Microsoft XBox 360
  163. // AS_PSP - Sony Playstation Portable
  164. // AS_PS2 - Sony Playstation 2
  165. // AS_PS3 - Sony Playstation 3
  166. // AS_DC - Sega Dreamcast
  167. // AS_GC - Nintendo GameCube
  168. // AS_WII - Nintendo Wii
  169. // AS_WIIU - Nintendo Wii U
  170. // AS_IPHONE - Apple IPhone
  171. // AS_ANDROID - Android
  172. // AS_HAIKU - Haiku
  173. // AS_ILLUMOS - Illumos like (OpenSolaris, OpenIndiana, NCP, etc)
  174. // AS_MARMALADE - Marmalade cross platform SDK (a layer on top of the OS)
  175. //
  176. // Calling conventions
  177. //-----------------------------------------
  178. // GNU_STYLE_VIRTUAL_METHOD
  179. // This constant should be defined if method pointers store index for virtual
  180. // functions in the same location as the function pointer. In such cases the method
  181. // is identified as virtual if the least significant bit is set.
  182. // MULTI_BASE_OFFSET(x)
  183. // This macro is used to retrieve the offset added to the object pointer in order to
  184. // implicitly cast the object to the base object. x is the method pointer received by
  185. // the register function.
  186. // HAVE_VIRTUAL_BASE_OFFSET
  187. // Define this constant if the compiler stores the virtual base offset in the method
  188. // pointers. If it is not stored in the pointers then AngelScript have no way of
  189. // identifying a method as coming from a class with virtual inheritance.
  190. // VIRTUAL_BASE_OFFSET(x)
  191. // This macro is used to retrieve the offset added to the object pointer in order to
  192. // find the virtual base object. x is the method pointer received by the register
  193. // function;
  194. // COMPLEX_RETURN_MASK
  195. // This constant shows what attributes determine if an object is returned in memory
  196. // or in the registers as normal structures
  197. // COMPLEX_MASK
  198. // This constant shows what attributes determine if an object is implicitly passed
  199. // by reference or not, even if the argument is declared by value
  200. // THISCALL_RETURN_SIMPLE_IN_MEMORY
  201. // CDECL_RETURN_SIMPLE_IN_MEMORY
  202. // STDCALL_RETURN_SIMPLE_IN_MEMORY
  203. // When these constants are defined then the corresponding calling convention always
  204. // return classes/structs in memory regardless of size or complexity.
  205. // THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  206. // STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  207. // CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  208. // Specifies the minimum size in dwords a class/struct needs to be to be passed in memory
  209. // CALLEE_POPS_HIDDEN_RETURN_POINTER
  210. // This constant should be defined if the callee pops the hidden return pointer,
  211. // used when returning an object in memory.
  212. // THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
  213. // This constant should be defined if the callee pops the hidden return pointer
  214. // for thiscall functions; used when returning an object in memory.
  215. // THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  216. // With this constant defined AngelScript will pass the object pointer on the stack
  217. // THISCALL_CALLEE_POPS_ARGUMENTS
  218. // If the callee pops arguments for class methods then define this constant
  219. // COMPLEX_OBJS_PASSED_BY_REF
  220. // Some compilers always pass certain objects by reference. GNUC for example does
  221. // this if the the class has a defined destructor.
  222. // AS_LARGE_OBJS_PASSED_BY_REF
  223. // If this is defined large objects are passed by reference, whether they are complex or not
  224. // AS_LARGE_OBJ_MIN_SIZE
  225. // This is the size of objects determined as large ones
  226. // AS_CALLEE_DESTROY_OBJ_BY_VAL
  227. // When an object is passed by value the called function is the one responsible
  228. // for calling the destructor before returning.
  229. // HAS_128_BIT_PRIMITIVES
  230. // 64bit processors often support 128bit primitives. These may require special
  231. // treatment when passed in function arguments or returned by functions.
  232. // SPLIT_OBJS_BY_MEMBER_TYPES
  233. // On some platforms objects with primitive members are split over different
  234. // register types when passed by value to functions.
  235. //
  236. // Detect compiler
  237. //------------------------------------------------
  238. #define VALUE_OF_BOOLEAN_TRUE 1
  239. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  240. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  241. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  242. #define THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
  243. // Embarcadero C++Builder
  244. #if defined(__BORLANDC__)
  245. #ifndef _Windows
  246. #error "Configuration doesn't yet support BCC for Linux or Mac OS."
  247. #endif
  248. #if defined(_M_X64)
  249. #error "Configuration doesn't yet support BCC for AMD64."
  250. #endif
  251. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  252. #define HAVE_VIRTUAL_BASE_OFFSET
  253. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+2))
  254. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  255. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  256. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  257. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  258. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  259. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  260. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  261. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  262. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  263. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  264. #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR)
  265. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR)
  266. #define STDCALL __stdcall
  267. #define AS_SIZEOF_BOOL 1
  268. #define AS_WINDOWS_THREADS
  269. #undef THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
  270. #define AS_WIN
  271. #define AS_X86
  272. #define ASM_INTEL
  273. #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
  274. #define fmodf(a,b) fmod(a,b)
  275. #define UNREACHABLE_RETURN
  276. #endif
  277. // Microsoft Visual C++
  278. // Ref: http://msdn.microsoft.com/en-us/library/b0084kay.aspx
  279. #if defined(_MSC_VER) && !defined(__MWERKS__)
  280. #if _MSC_VER <= 1200 // MSVC6
  281. // Disable the useless warnings about truncated symbol names for template instances
  282. #pragma warning( disable : 4786 )
  283. #endif
  284. #ifdef _M_X64
  285. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+2))
  286. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+4))
  287. #else
  288. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  289. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+3))
  290. #endif
  291. #define HAVE_VIRTUAL_BASE_OFFSET
  292. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  293. #define THISCALL_PASS_OBJECT_POINTER_IN_ECX
  294. // http://www.madewithmarmalade.com/
  295. #if defined(__S3E__)
  296. #ifndef AS_MARMALADE
  297. // From now on we'll use the below define
  298. #define AS_MARMALADE
  299. #endif
  300. // Marmalade doesn't use the Windows libraries
  301. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  302. // Marmalade doesn't seem to have proper support for
  303. // atomic instructions or read/write locks, so we turn off
  304. // multithread support
  305. //#define AS_POSIX_THREADS
  306. #define AS_NO_THREADS
  307. #define AS_NO_ATOMIC
  308. // Marmalade has it's own way of identifying the CPU target
  309. // Note, when building for ARM, the gnuc compiler will always
  310. // be used so we don't need to check for it here
  311. #if defined(I3D_ARCH_X86)
  312. #define AS_X86
  313. #endif
  314. #else
  315. #if _MSC_VER < 1500 // MSVC++ 9 (aka MSVC++ .NET 2008)
  316. #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
  317. #else
  318. #define asVSNPRINTF(a, b, c, d) vsnprintf_s(a, b, _TRUNCATE, c, d)
  319. #endif
  320. #define AS_WINDOWS_THREADS
  321. #endif
  322. #define THISCALL_CALLEE_POPS_ARGUMENTS
  323. #define STDCALL __stdcall
  324. #define AS_SIZEOF_BOOL 1
  325. #define ASM_INTEL // Intel style for inline assembly on microsoft compilers
  326. #if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
  327. #define AS_WIN
  328. #endif
  329. #if _XBOX_VER >= 200
  330. // 360 uses a Xenon processor (which is a modified 64bit PPC)
  331. #define AS_XBOX360
  332. #define AS_XENON
  333. #define AS_BIG_ENDIAN
  334. #else
  335. #if defined(_XBOX) || (defined(_M_IX86) && !defined(__LP64__))
  336. #define AS_X86
  337. #elif defined(_M_X64)
  338. #define AS_X64_MSVC
  339. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  340. #define AS_LARGE_OBJS_PASSED_BY_REF
  341. #define AS_LARGE_OBJ_MIN_SIZE 3
  342. #define COMPLEX_OBJS_PASSED_BY_REF
  343. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  344. #define COMPLEX_MASK (asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  345. #endif
  346. #endif
  347. #if defined(_ARM_) || defined(_M_ARM)
  348. #define AS_ARM
  349. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  350. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  351. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  352. #define COMPLEX_OBJS_PASSED_BY_REF
  353. #define COMPLEX_MASK asOBJ_APP_CLASS_ASSIGNMENT
  354. #define COMPLEX_RETURN_MASK asOBJ_APP_CLASS_ASSIGNMENT
  355. #define AS_SOFTFP
  356. #endif
  357. #ifndef COMPLEX_MASK
  358. #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  359. #endif
  360. #ifndef COMPLEX_RETURN_MASK
  361. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  362. #endif
  363. #define UNREACHABLE_RETURN
  364. #endif
  365. // Metrowerks CodeWarrior (experimental, let me know if something isn't working)
  366. #if defined(__MWERKS__) && !defined(EPPC) // JWC -- If Wii DO NOT use this even when using Metrowerks Compiler. Even though they are called Freescale...
  367. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  368. #define HAVE_VIRTUAL_BASE_OFFSET
  369. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+3))
  370. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  371. #define THISCALL_PASS_OBJECT_POINTER_IN_ECX
  372. #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
  373. #define THISCALL_CALLEE_POPS_ARGUMENTS
  374. #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  375. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  376. #define AS_SIZEOF_BOOL 1
  377. #define AS_WINDOWS_THREADS
  378. #define STDCALL __stdcall
  379. // Support native calling conventions on x86, but not 64bit yet
  380. #if defined(_M_IX86) && !defined(__LP64__)
  381. #define AS_X86
  382. #define ASM_INTEL // Intel style for inline assembly
  383. #endif
  384. #define UNREACHABLE_RETURN
  385. #endif
  386. // SN Systems ProDG
  387. #if defined(__SNC__) || defined(SNSYS)
  388. #define GNU_STYLE_VIRTUAL_METHOD
  389. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  390. #define CALLEE_POPS_HIDDEN_RETURN_POINTER
  391. #define COMPLEX_OBJS_PASSED_BY_REF
  392. #define ASM_AT_N_T // AT&T style inline assembly
  393. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  394. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  395. #define AS_SIZEOF_BOOL 1
  396. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  397. // SN doesnt seem to like STDCALL.
  398. // Maybe it can work with some fiddling, but I can't imagine linking to
  399. // any STDCALL functions with a console anyway...
  400. #define STDCALL
  401. // Linux specific
  402. #ifdef __linux__
  403. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  404. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  405. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  406. #endif
  407. // Support native calling conventions on x86, but not 64bit yet
  408. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  409. #define AS_X86
  410. // PS3
  411. #elif (defined(__PPC__) || defined(__ppc__)) && defined(__PPU__)
  412. // Support native calling conventions on PS3
  413. #define AS_PS3
  414. #define AS_PPC_64
  415. // PSP
  416. #elif defined(__psp__)
  417. #define AS_NO_MEMORY_H
  418. #define AS_MIPS
  419. #define AS_PSP
  420. #endif
  421. #define UNREACHABLE_RETURN
  422. #endif
  423. // GNU C (and MinGW or Cygwin on Windows)
  424. // Use the following command to determine predefined macros: echo . | g++ -dM -E -
  425. #if (defined(__GNUC__) && !defined(__SNC__)) || defined(EPPC) || defined(__CYGWIN__) // JWC -- use this instead for Wii
  426. #define GNU_STYLE_VIRTUAL_METHOD
  427. #if !defined( __amd64__ )
  428. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  429. #else
  430. #define MULTI_BASE_OFFSET(x) (*((asQWORD*)(&x)+1))
  431. #endif
  432. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  433. #define CALLEE_POPS_HIDDEN_RETURN_POINTER
  434. #define COMPLEX_OBJS_PASSED_BY_REF
  435. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  436. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  437. #define AS_NO_MEMORY_H
  438. #define AS_SIZEOF_BOOL 1
  439. #define STDCALL __attribute__((stdcall))
  440. #define ASM_AT_N_T
  441. // WII U
  442. #if defined(__ghs__)
  443. #define AS_WIIU
  444. // Native calling conventions are not yet supported
  445. #define AS_MAX_PORTABILITY
  446. // Marmalade is a cross platform SDK. It uses g++ to compile for iOS and Android
  447. #elif defined(__S3E__)
  448. #ifndef AS_MARMALADE
  449. // From now on we'll use the below define
  450. #define AS_MARMALADE
  451. #endif
  452. // STDCALL is not available on Marmalade when compiled for iOS or Android
  453. #undef STDCALL
  454. #define STDCALL
  455. // Marmalade doesn't seem to have proper support for
  456. // atomic instructions or read/write locks
  457. #define AS_NO_THREADS
  458. #define AS_NO_ATOMIC
  459. // Identify for which CPU the library is being built
  460. #if defined(I3D_ARCH_X86)
  461. #define AS_X86
  462. #elif defined(I3D_ARCH_ARM)
  463. #define AS_ARM
  464. #define AS_SOFTFP
  465. // Marmalade appear to use the same ABI as Android when built for ARM
  466. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  467. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  468. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  469. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  470. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  471. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  472. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  473. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  474. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  475. #undef GNU_STYLE_VIRTUAL_METHOD
  476. #undef COMPLEX_MASK
  477. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  478. #undef COMPLEX_RETURN_MASK
  479. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  480. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  481. #endif
  482. // MacOSX and IPhone
  483. #elif defined(__APPLE__)
  484. #include <TargetConditionals.h>
  485. // Is this a Mac or an IPhone (or other iOS device)?
  486. #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1
  487. #define AS_IPHONE
  488. #else
  489. #define AS_MAC
  490. #endif
  491. // The sizeof bool is different depending on the target CPU
  492. #undef AS_SIZEOF_BOOL
  493. #if defined(__ppc__)
  494. #define AS_SIZEOF_BOOL 4
  495. // STDCALL is not available on PPC
  496. #undef STDCALL
  497. #define STDCALL
  498. #else
  499. #define AS_SIZEOF_BOOL 1
  500. #endif
  501. #if (defined(_ARM_) || defined(__arm__))
  502. // iOS use ARM processor
  503. #define AS_ARM
  504. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  505. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  506. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  507. #undef GNU_STYLE_VIRTUAL_METHOD
  508. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  509. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  510. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  511. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  512. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  513. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  514. #define COMPLEX_OBJS_PASSED_BY_REF
  515. #undef COMPLEX_MASK
  516. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  517. #undef COMPLEX_RETURN_MASK
  518. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  519. // iOS uses soft-float ABI
  520. #define AS_SOFTFP
  521. // STDCALL is not available on ARM
  522. #undef STDCALL
  523. #define STDCALL
  524. #elif (defined(__arm64__))
  525. // The IPhone 5S+ uses an ARM64 processor
  526. // AngelScript currently doesn't support native calling
  527. // for 64bit ARM processors so it's necessary to turn on
  528. // portability mode
  529. #define AS_MAX_PORTABILITY
  530. // STDCALL is not available on ARM
  531. #undef STDCALL
  532. #define STDCALL
  533. #elif (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  534. // Support native calling conventions on Mac OS X + Intel 32bit CPU
  535. #define AS_X86
  536. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  537. #undef COMPLEX_MASK
  538. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  539. #undef COMPLEX_RETURN_MASK
  540. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  541. #elif defined(__LP64__) && !defined(__ppc__) && !defined(__PPC__) && !defined(__arm64__)
  542. // 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
  543. #define AS_X64_GCC
  544. #define HAS_128_BIT_PRIMITIVES
  545. #define SPLIT_OBJS_BY_MEMBER_TYPES
  546. #undef COMPLEX_MASK
  547. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  548. #undef COMPLEX_RETURN_MASK
  549. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  550. #define AS_LARGE_OBJS_PASSED_BY_REF
  551. #define AS_LARGE_OBJ_MIN_SIZE 5
  552. // STDCALL is not available on 64bit Mac
  553. #undef STDCALL
  554. #define STDCALL
  555. #elif (defined(__ppc__) || defined(__PPC__)) && !defined(__LP64__)
  556. // Support native calling conventions on Mac OS X + PPC 32bit CPU
  557. #define AS_PPC
  558. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  559. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  560. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  561. #undef COMPLEX_MASK
  562. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  563. #undef COMPLEX_RETURN_MASK
  564. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  565. #elif (defined(__ppc__) || defined(__PPC__)) && defined(__LP64__)
  566. #define AS_PPC_64
  567. #else
  568. // Unknown CPU type
  569. #define AS_MAX_PORTABILITY
  570. #endif
  571. #define AS_POSIX_THREADS
  572. // Windows
  573. #elif defined(WIN32) || defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
  574. // On Windows the simple classes are returned in the EAX:EDX registers
  575. //#define THISCALL_RETURN_SIMPLE_IN_MEMORY
  576. //#define CDECL_RETURN_SIMPLE_IN_MEMORY
  577. //#define STDCALL_RETURN_SIMPLE_IN_MEMORY
  578. #undef COMPLEX_MASK
  579. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  580. #undef COMPLEX_RETURN_MASK
  581. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  582. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  583. // Support native calling conventions on Intel 32bit CPU
  584. #define AS_X86
  585. // As of version 4.7 MinGW changed the ABI, presumably
  586. // to be better aligned with how MSVC works
  587. #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || __GNUC__ > 4
  588. #undef CALLEE_POPS_HIDDEN_RETURN_POINTER
  589. #define THISCALL_CALLEE_POPS_ARGUMENTS
  590. #else
  591. // Earlier versions than 4.7
  592. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  593. #endif
  594. #elif defined(__x86_64__)
  595. #define AS_X64_MINGW
  596. #define AS_LARGE_OBJS_PASSED_BY_REF
  597. #define AS_LARGE_OBJ_MIN_SIZE 3
  598. #define COMPLEX_OBJS_PASSED_BY_REF
  599. #else
  600. #define AS_MAX_PORTABILITY
  601. #endif
  602. #define AS_WIN
  603. #define AS_WINDOWS_THREADS
  604. // Linux
  605. #elif defined(__linux__) && !defined(ANDROID) && !defined(__ANDROID__)
  606. #undef COMPLEX_MASK
  607. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  608. #undef COMPLEX_RETURN_MASK
  609. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  610. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  611. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  612. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  613. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  614. // Support native calling conventions on Intel 32bit CPU
  615. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  616. #define AS_X86
  617. #elif defined(__LP64__) && !defined(__arm64__)
  618. #define AS_X64_GCC
  619. #define HAS_128_BIT_PRIMITIVES
  620. #define SPLIT_OBJS_BY_MEMBER_TYPES
  621. #define AS_LARGE_OBJS_PASSED_BY_REF
  622. #define AS_LARGE_OBJ_MIN_SIZE 5
  623. // STDCALL is not available on 64bit Linux
  624. #undef STDCALL
  625. #define STDCALL
  626. #elif defined(__ARMEL__) || defined(__arm__)
  627. #define AS_ARM
  628. #undef STDCALL
  629. #define STDCALL
  630. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  631. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  632. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  633. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  634. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  635. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  636. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  637. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  638. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  639. #ifndef AS_MAX_PORTABILITY
  640. // Make a few checks against incompatible ABI combinations
  641. #if defined(__FAST_MATH__) && __FAST_MATH__ == 1
  642. #error -ffast-math is not supported with native calling conventions
  643. #endif
  644. #endif
  645. // Verify if soft-float or hard-float ABI is used
  646. #if defined(__SOFTFP__) && __SOFTFP__ == 1
  647. // -ffloat-abi=softfp or -ffloat-abi=soft
  648. #define AS_SOFTFP
  649. #endif
  650. #elif defined(__mips__)
  651. #define AS_MIPS
  652. #define AS_BIG_ENDIAN
  653. #define AS_USE_DOUBLE_AS_FLOAT
  654. // Native calling conventions for Linux/Mips do not work yet.
  655. #define AS_MAX_PORTABILITY
  656. #else
  657. #define AS_MAX_PORTABILITY
  658. #endif
  659. #define AS_LINUX
  660. #define AS_POSIX_THREADS
  661. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  662. // Only with GCC 4.1 was the atomic instructions available
  663. #define AS_NO_ATOMIC
  664. #endif
  665. // Free BSD
  666. #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
  667. #define AS_BSD
  668. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  669. #undef COMPLEX_MASK
  670. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  671. #undef COMPLEX_RETURN_MASK
  672. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  673. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  674. #define AS_X86
  675. #elif defined(__LP64__)
  676. #define AS_X64_GCC
  677. #define HAS_128_BIT_PRIMITIVES
  678. #define SPLIT_OBJS_BY_MEMBER_TYPES
  679. #undef COMPLEX_MASK
  680. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  681. #undef COMPLEX_RETURN_MASK
  682. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  683. #define AS_LARGE_OBJS_PASSED_BY_REF
  684. #define AS_LARGE_OBJ_MIN_SIZE 5
  685. #undef STDCALL
  686. #define STDCALL
  687. #else
  688. #define AS_MAX_PORTABILITY
  689. #endif
  690. #define AS_POSIX_THREADS
  691. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  692. // Only with GCC 4.1 was the atomic instructions available
  693. #define AS_NO_ATOMIC
  694. #endif
  695. // PSP and PS2
  696. #elif defined(__PSP__) || defined(__psp__) || defined(_EE_) || defined(_PSP) || defined(_PS2)
  697. // Support native calling conventions on MIPS architecture
  698. #if (defined(_MIPS_ARCH) || defined(_mips) || defined(__MIPSEL__)) && !defined(__LP64__)
  699. #define AS_MIPS
  700. #else
  701. #define AS_MAX_PORTABILITY
  702. #endif
  703. // PS3
  704. #elif (defined(__PPC__) || defined(__ppc__)) && defined(__PPU__)
  705. // Support native calling conventions on PS3
  706. #define AS_PS3
  707. #define AS_PPC_64
  708. #define SPLIT_OBJS_BY_MEMBER_TYPES
  709. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  710. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  711. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  712. // PS3 doesn't have STDCALL
  713. #undef STDCALL
  714. #define STDCALL
  715. // Dreamcast
  716. #elif __SH4_SINGLE_ONLY__
  717. // Support native calling conventions on Dreamcast
  718. #define AS_DC
  719. #define AS_SH4
  720. // Wii JWC - Close to PS3 just no PPC_64 and AS_PS3
  721. #elif defined(EPPC)
  722. #define AS_WII
  723. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  724. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  725. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  726. #undef STDCALL
  727. #define STDCALL
  728. // Android
  729. #elif defined(ANDROID) || defined(__ANDROID__)
  730. #define AS_ANDROID
  731. // Android NDK 9+ supports posix threads
  732. #define AS_POSIX_THREADS
  733. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  734. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  735. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  736. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  737. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  738. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  739. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  740. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  741. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  742. #if (defined(_ARM_) || defined(__arm__))
  743. // The stdcall calling convention is not used on the arm cpu
  744. #undef STDCALL
  745. #define STDCALL
  746. #undef GNU_STYLE_VIRTUAL_METHOD
  747. #undef COMPLEX_MASK
  748. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  749. #undef COMPLEX_RETURN_MASK
  750. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  751. #define AS_ARM
  752. #define AS_SOFTFP
  753. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  754. #endif
  755. // Haiku OS
  756. #elif __HAIKU__
  757. #define AS_HAIKU
  758. // Only x86-32 is currently supported by Haiku, but they do plan to support
  759. // x86-64 and PowerPC in the future, so should go ahead and check the platform
  760. // for future compatibility
  761. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  762. #define AS_X86
  763. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  764. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  765. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  766. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  767. #else
  768. #define AS_MAX_PORTABILITY
  769. #endif
  770. #define AS_POSIX_THREADS
  771. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  772. // Only with GCC 4.1 was the atomic instructions available
  773. #define AS_NO_ATOMIC
  774. #endif
  775. // Illumos
  776. #elif defined(__sun)
  777. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  778. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  779. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  780. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  781. // Support native calling conventions on Intel 32bit CPU
  782. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  783. #define AS_X86
  784. #elif defined(__LP64__)
  785. #define AS_X64_GCC
  786. #define HAS_128_BIT_PRIMITIVES
  787. #define SPLIT_OBJS_BY_MEMBER_TYPES
  788. // STDCALL is not available on 64bit Linux
  789. #undef STDCALL
  790. #define STDCALL
  791. #else
  792. #define AS_MAX_PORTABILITY
  793. #endif
  794. #define AS_ILLUMOS
  795. #define AS_POSIX_THREADS
  796. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  797. // Only with GCC 4.1 was the atomic instructions available
  798. #define AS_NO_ATOMIC
  799. #endif
  800. #endif
  801. #define UNREACHABLE_RETURN
  802. #endif
  803. //
  804. // Detect target hardware
  805. //------------------------------------------------
  806. // X86, Intel, AMD, etc, i.e. most PCs
  807. #if defined(__i386__) || defined(_M_IX86)
  808. // Nothing special here
  809. #endif
  810. // MIPS architecture (generally PS2 and PSP consoles, potentially supports N64 as well)
  811. #if defined(_MIPS_ARCH) || defined(_mips) || defined(__MIPSEL__) || defined(__PSP__) || defined(__psp__) || defined(_EE_) || defined(_PSP) || defined(_PS2)
  812. #define AS_USE_DOUBLE_AS_FLOAT // use 32bit floats instead of doubles
  813. #endif
  814. // PowerPC, e.g. Mac, GameCube, PS3, XBox 360, Wii
  815. #if defined(__PPC__) || defined(__ppc__) || defined(_PPC_) || defined(EPPC)
  816. #define AS_BIG_ENDIAN
  817. // Gamecube
  818. #if defined(_GC)
  819. #define AS_USE_DOUBLE_AS_FLOAT
  820. #endif
  821. #endif
  822. // Dreamcast console
  823. #ifdef __SH4_SINGLE_ONLY__
  824. #define AS_USE_DOUBLE_AS_FLOAT // use 32bit floats instead of doubles
  825. #endif
  826. // If there are no current support for native calling
  827. // conventions, then compile with AS_MAX_PORTABILITY
  828. #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_X64_MINGW))
  829. #ifndef AS_MAX_PORTABILITY
  830. #define AS_MAX_PORTABILITY
  831. #endif
  832. #endif
  833. // If the platform doesn't support atomic instructions we can't allow
  834. // multithreading as the reference counters won't be threadsafe
  835. #if defined(AS_NO_ATOMIC) && !defined(AS_NO_THREADS)
  836. #define AS_NO_THREADS
  837. #endif
  838. // If the form of threads to use hasn't been chosen
  839. // then the library will be compiled without support
  840. // for multithreading
  841. #if !defined(AS_POSIX_THREADS) && !defined(AS_WINDOWS_THREADS)
  842. #define AS_NO_THREADS
  843. #endif
  844. // The assert macro
  845. #if defined(ANDROID)
  846. #if defined(AS_DEBUG)
  847. #include <android/log.h>
  848. #include <stdlib.h>
  849. #define asASSERT(x) \
  850. do { \
  851. if (!(x)) { \
  852. __android_log_print(ANDROID_LOG_ERROR, "AngelScript", "Assert failed at %s:%d - %s", __FILE__, __LINE__, #x); \
  853. exit(1); \
  854. } \
  855. } while (0)
  856. #else
  857. #define asASSERT(x)
  858. #endif
  859. #else
  860. #include <assert.h>
  861. #define asASSERT(x) assert(x)
  862. #endif
  863. //
  864. // Internal defines (do not change these)
  865. //----------------------------------------------------------------
  866. #define ARG_W(b) ((asWORD*)&b)
  867. #define ARG_DW(b) ((asDWORD*)&b)
  868. #define ARG_QW(b) ((asQWORD*)&b)
  869. #define ARG_PTR(b) ((asPWORD*)&b)
  870. #define BCARG_W(b) ((asWORD*)&(b)[1])
  871. #define BCARG_DW(b) ((asDWORD*)&(b)[1])
  872. #define BCARG_QW(b) ((asQWORD*)&(b)[1])
  873. #define BCARG_PTR(b) ((asPWORD*)&(b)[1])
  874. // This macro is used to avoid warnings about unused variables.
  875. // Usually where the variables are only used in debug mode.
  876. #define UNUSED_VAR(x) (void)(x)
  877. #include "../include/angelscript.h"
  878. #include "as_memory.h"
  879. #ifdef AS_USE_NAMESPACE
  880. using namespace AngelScript;
  881. #endif
  882. #endif