as_config.h 40 KB

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