as_config.h 44 KB

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