as_config.h 42 KB

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