as_config.h 38 KB

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