as_config.h 44 KB

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