as_config.h 42 KB

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