as_config.h 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282
  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. #if (defined(__GNUC__) && !defined(__SNC__)) || defined(EPPC) || defined(__CYGWIN__) // JWC -- use this instead for Wii
  471. #define GNU_STYLE_VIRTUAL_METHOD
  472. #define MULTI_BASE_OFFSET(x) (*((asPWORD*)(&x)+1))
  473. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  474. #define CALLEE_POPS_HIDDEN_RETURN_POINTER
  475. #define COMPLEX_OBJS_PASSED_BY_REF
  476. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_ARRAY)
  477. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_ARRAY)
  478. #define AS_NO_MEMORY_H
  479. #define AS_SIZEOF_BOOL 1
  480. #define STDCALL __attribute__((stdcall))
  481. #define ASM_AT_N_T
  482. // WII U
  483. #if defined(__ghs__)
  484. #define AS_WIIU
  485. // Native calling conventions are not yet supported
  486. #define AS_MAX_PORTABILITY
  487. // Marmalade is a cross platform SDK. It uses g++ to compile for iOS and Android
  488. #elif defined(__S3E__)
  489. #ifndef AS_MARMALADE
  490. // From now on we'll use the below define
  491. #define AS_MARMALADE
  492. #endif
  493. // STDCALL is not available on Marmalade when compiled for iOS or Android
  494. #undef STDCALL
  495. #define STDCALL
  496. // Marmalade doesn't seem to have proper support for
  497. // atomic instructions or read/write locks
  498. #define AS_NO_THREADS
  499. #define AS_NO_ATOMIC
  500. // Identify for which CPU the library is being built
  501. #if defined(I3D_ARCH_X86)
  502. #define AS_X86
  503. #elif defined(I3D_ARCH_ARM)
  504. #define AS_ARM
  505. #define AS_SOFTFP
  506. // Marmalade appear to use the same ABI as Android when built for ARM
  507. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  508. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  509. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  510. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  511. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  512. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  513. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  514. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  515. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  516. #undef GNU_STYLE_VIRTUAL_METHOD
  517. #undef COMPLEX_MASK
  518. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  519. #undef COMPLEX_RETURN_MASK
  520. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  521. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  522. #endif
  523. // MacOSX and IPhone
  524. #elif defined(__APPLE__)
  525. #include <TargetConditionals.h>
  526. // Is this a Mac or an IPhone (or other iOS device)?
  527. #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1
  528. #define AS_IPHONE
  529. #else
  530. #define AS_MAC
  531. #endif
  532. // The sizeof bool is different depending on the target CPU
  533. #undef AS_SIZEOF_BOOL
  534. #if defined(__ppc__)
  535. #define AS_SIZEOF_BOOL 4
  536. // STDCALL is not available on PPC
  537. #undef STDCALL
  538. #define STDCALL
  539. #else
  540. #define AS_SIZEOF_BOOL 1
  541. #endif
  542. #if (defined(_ARM_) || defined(__arm__))
  543. // iOS use ARM processor
  544. #define AS_ARM
  545. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  546. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  547. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  548. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  549. #undef GNU_STYLE_VIRTUAL_METHOD
  550. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  551. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  552. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  553. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  554. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  555. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  556. #define COMPLEX_OBJS_PASSED_BY_REF
  557. #undef COMPLEX_MASK
  558. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  559. #undef COMPLEX_RETURN_MASK
  560. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  561. // iOS uses soft-float ABI
  562. #define AS_SOFTFP
  563. // STDCALL is not available on ARM
  564. #undef STDCALL
  565. #define STDCALL
  566. #elif (defined(__arm64__))
  567. // The IPhone 5S+ uses an ARM64 processor
  568. // AngelScript currently doesn't support native calling
  569. // for 64bit ARM processors so it's necessary to turn on
  570. // portability mode
  571. #define AS_MAX_PORTABILITY
  572. // STDCALL is not available on ARM
  573. #undef STDCALL
  574. #define STDCALL
  575. #elif (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  576. // Support native calling conventions on Mac OS X + Intel 32bit CPU
  577. #define AS_X86
  578. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  579. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  580. #undef COMPLEX_MASK
  581. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  582. #undef COMPLEX_RETURN_MASK
  583. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  584. #elif defined(__LP64__) && !defined(__ppc__) && !defined(__PPC__) && !defined(__arm64__)
  585. // 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
  586. #define AS_X64_GCC
  587. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  588. #define HAS_128_BIT_PRIMITIVES
  589. #define SPLIT_OBJS_BY_MEMBER_TYPES
  590. #undef COMPLEX_MASK
  591. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  592. #undef COMPLEX_RETURN_MASK
  593. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  594. #define AS_LARGE_OBJS_PASSED_BY_REF
  595. #define AS_LARGE_OBJ_MIN_SIZE 5
  596. // STDCALL is not available on 64bit Mac
  597. #undef STDCALL
  598. #define STDCALL
  599. #elif (defined(__ppc__) || defined(__PPC__)) && !defined(__LP64__)
  600. // Support native calling conventions on Mac OS X + PPC 32bit CPU
  601. #define AS_PPC
  602. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  603. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  604. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  605. #undef COMPLEX_MASK
  606. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  607. #undef COMPLEX_RETURN_MASK
  608. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  609. #elif (defined(__ppc__) || defined(__PPC__)) && defined(__LP64__)
  610. #define AS_PPC_64
  611. #else
  612. // Unknown CPU type
  613. #define AS_MAX_PORTABILITY
  614. #endif
  615. #define AS_POSIX_THREADS
  616. // Windows
  617. #elif defined(WIN32) || defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
  618. // On Windows the simple classes are returned in the EAX:EDX registers
  619. //#define THISCALL_RETURN_SIMPLE_IN_MEMORY
  620. //#define CDECL_RETURN_SIMPLE_IN_MEMORY
  621. //#define STDCALL_RETURN_SIMPLE_IN_MEMORY
  622. #undef COMPLEX_MASK
  623. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  624. #undef COMPLEX_RETURN_MASK
  625. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  626. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  627. // Support native calling conventions on Intel 32bit CPU
  628. #define AS_X86
  629. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  630. // As of version 4.7 MinGW changed the ABI, presumably
  631. // to be better aligned with how MSVC works
  632. // Urho3D: also check for Clang version and use the same workaround
  633. #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || __GNUC__ > 4
  634. #define AS_MINGW47
  635. #endif
  636. #if (__clang_major__ == 3 && __clang_minor__ > 4)
  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. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  665. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  666. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  667. // Support native calling conventions on Intel 32bit CPU
  668. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  669. #define AS_X86
  670. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  671. // Urho3D - use __aarch64__ instead of __arm64__ because GCC only emits the former
  672. #elif defined(__LP64__) && !defined(__aarch64__)
  673. #define AS_X64_GCC
  674. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  675. #define HAS_128_BIT_PRIMITIVES
  676. #define SPLIT_OBJS_BY_MEMBER_TYPES
  677. #define AS_LARGE_OBJS_PASSED_BY_REF
  678. #define AS_LARGE_OBJ_MIN_SIZE 5
  679. // STDCALL is not available on 64bit Linux
  680. #undef STDCALL
  681. #define STDCALL
  682. // Urho3D - Add support for aarch64-linux-gnu
  683. #elif defined(__aarch64__)
  684. // AngelScript currently doesn't support native calling
  685. // for 64bit ARM processors so it's necessary to turn on
  686. // portability mode
  687. #define AS_MAX_PORTABILITY
  688. // STDCALL is not available on ARM
  689. #undef STDCALL
  690. #define STDCALL
  691. #elif (defined(__ARMEL__) || defined(__arm__)) && !(defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__))
  692. #define AS_ARM
  693. // TODO: The stack unwind on exceptions currently fails due to the assembler code in as_callfunc_arm_gcc.S
  694. #define AS_NO_EXCEPTIONS
  695. #undef STDCALL
  696. #define STDCALL
  697. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  698. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  699. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  700. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  701. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  702. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  703. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  704. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  705. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  706. #ifndef AS_MAX_PORTABILITY
  707. // Make a few checks against incompatible ABI combinations
  708. #if defined(__FAST_MATH__) && __FAST_MATH__ == 1
  709. #error -ffast-math is not supported with native calling conventions
  710. #endif
  711. #endif
  712. // Verify if soft-float or hard-float ABI is used
  713. #if defined(__SOFTFP__) && __SOFTFP__ == 1
  714. // -ffloat-abi=softfp or -ffloat-abi=soft
  715. #define AS_SOFTFP
  716. #endif
  717. // Tested with both hard float and soft float abi
  718. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  719. #elif defined(__mips__)
  720. #define AS_MIPS
  721. #undef STDCALL
  722. #define STDCALL
  723. #ifdef _ABIO32
  724. #define AS_MIPS
  725. // All structures are returned in memory regardless of size or complexity
  726. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  727. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  728. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  729. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  730. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  731. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  732. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  733. #else
  734. // For other ABIs the native calling convention is not available (yet)
  735. #define AS_MAX_PORTABILITY
  736. #endif
  737. #else
  738. #define AS_MAX_PORTABILITY
  739. #endif
  740. #define AS_LINUX
  741. #define AS_POSIX_THREADS
  742. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  743. // Only with GCC 4.1 was the atomic instructions available
  744. #define AS_NO_ATOMIC
  745. #endif
  746. // Free BSD
  747. #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
  748. #define AS_BSD
  749. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  750. #undef COMPLEX_MASK
  751. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  752. #undef COMPLEX_RETURN_MASK
  753. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  754. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  755. #define AS_X86
  756. #elif defined(__LP64__)
  757. #define AS_X64_GCC
  758. #define HAS_128_BIT_PRIMITIVES
  759. #define SPLIT_OBJS_BY_MEMBER_TYPES
  760. #undef COMPLEX_MASK
  761. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  762. #undef COMPLEX_RETURN_MASK
  763. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  764. #define AS_LARGE_OBJS_PASSED_BY_REF
  765. #define AS_LARGE_OBJ_MIN_SIZE 5
  766. #undef STDCALL
  767. #define STDCALL
  768. #else
  769. #define AS_MAX_PORTABILITY
  770. #endif
  771. #define AS_POSIX_THREADS
  772. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  773. // Only with GCC 4.1 was the atomic instructions available
  774. #define AS_NO_ATOMIC
  775. #endif
  776. // PSP and PS2
  777. #elif defined(__PSP__) || defined(__psp__) || defined(_EE_) || defined(_PSP) || defined(_PS2)
  778. // Support native calling conventions on MIPS architecture
  779. #if (defined(_MIPS_ARCH) || defined(_mips) || defined(__MIPSEL__)) && !defined(__LP64__)
  780. #define AS_MIPS
  781. #define AS_USE_DOUBLE_AS_FLOAT
  782. #else
  783. #define AS_MAX_PORTABILITY
  784. #endif
  785. // PS3
  786. #elif (defined(__PPC__) || defined(__ppc__)) && defined(__PPU__)
  787. // Support native calling conventions on PS3
  788. #define AS_PS3
  789. #define AS_PPC_64
  790. #define SPLIT_OBJS_BY_MEMBER_TYPES
  791. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  792. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  793. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  794. // PS3 doesn't have STDCALL
  795. #undef STDCALL
  796. #define STDCALL
  797. // Dreamcast
  798. #elif __SH4_SINGLE_ONLY__
  799. // Support native calling conventions on Dreamcast
  800. #define AS_DC
  801. #define AS_SH4
  802. // Wii JWC - Close to PS3 just no PPC_64 and AS_PS3
  803. #elif defined(EPPC)
  804. #define AS_WII
  805. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  806. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  807. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  808. #undef STDCALL
  809. #define STDCALL
  810. // Android
  811. #elif defined(ANDROID) || defined(__ANDROID__)
  812. #define AS_ANDROID
  813. // Android 2.3+ supports posix threads
  814. #define AS_POSIX_THREADS
  815. // Common configuration with Android arm and x86
  816. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  817. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  818. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  819. #undef COMPLEX_MASK
  820. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  821. #undef COMPLEX_RETURN_MASK
  822. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  823. #if (defined(_ARM_) || defined(__arm__))
  824. // Android ARM
  825. // TODO: The stack unwind on exceptions currently fails due to the assembler code in as_callfunc_arm_gcc.S
  826. #define AS_NO_EXCEPTIONS
  827. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  828. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  829. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  830. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  831. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  832. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  833. // The stdcall calling convention is not used on the arm cpu
  834. #undef STDCALL
  835. #define STDCALL
  836. #undef GNU_STYLE_VIRTUAL_METHOD
  837. #define AS_ARM
  838. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  839. #define AS_SOFTFP
  840. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  841. #elif (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  842. // Android Intel x86 (same config as Linux x86). Tested with Intel x86 Atom System Image.
  843. // Support native calling conventions on Intel 32bit CPU
  844. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  845. #define AS_X86
  846. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  847. // Urho3D - Add support for Android Intel x86_64 and Android ARM 64bit
  848. #elif defined(__LP64__) && !defined(__aarch64__)
  849. // Android Intel x86_64 (same config as Linux x86_64). Tested with Intel x86_64 Atom System Image.
  850. #define AS_X64_GCC
  851. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  852. #define HAS_128_BIT_PRIMITIVES
  853. #define SPLIT_OBJS_BY_MEMBER_TYPES
  854. #define AS_LARGE_OBJS_PASSED_BY_REF
  855. #define AS_LARGE_OBJ_MIN_SIZE 5
  856. // STDCALL is not available on 64bit Linux
  857. #undef STDCALL
  858. #define STDCALL
  859. #elif defined(__aarch64__)
  860. // Doesn't support native calling for Android ARM 64bit yet
  861. #define AS_MAX_PORTABILITY
  862. // STDCALL is not available on ARM
  863. #undef STDCALL
  864. #define STDCALL
  865. #elif defined(__mips__)
  866. #define AS_MIPS
  867. #undef STDCALL
  868. #define STDCALL
  869. #ifdef _ABIO32
  870. #define AS_MIPS
  871. // All structures are returned in memory regardless of size or complexity
  872. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  873. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  874. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  875. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  876. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  877. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 0
  878. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  879. #else
  880. // For other ABIs the native calling convention is not available (yet)
  881. #define AS_MAX_PORTABILITY
  882. #endif
  883. #endif
  884. // Haiku OS
  885. #elif __HAIKU__
  886. #define AS_HAIKU
  887. // Only x86-32 is currently supported by Haiku, but they do plan to support
  888. // x86-64 and PowerPC in the future, so should go ahead and check the platform
  889. // for future compatibility
  890. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  891. #define AS_X86
  892. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  893. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  894. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  895. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  896. #else
  897. #define AS_MAX_PORTABILITY
  898. #endif
  899. #define AS_POSIX_THREADS
  900. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  901. // Only with GCC 4.1 was the atomic instructions available
  902. #define AS_NO_ATOMIC
  903. #endif
  904. // Illumos
  905. #elif defined(__sun)
  906. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  907. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  908. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  909. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  910. // Support native calling conventions on Intel 32bit CPU
  911. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  912. #define AS_X86
  913. #elif (defined(__x86_64__) || defined(__LP64__))
  914. #define AS_X64_GCC
  915. #define HAS_128_BIT_PRIMITIVES
  916. #define SPLIT_OBJS_BY_MEMBER_TYPES
  917. // STDCALL is not available on 64bit Linux
  918. #undef STDCALL
  919. #define STDCALL
  920. #else
  921. #define AS_MAX_PORTABILITY
  922. #endif
  923. #define AS_ILLUMOS
  924. #define AS_POSIX_THREADS
  925. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  926. // Only with GCC 4.1 was the atomic instructions available
  927. #define AS_NO_ATOMIC
  928. #endif
  929. #endif
  930. #define UNREACHABLE_RETURN
  931. #endif
  932. // Sun CC
  933. // Initial information provided by Andrey Bergman
  934. #if defined(__SUNPRO_CC)
  935. #if defined(__sparc)
  936. #define AS_SPARC
  937. #endif
  938. #if defined(__sun)
  939. #define AS_SUN
  940. #endif
  941. // Native calling conventions is not yet supported for Sun CC
  942. #if !defined(AS_MAX_PORTABILITY)
  943. #define AS_MAX_PORTABILITY
  944. #endif
  945. // I presume Sun CC uses a similar structure of method pointers as gnuc
  946. #define MULTI_BASE_OFFSET(x) (*((asPWORD*)(&x)+1))
  947. #if !defined(AS_SIZEOF_BOOL)
  948. #define AS_SIZEOF_BOOL 1 // sizeof(bool) == 1
  949. #endif
  950. #if !defined(UNREACHABLE_RETURN)
  951. #define UNREACHABLE_RETURN
  952. #endif
  953. #if !defined(STDCALL)
  954. #define STDCALL // There is no stdcall on Solaris/SunPro/SPARC
  955. #endif
  956. #if !defined(asVSNPRINTF)
  957. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  958. #endif
  959. #endif
  960. //
  961. // Detect target hardware
  962. //------------------------------------------------
  963. // X86, Intel, AMD, etc, i.e. most PCs
  964. #if defined(__i386__) || defined(_M_IX86)
  965. // Nothing special here
  966. #endif
  967. // PowerPC, e.g. Mac, GameCube, PS3, XBox 360, Wii
  968. #if defined(__PPC__) || defined(__ppc__) || defined(_PPC_) || defined(EPPC)
  969. #define AS_BIG_ENDIAN
  970. // Gamecube
  971. #if defined(_GC)
  972. #define AS_USE_DOUBLE_AS_FLOAT
  973. #endif
  974. #endif
  975. // Dreamcast console
  976. #ifdef __SH4_SINGLE_ONLY__
  977. #define AS_USE_DOUBLE_AS_FLOAT // use 32bit floats instead of doubles
  978. #endif
  979. // If there are no current support for native calling
  980. // conventions, then compile with AS_MAX_PORTABILITY
  981. #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))
  982. #ifndef AS_MAX_PORTABILITY
  983. #define AS_MAX_PORTABILITY
  984. #endif
  985. #endif
  986. // If the platform doesn't support atomic instructions we can't allow
  987. // multithreading as the reference counters won't be threadsafe
  988. #if defined(AS_NO_ATOMIC) && !defined(AS_NO_THREADS)
  989. #define AS_NO_THREADS
  990. #endif
  991. // If the form of threads to use hasn't been chosen
  992. // then the library will be compiled without support
  993. // for multithreading
  994. #if !defined(AS_POSIX_THREADS) && !defined(AS_WINDOWS_THREADS)
  995. #define AS_NO_THREADS
  996. #endif
  997. // The assert macro
  998. // Urho3D - use __ANDROID__ define emitted by all Android compiler toolchains
  999. #if defined(ANDROID) || defined(__ANDROID__)
  1000. #if defined(AS_DEBUG)
  1001. #include <android/log.h>
  1002. #include <stdlib.h>
  1003. #define asASSERT(x) \
  1004. do { \
  1005. if (!(x)) { \
  1006. __android_log_print(ANDROID_LOG_ERROR, "AngelScript", "Assert failed at %s:%d - %s", __FILE__, __LINE__, #x); \
  1007. exit(1); \
  1008. } \
  1009. } while (0)
  1010. #else
  1011. #define asASSERT(x)
  1012. #endif
  1013. #else
  1014. #include <assert.h>
  1015. #define asASSERT(x) assert(x)
  1016. #endif
  1017. //
  1018. // Internal defines (do not change these)
  1019. //----------------------------------------------------------------
  1020. #define ARG_W(b) ((asWORD*)&b)
  1021. #define ARG_DW(b) ((asDWORD*)&b)
  1022. #define ARG_QW(b) ((asQWORD*)&b)
  1023. #define ARG_PTR(b) ((asPWORD*)&b)
  1024. #define BCARG_W(b) ((asWORD*)&(b)[1])
  1025. #define BCARG_DW(b) ((asDWORD*)&(b)[1])
  1026. #define BCARG_QW(b) ((asQWORD*)&(b)[1])
  1027. #define BCARG_PTR(b) ((asPWORD*)&(b)[1])
  1028. // This macro is used to avoid warnings about unused variables.
  1029. // Usually where the variables are only used in debug mode.
  1030. #define UNUSED_VAR(x) (void)(x)
  1031. #include "../include/angelscript.h"
  1032. #include "as_memory.h"
  1033. #ifdef AS_USE_NAMESPACE
  1034. using namespace AngelScript;
  1035. #endif
  1036. #endif