as_config.h 42 KB

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