as_config.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. /*
  2. AngelCode Scripting Library
  3. Copyright (c) 2003-2013 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_X64_GCC
  140. // Use GCC assembler code for the X64 AMD/Intel CPU family
  141. // AS_X64_MSVC
  142. // Use MSVC assembler code for the X64 AMD/Intel CPU family
  143. // AS_64BIT_PTR
  144. // Define this to make the engine store all pointers in 64bit words.
  145. // AS_BIG_ENDIAN
  146. // Define this for CPUs that use big endian memory layout, e.g. PPC
  147. //
  148. // Target systems
  149. //--------------------------------
  150. // This group shows a few of the flags used to identify different target systems.
  151. // Sometimes there are differences on different target systems, while both CPU and
  152. // compiler is the same for both, when this is so these flags are used to produce the
  153. // right code.
  154. // AS_WIN - Microsoft Windows
  155. // AS_LINUX - Linux
  156. // AS_MAC - Apple Macintosh
  157. // AS_BSD - BSD based OS (FreeBSD, DragonFly, OpenBSD, etc)
  158. // AS_XBOX - Microsoft XBox
  159. // AS_XBOX360 - Microsoft XBox 360
  160. // AS_PSP - Sony Playstation Portable
  161. // AS_PS2 - Sony Playstation 2
  162. // AS_PS3 - Sony Playstation 3
  163. // AS_DC - Sega Dreamcast
  164. // AS_GC - Nintendo GameCube
  165. // AS_WII - Nintendo Wii
  166. // AS_WIIU - Nintendo Wii U
  167. // AS_IPHONE - Apple IPhone
  168. // AS_ANDROID - Android
  169. // AS_HAIKU - Haiku
  170. // AS_ILLUMOS - Illumos like (OpenSolaris, OpenIndiana, NCP, etc)
  171. // AS_MARMALADE - Marmalade cross platform SDK (a layer on top of the OS)
  172. //
  173. // Calling conventions
  174. //-----------------------------------------
  175. // GNU_STYLE_VIRTUAL_METHOD
  176. // This constant should be defined if method pointers store index for virtual
  177. // functions in the same location as the function pointer. In such cases the method
  178. // is identified as virtual if the least significant bit is set.
  179. // MULTI_BASE_OFFSET(x)
  180. // This macro is used to retrieve the offset added to the object pointer in order to
  181. // implicitly cast the object to the base object. x is the method pointer received by
  182. // the register function.
  183. // HAVE_VIRTUAL_BASE_OFFSET
  184. // Define this constant if the compiler stores the virtual base offset in the method
  185. // pointers. If it is not stored in the pointers then AngelScript have no way of
  186. // identifying a method as coming from a class with virtual inheritance.
  187. // VIRTUAL_BASE_OFFSET(x)
  188. // This macro is used to retrieve the offset added to the object pointer in order to
  189. // find the virtual base object. x is the method pointer received by the register
  190. // function;
  191. // COMPLEX_RETURN_MASK
  192. // This constant shows what attributes determine if an object is returned in memory
  193. // or in the registers as normal structures
  194. // COMPLEX_MASK
  195. // This constant shows what attributes determine if an object is implicitly passed
  196. // by reference or not, even if the argument is declared by value
  197. // THISCALL_RETURN_SIMPLE_IN_MEMORY
  198. // CDECL_RETURN_SIMPLE_IN_MEMORY
  199. // STDCALL_RETURN_SIMPLE_IN_MEMORY
  200. // When these constants are defined then the corresponding calling convention always
  201. // return classes/structs in memory regardless of size or complexity.
  202. // THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  203. // STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  204. // CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  205. // Specifies the minimum size in dwords a class/struct needs to be to be passed in memory
  206. // CALLEE_POPS_HIDDEN_RETURN_POINTER
  207. // This constant should be defined if the callee pops the hidden return pointer,
  208. // used when returning an object in memory.
  209. // THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
  210. // This constant should be defined if the callee pops the hidden return pointer
  211. // for thiscall functions; used when returning an object in memory.
  212. // THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  213. // With this constant defined AngelScript will pass the object pointer on the stack
  214. // THISCALL_CALLEE_POPS_ARGUMENTS
  215. // If the callee pops arguments for class methods then define this constant
  216. // COMPLEX_OBJS_PASSED_BY_REF
  217. // Some compilers always pass certain objects by reference. GNUC for example does
  218. // this if the the class has a defined destructor.
  219. // AS_LARGE_OBJS_PASSED_BY_REF
  220. // If this is defined large objects are passed by reference, whether they are complex or not
  221. // AS_LARGE_OBJ_MIN_SIZE
  222. // This is the size of objects determined as large ones
  223. // AS_CALLEE_DESTROY_OBJ_BY_VAL
  224. // When an object is passed by value the called function is the one responsible
  225. // for calling the destructor before returning.
  226. // HAS_128_BIT_PRIMITIVES
  227. // 64bit processors often support 128bit primitives. These may require special
  228. // treatment when passed in function arguments or returned by functions.
  229. // SPLIT_OBJS_BY_MEMBER_TYPES
  230. // On some platforms objects with primitive members are split over different
  231. // register types when passed by value to functions.
  232. //
  233. // Detect compiler
  234. //------------------------------------------------
  235. #define VALUE_OF_BOOLEAN_TRUE 1
  236. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  237. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  238. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  239. #define THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
  240. // Embarcadero C++Builder
  241. #if defined(__BORLANDC__)
  242. #ifndef _Windows
  243. #error "Configuration doesn't yet support BCC for Linux or Mac OS."
  244. #endif
  245. #if defined(_M_X64)
  246. #error "Configuration doesn't yet support BCC for AMD64."
  247. #endif
  248. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  249. #define HAVE_VIRTUAL_BASE_OFFSET
  250. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+2))
  251. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  252. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  253. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  254. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  255. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  256. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  257. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  258. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  259. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  260. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  261. #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR)
  262. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR)
  263. #define STDCALL __stdcall
  264. #define AS_SIZEOF_BOOL 1
  265. #define AS_WINDOWS_THREADS
  266. #undef THISCALL_CALLEE_POPS_HIDDEN_RETURN_POINTER
  267. #define AS_WIN
  268. #define AS_X86
  269. #define ASM_INTEL
  270. #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
  271. #define fmodf(a,b) fmod(a,b)
  272. #define UNREACHABLE_RETURN
  273. #endif
  274. // Microsoft Visual C++
  275. #if defined(_MSC_VER) && !defined(__MWERKS__)
  276. #if _MSC_VER <= 1200 // MSVC6
  277. // Disable the useless warnings about truncated symbol names for template instances
  278. #pragma warning( disable : 4786 )
  279. #endif
  280. #ifdef _M_X64
  281. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+2))
  282. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+4))
  283. #else
  284. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  285. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+3))
  286. #endif
  287. #define HAVE_VIRTUAL_BASE_OFFSET
  288. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  289. #define THISCALL_PASS_OBJECT_POINTER_IN_ECX
  290. // http://www.madewithmarmalade.com/
  291. #if defined(__S3E__)
  292. #ifndef AS_MARMALADE
  293. // From now on we'll use the below define
  294. #define AS_MARMALADE
  295. #endif
  296. // Marmalade doesn't use the Windows libraries
  297. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  298. // Marmalade doesn't seem to have proper support for
  299. // atomic instructions or read/write locks, so we turn off
  300. // multithread support
  301. //#define AS_POSIX_THREADS
  302. #define AS_NO_THREADS
  303. #define AS_NO_ATOMIC
  304. // Marmalade has it's own way of identifying the CPU target
  305. // Note, when building for ARM, the gnuc compiler will always
  306. // be used so we don't need to check for it here
  307. #if defined(I3D_ARCH_X86)
  308. #define AS_X86
  309. #endif
  310. #else
  311. #if _MSC_VER < 1500 // MSVC++ 9 (aka MSVC++ .NET 2008)
  312. #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
  313. #else
  314. #define asVSNPRINTF(a, b, c, d) vsnprintf_s(a, b, _TRUNCATE, c, d)
  315. #endif
  316. #define AS_WINDOWS_THREADS
  317. #endif
  318. #define THISCALL_CALLEE_POPS_ARGUMENTS
  319. #define STDCALL __stdcall
  320. #define AS_SIZEOF_BOOL 1
  321. #define ASM_INTEL // Intel style for inline assembly on microsoft compilers
  322. #if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
  323. #define AS_WIN
  324. #endif
  325. #if _XBOX_VER >= 200
  326. // 360 uses a Xenon processor (which is a modified 64bit PPC)
  327. #define AS_XBOX360
  328. #define AS_XENON
  329. #define AS_BIG_ENDIAN
  330. #else
  331. #if defined(_XBOX) || (defined(_M_IX86) && !defined(__LP64__))
  332. #define AS_X86
  333. #elif defined(_M_X64)
  334. #define AS_X64_MSVC
  335. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  336. #define AS_LARGE_OBJS_PASSED_BY_REF
  337. #define AS_LARGE_OBJ_MIN_SIZE 3
  338. #define COMPLEX_OBJS_PASSED_BY_REF
  339. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  340. #define COMPLEX_MASK (asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  341. #endif
  342. #endif
  343. #ifdef _ARM_
  344. #define AS_ARM
  345. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  346. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  347. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  348. #define COMPLEX_OBJS_PASSED_BY_REF
  349. #define COMPLEX_MASK asOBJ_APP_CLASS_ASSIGNMENT
  350. #define COMPLEX_RETURN_MASK asOBJ_APP_CLASS_ASSIGNMENT
  351. #endif
  352. #ifndef COMPLEX_MASK
  353. #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  354. #endif
  355. #ifndef COMPLEX_RETURN_MASK
  356. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  357. #endif
  358. #define UNREACHABLE_RETURN
  359. #endif
  360. // Metrowerks CodeWarrior (experimental, let me know if something isn't working)
  361. #if defined(__MWERKS__) && !defined(EPPC) // JWC -- If Wii DO NOT use this even when using Metrowerks Compiler. Even though they are called Freescale...
  362. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  363. #define HAVE_VIRTUAL_BASE_OFFSET
  364. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+3))
  365. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  366. #define THISCALL_PASS_OBJECT_POINTER_IN_ECX
  367. #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
  368. #define THISCALL_CALLEE_POPS_ARGUMENTS
  369. #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  370. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  371. #define AS_SIZEOF_BOOL 1
  372. #define AS_WINDOWS_THREADS
  373. #define STDCALL __stdcall
  374. // Support native calling conventions on x86, but not 64bit yet
  375. #if defined(_M_IX86) && !defined(__LP64__)
  376. #define AS_X86
  377. #define ASM_INTEL // Intel style for inline assembly
  378. #endif
  379. #define UNREACHABLE_RETURN
  380. #endif
  381. // SN Systems ProDG
  382. #if defined(__SNC__) || defined(SNSYS)
  383. #define GNU_STYLE_VIRTUAL_METHOD
  384. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  385. #define CALLEE_POPS_HIDDEN_RETURN_POINTER
  386. #define COMPLEX_OBJS_PASSED_BY_REF
  387. #define ASM_AT_N_T // AT&T style inline assembly
  388. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  389. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  390. #define AS_SIZEOF_BOOL 1
  391. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  392. // SN doesnt seem to like STDCALL.
  393. // Maybe it can work with some fiddling, but I can't imagine linking to
  394. // any STDCALL functions with a console anyway...
  395. #define STDCALL
  396. // Linux specific
  397. #ifdef __linux__
  398. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  399. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  400. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  401. #endif
  402. // Support native calling conventions on x86, but not 64bit yet
  403. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  404. #define AS_X86
  405. // PS3
  406. #elif (defined(__PPC__) || defined(__ppc__)) && defined(__PPU__)
  407. // Support native calling conventions on PS3
  408. #define AS_PS3
  409. #define AS_PPC_64
  410. // PSP
  411. #elif defined(__psp__)
  412. #define AS_NO_MEMORY_H
  413. #define AS_MIPS
  414. #define AS_PSP
  415. #endif
  416. #define UNREACHABLE_RETURN
  417. #endif
  418. // GNU C (and MinGW or Cygwin on Windows)
  419. // Use the following command to determine predefined macros: echo . | mingw32-g++ -dM -E -
  420. #if (defined(__GNUC__) && !defined(__SNC__)) || defined(EPPC) || defined(__CYGWIN__) // JWC -- use this instead for Wii
  421. #define GNU_STYLE_VIRTUAL_METHOD
  422. #if !defined( __amd64__ )
  423. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  424. #else
  425. #define MULTI_BASE_OFFSET(x) (*((asQWORD*)(&x)+1))
  426. #endif
  427. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  428. #define CALLEE_POPS_HIDDEN_RETURN_POINTER
  429. #define COMPLEX_OBJS_PASSED_BY_REF
  430. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  431. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  432. #define AS_NO_MEMORY_H
  433. #define AS_SIZEOF_BOOL 1
  434. #define STDCALL __attribute__((stdcall))
  435. #define ASM_AT_N_T
  436. // WII U
  437. #if defined(__ghs__)
  438. #define AS_WIIU
  439. // Native calling conventions are not yet supported
  440. #define AS_MAX_PORTABILITY
  441. // Marmalade is a cross platform SDK. It uses g++ to compile for iOS and Android
  442. #elif defined(__S3E__)
  443. #ifndef AS_MARMALADE
  444. // From now on we'll use the below define
  445. #define AS_MARMALADE
  446. #endif
  447. // STDCALL is not available on Marmalade when compiled for iOS or Android
  448. #undef STDCALL
  449. #define STDCALL
  450. // Marmalade doesn't seem to have proper support for
  451. // atomic instructions or read/write locks
  452. #define AS_NO_THREADS
  453. #define AS_NO_ATOMIC
  454. // Identify for which CPU the library is being built
  455. #if defined(I3D_ARCH_X86)
  456. #define AS_X86
  457. #elif defined(I3D_ARCH_ARM)
  458. #define AS_ARM
  459. // Marmalade appear to use the same ABI as Android when built for ARM
  460. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  461. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  462. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  463. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  464. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  465. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  466. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  467. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  468. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  469. #undef GNU_STYLE_VIRTUAL_METHOD
  470. #undef COMPLEX_MASK
  471. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  472. #undef COMPLEX_RETURN_MASK
  473. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  474. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  475. #endif
  476. // MacOSX and IPhone
  477. #elif defined(__APPLE__)
  478. #include <TargetConditionals.h>
  479. // Is this a Mac or an IPhone (or other iOS device)?
  480. #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1
  481. #define AS_IPHONE
  482. #else
  483. #define AS_MAC
  484. #endif
  485. // The sizeof bool is different depending on the target CPU
  486. #undef AS_SIZEOF_BOOL
  487. #if defined(__ppc__)
  488. #define AS_SIZEOF_BOOL 4
  489. // STDCALL is not available on PPC
  490. #undef STDCALL
  491. #define STDCALL
  492. #else
  493. #define AS_SIZEOF_BOOL 1
  494. #endif
  495. #if (defined(_ARM_) || defined(__arm__))
  496. // The IPhone use an ARM processor
  497. #define AS_ARM
  498. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  499. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  500. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  501. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  502. #undef GNU_STYLE_VIRTUAL_METHOD
  503. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  504. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  505. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  506. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  507. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  508. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  509. #define COMPLEX_OBJS_PASSED_BY_REF
  510. #undef COMPLEX_MASK
  511. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  512. #undef COMPLEX_RETURN_MASK
  513. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  514. // STDCALL is not available on ARM
  515. #undef STDCALL
  516. #define STDCALL
  517. #elif (defined(__arm64__))
  518. // The IPhone 5S+ uses an ARM64 processor
  519. // AngelScript currently doesn't support native calling
  520. // for 64bit ARM processors so it's necessary to turn on
  521. // portability mode
  522. #define AS_MAX_PORTABILITY
  523. // STDCALL is not available on ARM
  524. #undef STDCALL
  525. #define STDCALL
  526. #elif (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  527. // Support native calling conventions on Mac OS X + Intel 32bit CPU
  528. #define AS_X86
  529. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  530. #undef COMPLEX_MASK
  531. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  532. #undef COMPLEX_RETURN_MASK
  533. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  534. #elif defined(__LP64__) && !defined(__ppc__) && !defined(__PPC__) && !defined(__arm64__)
  535. // 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
  536. #define AS_X64_GCC
  537. #define HAS_128_BIT_PRIMITIVES
  538. #define SPLIT_OBJS_BY_MEMBER_TYPES
  539. #undef COMPLEX_MASK
  540. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  541. #undef COMPLEX_RETURN_MASK
  542. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  543. #define AS_LARGE_OBJS_PASSED_BY_REF
  544. #define AS_LARGE_OBJ_MIN_SIZE 5
  545. // STDCALL is not available on 64bit Mac
  546. #undef STDCALL
  547. #define STDCALL
  548. #elif (defined(__ppc__) || defined(__PPC__)) && !defined(__LP64__)
  549. // Support native calling conventions on Mac OS X + PPC 32bit CPU
  550. #define AS_PPC
  551. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  552. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  553. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  554. #undef COMPLEX_MASK
  555. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  556. #undef COMPLEX_RETURN_MASK
  557. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  558. #elif (defined(__ppc__) || defined(__PPC__)) && defined(__LP64__)
  559. #define AS_PPC_64
  560. #else
  561. // Unknown CPU type
  562. #define AS_MAX_PORTABILITY
  563. #endif
  564. #define AS_POSIX_THREADS
  565. // Windows
  566. #elif defined(WIN32) || defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
  567. // On Windows the simple classes are returned in the EAX:EDX registers
  568. //#define THISCALL_RETURN_SIMPLE_IN_MEMORY
  569. //#define CDECL_RETURN_SIMPLE_IN_MEMORY
  570. //#define STDCALL_RETURN_SIMPLE_IN_MEMORY
  571. #undef COMPLEX_MASK
  572. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  573. #undef COMPLEX_RETURN_MASK
  574. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  575. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  576. // Support native calling conventions on Intel 32bit CPU
  577. #define AS_X86
  578. // As of version 4.7 MinGW changed the ABI, presumably
  579. // to be better aligned with how MSVC works
  580. #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || __GNUC__ > 4
  581. #undef CALLEE_POPS_HIDDEN_RETURN_POINTER
  582. #define THISCALL_CALLEE_POPS_ARGUMENTS
  583. #else
  584. // Earlier versions than 4.7
  585. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  586. #endif
  587. #elif defined(__x86_64__)
  588. #define AS_X64_MINGW
  589. #define AS_LARGE_OBJS_PASSED_BY_REF
  590. #define AS_LARGE_OBJ_MIN_SIZE 3
  591. #define COMPLEX_OBJS_PASSED_BY_REF
  592. #else
  593. #define AS_MAX_PORTABILITY
  594. #endif
  595. #define AS_WIN
  596. #define AS_WINDOWS_THREADS
  597. // Linux
  598. #elif defined(__linux__) && !defined(ANDROID) && !defined(__ANDROID__)
  599. #undef COMPLEX_MASK
  600. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  601. #undef COMPLEX_RETURN_MASK
  602. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  603. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  604. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  605. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  606. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  607. // Support native calling conventions on Intel 32bit CPU
  608. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  609. #define AS_X86
  610. #elif defined(__LP64__) && !defined(__arm64__)
  611. #define AS_X64_GCC
  612. #define HAS_128_BIT_PRIMITIVES
  613. #define SPLIT_OBJS_BY_MEMBER_TYPES
  614. #define AS_LARGE_OBJS_PASSED_BY_REF
  615. #define AS_LARGE_OBJ_MIN_SIZE 5
  616. // STDCALL is not available on 64bit Linux
  617. #undef STDCALL
  618. #define STDCALL
  619. #elif defined(__ARMEL__) || defined(__arm__)
  620. #define AS_ARM
  621. #define AS_NO_ATOMIC
  622. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  623. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  624. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  625. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  626. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  627. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  628. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  629. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  630. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  631. #elif defined(__mips__)
  632. #define AS_MIPS
  633. #define AS_BIG_ENDIAN
  634. #define AS_USE_DOUBLE_AS_FLOAT
  635. // Native calling conventions for Linux/Mips do not work yet.
  636. #define AS_MAX_PORTABILITY
  637. #else
  638. #define AS_MAX_PORTABILITY
  639. #endif
  640. #define AS_LINUX
  641. #define AS_POSIX_THREADS
  642. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  643. // Only with GCC 4.1 was the atomic instructions available
  644. #define AS_NO_ATOMIC
  645. #endif
  646. // Free BSD
  647. #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
  648. #define AS_BSD
  649. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  650. #undef COMPLEX_MASK
  651. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  652. #undef COMPLEX_RETURN_MASK
  653. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  654. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  655. #define AS_X86
  656. #elif defined(__LP64__)
  657. #define AS_X64_GCC
  658. #define HAS_128_BIT_PRIMITIVES
  659. #define SPLIT_OBJS_BY_MEMBER_TYPES
  660. #undef COMPLEX_MASK
  661. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  662. #undef COMPLEX_RETURN_MASK
  663. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  664. #define AS_LARGE_OBJS_PASSED_BY_REF
  665. #define AS_LARGE_OBJ_MIN_SIZE 5
  666. #undef STDCALL
  667. #define STDCALL
  668. #else
  669. #define AS_MAX_PORTABILITY
  670. #endif
  671. #define AS_POSIX_THREADS
  672. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  673. // Only with GCC 4.1 was the atomic instructions available
  674. #define AS_NO_ATOMIC
  675. #endif
  676. // PSP and PS2
  677. #elif defined(__PSP__) || defined(__psp__) || defined(_EE_) || defined(_PSP) || defined(_PS2)
  678. // Support native calling conventions on MIPS architecture
  679. #if (defined(_MIPS_ARCH) || defined(_mips) || defined(__MIPSEL__)) && !defined(__LP64__)
  680. #define AS_MIPS
  681. #else
  682. #define AS_MAX_PORTABILITY
  683. #endif
  684. // PS3
  685. #elif (defined(__PPC__) || defined(__ppc__)) && defined(__PPU__)
  686. // Support native calling conventions on PS3
  687. #define AS_PS3
  688. #define AS_PPC_64
  689. #define SPLIT_OBJS_BY_MEMBER_TYPES
  690. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  691. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  692. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  693. // PS3 doesn't have STDCALL
  694. #undef STDCALL
  695. #define STDCALL
  696. // Dreamcast
  697. #elif __SH4_SINGLE_ONLY__
  698. // Support native calling conventions on Dreamcast
  699. #define AS_DC
  700. #define AS_SH4
  701. // Wii JWC - Close to PS3 just no PPC_64 and AS_PS3
  702. #elif defined(EPPC)
  703. #define AS_WII
  704. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  705. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  706. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  707. #undef STDCALL
  708. #define STDCALL
  709. // Android
  710. #elif defined(ANDROID) || defined(__ANDROID__)
  711. #define AS_ANDROID
  712. // Android NDK 9+ supports posix threads
  713. #define AS_POSIX_THREADS
  714. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  715. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  716. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  717. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  718. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  719. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  720. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  721. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  722. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  723. #if (defined(_ARM_) || defined(__arm__))
  724. // The stdcall calling convention is not used on the arm cpu
  725. #undef STDCALL
  726. #define STDCALL
  727. #undef GNU_STYLE_VIRTUAL_METHOD
  728. #undef COMPLEX_MASK
  729. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  730. #undef COMPLEX_RETURN_MASK
  731. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR)
  732. #define AS_ARM
  733. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  734. #endif
  735. // Haiku OS
  736. #elif __HAIKU__
  737. #define AS_HAIKU
  738. // Only x86-32 is currently supported by Haiku, but they do plan to support
  739. // x86-64 and PowerPC in the future, so should go ahead and check the platform
  740. // for future compatibility
  741. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  742. #define AS_X86
  743. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  744. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  745. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  746. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  747. #else
  748. #define AS_MAX_PORTABILITY
  749. #endif
  750. #define AS_POSIX_THREADS
  751. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  752. // Only with GCC 4.1 was the atomic instructions available
  753. #define AS_NO_ATOMIC
  754. #endif
  755. // Illumos
  756. #elif defined(__sun)
  757. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  758. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  759. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  760. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  761. // Support native calling conventions on Intel 32bit CPU
  762. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  763. #define AS_X86
  764. #elif defined(__LP64__)
  765. #define AS_X64_GCC
  766. #define HAS_128_BIT_PRIMITIVES
  767. #define SPLIT_OBJS_BY_MEMBER_TYPES
  768. // STDCALL is not available on 64bit Linux
  769. #undef STDCALL
  770. #define STDCALL
  771. #else
  772. #define AS_MAX_PORTABILITY
  773. #endif
  774. #define AS_ILLUMOS
  775. #define AS_POSIX_THREADS
  776. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  777. // Only with GCC 4.1 was the atomic instructions available
  778. #define AS_NO_ATOMIC
  779. #endif
  780. #endif
  781. #define UNREACHABLE_RETURN
  782. #endif
  783. //
  784. // Detect target hardware
  785. //------------------------------------------------
  786. // X86, Intel, AMD, etc, i.e. most PCs
  787. #if defined(__i386__) || defined(_M_IX86)
  788. // Nothing special here
  789. #endif
  790. // MIPS architecture (generally PS2 and PSP consoles, potentially supports N64 as well)
  791. #if defined(_MIPS_ARCH) || defined(_mips) || defined(__MIPSEL__) || defined(__PSP__) || defined(__psp__) || defined(_EE_) || defined(_PSP) || defined(_PS2)
  792. #define AS_USE_DOUBLE_AS_FLOAT // use 32bit floats instead of doubles
  793. #endif
  794. // PowerPC, e.g. Mac, GameCube, PS3, XBox 360, Wii
  795. #if defined(__PPC__) || defined(__ppc__) || defined(_PPC_) || defined(EPPC)
  796. #define AS_BIG_ENDIAN
  797. // Gamecube
  798. #if defined(_GC)
  799. #define AS_USE_DOUBLE_AS_FLOAT
  800. #endif
  801. #endif
  802. // Dreamcast console
  803. #ifdef __SH4_SINGLE_ONLY__
  804. #define AS_USE_DOUBLE_AS_FLOAT // use 32bit floats instead of doubles
  805. #endif
  806. // If there are no current support for native calling
  807. // conventions, then compile with AS_MAX_PORTABILITY
  808. #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))
  809. #ifndef AS_MAX_PORTABILITY
  810. #define AS_MAX_PORTABILITY
  811. #endif
  812. #endif
  813. // If the platform doesn't support atomic instructions we can't allow
  814. // multithreading as the reference counters won't be threadsafe
  815. #if defined(AS_NO_ATOMIC) && !defined(AS_NO_THREADS)
  816. #define AS_NO_THREADS
  817. #endif
  818. // If the form of threads to use hasn't been chosen
  819. // then the library will be compiled without support
  820. // for multithreading
  821. #if !defined(AS_POSIX_THREADS) && !defined(AS_WINDOWS_THREADS)
  822. #define AS_NO_THREADS
  823. #endif
  824. // The assert macro
  825. #if defined(ANDROID)
  826. #if defined(AS_DEBUG)
  827. #include <android/log.h>
  828. #include <stdlib.h>
  829. #define asASSERT(x) \
  830. do { \
  831. if (!(x)) { \
  832. __android_log_print(ANDROID_LOG_ERROR, "AngelScript", "Assert failed at %s:%d - %s", __FILE__, __LINE__, #x); \
  833. exit(1); \
  834. } \
  835. } while (0)
  836. #else
  837. #define asASSERT(x)
  838. #endif
  839. #else
  840. #include <assert.h>
  841. #define asASSERT(x) assert(x)
  842. #endif
  843. //
  844. // Internal defines (do not change these)
  845. //----------------------------------------------------------------
  846. #define ARG_W(b) ((asWORD*)&b)
  847. #define ARG_DW(b) ((asDWORD*)&b)
  848. #define ARG_QW(b) ((asQWORD*)&b)
  849. #define ARG_PTR(b) ((asPWORD*)&b)
  850. #define BCARG_W(b) ((asWORD*)&(b)[1])
  851. #define BCARG_DW(b) ((asDWORD*)&(b)[1])
  852. #define BCARG_QW(b) ((asQWORD*)&(b)[1])
  853. #define BCARG_PTR(b) ((asPWORD*)&(b)[1])
  854. // This macro is used to avoid warnings about unused variables.
  855. // Usually where the variables are only used in debug mode.
  856. #define UNUSED_VAR(x) (void)(x)
  857. #include "../include/angelscript.h"
  858. #include "as_memory.h"
  859. #ifdef AS_USE_NAMESPACE
  860. using namespace AngelScript;
  861. #endif
  862. #endif