as_config.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  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. // Modified by Yao Wei Tjong for Urho3D
  24. //
  25. // as_config.h
  26. //
  27. // this file is used for configuring the compilation of the library
  28. //
  29. #ifndef AS_CONFIG_H
  30. #define AS_CONFIG_H
  31. //
  32. // Features
  33. //-----------------------------------------
  34. // AS_NO_THREADS
  35. // Turns off support for multithreading. By turning off
  36. // this when it's not needed a bit of performance is gained.
  37. // AS_WINDOWS_THREADS
  38. // If the library should be compiled using windows threads.
  39. // AS_POSIX_THREADS
  40. // If the library should be compiled using posix threads.
  41. // AS_NO_ATOMIC
  42. // If the compiler/platform doesn't support atomic instructions
  43. // then this should be defined to use critical sections instead.
  44. // AS_DEBUG
  45. // This flag can be defined to make the library write some extra output when
  46. // compiling and executing scripts.
  47. // AS_DEPRECATED
  48. // If this flag is defined then some backwards compatibility is maintained.
  49. // There is no guarantee for how well deprecated functionality will work though
  50. // so it is best to exchange it for the new functionality as soon as possible.
  51. // AS_NO_CLASS_METHODS
  52. // Disables the possibility to add class methods. Can increase the
  53. // portability of the library.
  54. // AS_MAX_PORTABILITY
  55. // Disables all platform specific code. Only the asCALL_GENERIC calling
  56. // convention will be available in with this flag set.
  57. // AS_DOUBLEBYTE_CHARSET
  58. // When this flag is defined, the parser will treat all characters in strings
  59. // that are greater than 127 as lead characters and automatically include the
  60. // next character in the script without checking its value. This should be
  61. // compatible with common encoding schemes, e.g. Big5. Shift-JIS is not compatible
  62. // though as it encodes some single byte characters above 127.
  63. //
  64. // If support for international text is desired, it is recommended that UTF-8
  65. // is used as this is supported natively by the compiler without the use for this
  66. // preprocessor flag.
  67. // AS_NO_COMPILER
  68. // Compiles the library without support for compiling scripts. This is intended
  69. // for those applications that will load pre-compiled bytecode and wants to decrease
  70. // the size of the executable.
  71. // AS_NO_EXCEPTIONS
  72. // Define this if exception handling is turned off or not available on the target platform.
  73. // AS_NO_MEMBER_INIT
  74. // Disable the support for initialization of class members directly in the declaration.
  75. // This was as a form to maintain backwards compatibility with versions before 2.26.0
  76. // if the new order of the member initialization caused null pointer exceptions in older
  77. // scripts (e.g. if a base class accessed members of a derived class through a virtual method).
  78. // AS_USE_NAMESPACE
  79. // Adds the AngelScript namespace on the declarations.
  80. //
  81. // Library usage
  82. //------------------------------------------
  83. // ANGELSCRIPT_EXPORT
  84. // This flag should be defined when compiling the library as a lib or dll.
  85. // ANGELSCRIPT_DLL_LIBRARY_IMPORT
  86. // This flag should be defined when using AngelScript as a dll with automatic
  87. // library import.
  88. // ANGELSCRIPT_DLL_MANUAL_IMPORT
  89. // This flag should be defined when using AngelScript as a dll with manual
  90. // loading of the library.
  91. //
  92. // Compiler differences
  93. //-----------------------------------------
  94. // asVSNPRINTF(a,b,c,d)
  95. // Some compilers use different names for this function. You must
  96. // define this macro to map to the proper function.
  97. // ASM_AT_N_T or ASM_INTEL
  98. // You should choose what inline assembly syntax to use when compiling.
  99. // VALUE_OF_BOOLEAN_TRUE
  100. // This flag allows to customize the exact value of boolean true.
  101. // AS_SIZEOF_BOOL
  102. // On some target platforms the sizeof(bool) is 4, but on most it is 1.
  103. // STDCALL
  104. // This is used to declare a function to use the stdcall calling convention.
  105. // AS_NO_MEMORY_H
  106. // Some compilers don't come with the memory.h header file.
  107. // AS_NO_THISCALL_FUNCTOR_METHOD
  108. // Defined if the support for functor methods hasn't been implemented on the platform.
  109. //
  110. // How to identify different compilers
  111. //-----------------------------------------
  112. // MS Visual C++
  113. // _MSC_VER is defined
  114. // __MWERKS__ is not defined
  115. // Metrowerks
  116. // _MSC_VER is defined
  117. // __MWERKS__ is defined
  118. // GNU C based compilers
  119. // __GNUC__ is defined
  120. // Embarcadero C++Builder
  121. // __BORLANDC__ is defined
  122. // Sun CC compiler
  123. // __SUNPRO_CC is defined
  124. //
  125. // CPU differences
  126. //---------------------------------------
  127. // AS_USE_DOUBLE_AS_FLOAT
  128. // If there is no 64 bit floating point type, then this constant can be defined
  129. // to treat double like normal floats.
  130. // AS_X86
  131. // Use assembler code for the x86 CPU family
  132. // AS_SH4
  133. // Use assembler code for the SH4 CPU family
  134. // AS_MIPS
  135. // Use assembler code for the MIPS CPU family
  136. // AS_PPC
  137. // Use assembler code for the 32bit PowerPC CPU family
  138. // AS_PPC_64
  139. // Use assembler code for the 64bit PowerPC CPU family
  140. // AS_XENON
  141. // Use assembler code for the Xenon (XBOX360) CPU family
  142. // AS_ARM
  143. // Use assembler code for the ARM CPU family
  144. // AS_SOFTFP
  145. // Use to tell compiler that ARM soft-float ABI
  146. // should be used instead of ARM hard-float ABI
  147. // AS_X64_GCC
  148. // Use GCC assembler code for the X64 AMD/Intel CPU family
  149. // AS_X64_MSVC
  150. // Use MSVC assembler code for the X64 AMD/Intel CPU family
  151. // AS_64BIT_PTR
  152. // Define this to make the engine store all pointers in 64bit words.
  153. // AS_BIG_ENDIAN
  154. // Define this for CPUs that use big endian memory layout, e.g. PPC
  155. // AS_SPARC
  156. // Define this for SPARC CPU family
  157. //
  158. // Target systems
  159. //--------------------------------
  160. // This group shows a few of the flags used to identify different target systems.
  161. // Sometimes there are differences on different target systems, while both CPU and
  162. // compiler is the same for both, when this is so these flags are used to produce the
  163. // right code.
  164. // AS_WIN - Microsoft Windows
  165. // AS_LINUX - Linux
  166. // AS_MAC - Apple Macintosh
  167. // AS_BSD - BSD based OS (FreeBSD, DragonFly, OpenBSD, etc)
  168. // AS_XBOX - Microsoft XBox
  169. // AS_XBOX360 - Microsoft XBox 360
  170. // AS_PSP - Sony Playstation Portable
  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. #define AS_SOFTFP
  370. #endif
  371. #ifndef COMPLEX_MASK
  372. #define COMPLEX_MASK (asOBJ_APP_ARRAY)
  373. #endif
  374. #ifndef COMPLEX_RETURN_MASK
  375. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT | asOBJ_APP_ARRAY)
  376. #endif
  377. #define UNREACHABLE_RETURN
  378. #endif
  379. // Metrowerks CodeWarrior (experimental, let me know if something isn't working)
  380. #if defined(__MWERKS__) && !defined(EPPC) // JWC -- If Wii DO NOT use this even when using Metrowerks Compiler. Even though they are called Freescale...
  381. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  382. #define HAVE_VIRTUAL_BASE_OFFSET
  383. #define VIRTUAL_BASE_OFFSET(x) (*((asDWORD*)(&x)+3))
  384. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  385. #define THISCALL_PASS_OBJECT_POINTER_IN_ECX
  386. #define asVSNPRINTF(a, b, c, d) _vsnprintf(a, b, c, d)
  387. #define THISCALL_CALLEE_POPS_ARGUMENTS
  388. #define COMPLEX_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  389. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT)
  390. #define AS_SIZEOF_BOOL 1
  391. #define AS_WINDOWS_THREADS
  392. #define STDCALL __stdcall
  393. // Support native calling conventions on x86, but not 64bit yet
  394. #if defined(_M_IX86) && !defined(__LP64__)
  395. #define AS_X86
  396. #define ASM_INTEL // Intel style for inline assembly
  397. #endif
  398. #define UNREACHABLE_RETURN
  399. #endif
  400. // SN Systems ProDG
  401. #if defined(__SNC__) || defined(SNSYS)
  402. #define GNU_STYLE_VIRTUAL_METHOD
  403. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  404. #define CALLEE_POPS_HIDDEN_RETURN_POINTER
  405. #define COMPLEX_OBJS_PASSED_BY_REF
  406. #define ASM_AT_N_T // AT&T style inline assembly
  407. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  408. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR)
  409. #define AS_SIZEOF_BOOL 1
  410. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  411. // SN doesnt seem to like STDCALL.
  412. // Maybe it can work with some fiddling, but I can't imagine linking to
  413. // any STDCALL functions with a console anyway...
  414. #define STDCALL
  415. // Linux specific
  416. #ifdef __linux__
  417. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  418. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  419. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  420. #endif
  421. // Support native calling conventions on x86, but not 64bit yet
  422. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  423. #define AS_X86
  424. // PS3
  425. #elif (defined(__PPC__) || defined(__ppc__)) && defined(__PPU__)
  426. // Support native calling conventions on PS3
  427. #define AS_PS3
  428. #define AS_PPC_64
  429. // PSP
  430. #elif defined(__psp__)
  431. #define AS_NO_MEMORY_H
  432. #define AS_MIPS
  433. #define AS_PSP
  434. #endif
  435. #define UNREACHABLE_RETURN
  436. #endif
  437. // GNU C (and MinGW or Cygwin on Windows)
  438. // Use the following command to determine predefined macros: echo . | g++ -dM -E -
  439. #if (defined(__GNUC__) && !defined(__SNC__)) || defined(EPPC) || defined(__CYGWIN__) // JWC -- use this instead for Wii
  440. #define GNU_STYLE_VIRTUAL_METHOD
  441. #if !defined( __amd64__ )
  442. #define MULTI_BASE_OFFSET(x) (*((asDWORD*)(&x)+1))
  443. #else
  444. #define MULTI_BASE_OFFSET(x) (*((asQWORD*)(&x)+1))
  445. #endif
  446. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  447. #define CALLEE_POPS_HIDDEN_RETURN_POINTER
  448. #define COMPLEX_OBJS_PASSED_BY_REF
  449. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_ARRAY)
  450. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_ARRAY)
  451. #define AS_NO_MEMORY_H
  452. #define AS_SIZEOF_BOOL 1
  453. #define STDCALL __attribute__((stdcall))
  454. #define ASM_AT_N_T
  455. // WII U
  456. #if defined(__ghs__)
  457. #define AS_WIIU
  458. // Native calling conventions are not yet supported
  459. #define AS_MAX_PORTABILITY
  460. // Marmalade is a cross platform SDK. It uses g++ to compile for iOS and Android
  461. #elif defined(__S3E__)
  462. #ifndef AS_MARMALADE
  463. // From now on we'll use the below define
  464. #define AS_MARMALADE
  465. #endif
  466. // STDCALL is not available on Marmalade when compiled for iOS or Android
  467. #undef STDCALL
  468. #define STDCALL
  469. // Marmalade doesn't seem to have proper support for
  470. // atomic instructions or read/write locks
  471. #define AS_NO_THREADS
  472. #define AS_NO_ATOMIC
  473. // Identify for which CPU the library is being built
  474. #if defined(I3D_ARCH_X86)
  475. #define AS_X86
  476. #elif defined(I3D_ARCH_ARM)
  477. #define AS_ARM
  478. #define AS_SOFTFP
  479. // Marmalade appear to use the same ABI as Android when built for ARM
  480. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  481. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  482. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  483. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  484. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  485. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  486. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  487. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  488. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  489. #undef GNU_STYLE_VIRTUAL_METHOD
  490. #undef COMPLEX_MASK
  491. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  492. #undef COMPLEX_RETURN_MASK
  493. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  494. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  495. #endif
  496. // MacOSX and IPhone
  497. #elif defined(__APPLE__)
  498. #include <TargetConditionals.h>
  499. // Is this a Mac or an IPhone (or other iOS device)?
  500. #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1
  501. #define AS_IPHONE
  502. #else
  503. #define AS_MAC
  504. #endif
  505. // The sizeof bool is different depending on the target CPU
  506. #undef AS_SIZEOF_BOOL
  507. #if defined(__ppc__)
  508. #define AS_SIZEOF_BOOL 4
  509. // STDCALL is not available on PPC
  510. #undef STDCALL
  511. #define STDCALL
  512. #else
  513. #define AS_SIZEOF_BOOL 1
  514. #endif
  515. #if (defined(_ARM_) || defined(__arm__))
  516. // iOS use ARM processor
  517. #define AS_ARM
  518. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  519. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  520. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  521. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  522. #undef GNU_STYLE_VIRTUAL_METHOD
  523. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  524. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  525. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  526. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  527. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  528. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  529. #define COMPLEX_OBJS_PASSED_BY_REF
  530. #undef COMPLEX_MASK
  531. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  532. #undef COMPLEX_RETURN_MASK
  533. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  534. // iOS uses soft-float ABI
  535. #define AS_SOFTFP
  536. // STDCALL is not available on ARM
  537. #undef STDCALL
  538. #define STDCALL
  539. #elif (defined(__arm64__))
  540. // The IPhone 5S+ uses an ARM64 processor
  541. // AngelScript currently doesn't support native calling
  542. // for 64bit ARM processors so it's necessary to turn on
  543. // portability mode
  544. #define AS_MAX_PORTABILITY
  545. // STDCALL is not available on ARM
  546. #undef STDCALL
  547. #define STDCALL
  548. #elif (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  549. // Support native calling conventions on Mac OS X + Intel 32bit CPU
  550. #define AS_X86
  551. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  552. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  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. #elif defined(__LP64__) && !defined(__ppc__) && !defined(__PPC__) && !defined(__arm64__)
  558. // 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
  559. #define AS_X64_GCC
  560. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  561. #define HAS_128_BIT_PRIMITIVES
  562. #define SPLIT_OBJS_BY_MEMBER_TYPES
  563. #undef COMPLEX_MASK
  564. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  565. #undef COMPLEX_RETURN_MASK
  566. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  567. #define AS_LARGE_OBJS_PASSED_BY_REF
  568. #define AS_LARGE_OBJ_MIN_SIZE 5
  569. // STDCALL is not available on 64bit Mac
  570. #undef STDCALL
  571. #define STDCALL
  572. #elif (defined(__ppc__) || defined(__PPC__)) && !defined(__LP64__)
  573. // Support native calling conventions on Mac OS X + PPC 32bit CPU
  574. #define AS_PPC
  575. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  576. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  577. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  578. #undef COMPLEX_MASK
  579. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  580. #undef COMPLEX_RETURN_MASK
  581. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  582. #elif (defined(__ppc__) || defined(__PPC__)) && defined(__LP64__)
  583. #define AS_PPC_64
  584. #else
  585. // Unknown CPU type
  586. #define AS_MAX_PORTABILITY
  587. #endif
  588. #define AS_POSIX_THREADS
  589. // Windows
  590. #elif defined(WIN32) || defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
  591. // On Windows the simple classes are returned in the EAX:EDX registers
  592. //#define THISCALL_RETURN_SIMPLE_IN_MEMORY
  593. //#define CDECL_RETURN_SIMPLE_IN_MEMORY
  594. //#define STDCALL_RETURN_SIMPLE_IN_MEMORY
  595. #undef COMPLEX_MASK
  596. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  597. #undef COMPLEX_RETURN_MASK
  598. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  599. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  600. // Support native calling conventions on Intel 32bit CPU
  601. #define AS_X86
  602. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  603. // As of version 4.7 MinGW changed the ABI, presumably
  604. // to be better aligned with how MSVC works
  605. #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || __GNUC__ > 4
  606. #undef CALLEE_POPS_HIDDEN_RETURN_POINTER
  607. #define THISCALL_CALLEE_POPS_ARGUMENTS
  608. #else
  609. // Earlier versions than 4.7
  610. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  611. #endif
  612. #elif defined(__x86_64__)
  613. #define AS_X64_MINGW
  614. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  615. #define AS_LARGE_OBJS_PASSED_BY_REF
  616. #define AS_LARGE_OBJ_MIN_SIZE 3
  617. #define COMPLEX_OBJS_PASSED_BY_REF
  618. #else
  619. #define AS_MAX_PORTABILITY
  620. #endif
  621. #define AS_WIN
  622. #define AS_WINDOWS_THREADS
  623. // Linux
  624. #elif defined(__linux__) && !defined(ANDROID) && !defined(__ANDROID__)
  625. #undef COMPLEX_MASK
  626. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  627. #undef COMPLEX_RETURN_MASK
  628. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  629. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  630. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  631. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  632. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  633. // Support native calling conventions on Intel 32bit CPU
  634. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  635. #define AS_X86
  636. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  637. #elif defined(__LP64__) && !defined(__arm64__)
  638. #define AS_X64_GCC
  639. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  640. #define HAS_128_BIT_PRIMITIVES
  641. #define SPLIT_OBJS_BY_MEMBER_TYPES
  642. #define AS_LARGE_OBJS_PASSED_BY_REF
  643. #define AS_LARGE_OBJ_MIN_SIZE 5
  644. // STDCALL is not available on 64bit Linux
  645. #undef STDCALL
  646. #define STDCALL
  647. #elif defined(__ARMEL__) || defined(__arm__)
  648. #define AS_ARM
  649. #undef STDCALL
  650. #define STDCALL
  651. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  652. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  653. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  654. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  655. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  656. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  657. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  658. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  659. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  660. #ifndef AS_MAX_PORTABILITY
  661. // Make a few checks against incompatible ABI combinations
  662. #if defined(__FAST_MATH__) && __FAST_MATH__ == 1
  663. #error -ffast-math is not supported with native calling conventions
  664. #endif
  665. #endif
  666. // Verify if soft-float or hard-float ABI is used
  667. #if defined(__SOFTFP__) && __SOFTFP__ == 1
  668. // -ffloat-abi=softfp or -ffloat-abi=soft
  669. #define AS_SOFTFP
  670. #endif
  671. // Tested with both hard float and soft float abi
  672. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  673. #elif defined(__mips__)
  674. #define AS_MIPS
  675. #define AS_BIG_ENDIAN
  676. #define AS_USE_DOUBLE_AS_FLOAT
  677. // Native calling conventions for Linux/Mips do not work yet.
  678. #define AS_MAX_PORTABILITY
  679. #else
  680. #define AS_MAX_PORTABILITY
  681. #endif
  682. #define AS_LINUX
  683. #define AS_POSIX_THREADS
  684. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  685. // Only with GCC 4.1 was the atomic instructions available
  686. #define AS_NO_ATOMIC
  687. #endif
  688. // Free BSD
  689. #elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__)
  690. #define AS_BSD
  691. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  692. #undef COMPLEX_MASK
  693. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  694. #undef COMPLEX_RETURN_MASK
  695. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  696. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  697. #define AS_X86
  698. #elif defined(__LP64__)
  699. #define AS_X64_GCC
  700. #define HAS_128_BIT_PRIMITIVES
  701. #define SPLIT_OBJS_BY_MEMBER_TYPES
  702. #undef COMPLEX_MASK
  703. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  704. #undef COMPLEX_RETURN_MASK
  705. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  706. #define AS_LARGE_OBJS_PASSED_BY_REF
  707. #define AS_LARGE_OBJ_MIN_SIZE 5
  708. #undef STDCALL
  709. #define STDCALL
  710. #else
  711. #define AS_MAX_PORTABILITY
  712. #endif
  713. #define AS_POSIX_THREADS
  714. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  715. // Only with GCC 4.1 was the atomic instructions available
  716. #define AS_NO_ATOMIC
  717. #endif
  718. // PSP and PS2
  719. #elif defined(__PSP__) || defined(__psp__) || defined(_EE_) || defined(_PSP) || defined(_PS2)
  720. // Support native calling conventions on MIPS architecture
  721. #if (defined(_MIPS_ARCH) || defined(_mips) || defined(__MIPSEL__)) && !defined(__LP64__)
  722. #define AS_MIPS
  723. #else
  724. #define AS_MAX_PORTABILITY
  725. #endif
  726. // PS3
  727. #elif (defined(__PPC__) || defined(__ppc__)) && defined(__PPU__)
  728. // Support native calling conventions on PS3
  729. #define AS_PS3
  730. #define AS_PPC_64
  731. #define SPLIT_OBJS_BY_MEMBER_TYPES
  732. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  733. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  734. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  735. // PS3 doesn't have STDCALL
  736. #undef STDCALL
  737. #define STDCALL
  738. // Dreamcast
  739. #elif __SH4_SINGLE_ONLY__
  740. // Support native calling conventions on Dreamcast
  741. #define AS_DC
  742. #define AS_SH4
  743. // Wii JWC - Close to PS3 just no PPC_64 and AS_PS3
  744. #elif defined(EPPC)
  745. #define AS_WII
  746. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  747. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  748. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  749. #undef STDCALL
  750. #define STDCALL
  751. // Android
  752. #elif defined(ANDROID) || defined(__ANDROID__)
  753. #define AS_ANDROID
  754. // Android 2.3+ supports posix threads
  755. #define AS_POSIX_THREADS
  756. // Common configuration with Android arm and x86
  757. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  758. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  759. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  760. #undef COMPLEX_MASK
  761. #define COMPLEX_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  762. #undef COMPLEX_RETURN_MASK
  763. #define COMPLEX_RETURN_MASK (asOBJ_APP_CLASS_DESTRUCTOR | asOBJ_APP_CLASS_COPY_CONSTRUCTOR | asOBJ_APP_ARRAY)
  764. #if (defined(_ARM_) || defined(__arm__))
  765. // Android ARM
  766. #undef THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  767. #undef CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  768. #undef STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE
  769. #define THISCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  770. #define CDECL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  771. #define STDCALL_RETURN_SIMPLE_IN_MEMORY_MIN_SIZE 2
  772. // The stdcall calling convention is not used on the arm cpu
  773. #undef STDCALL
  774. #define STDCALL
  775. #undef GNU_STYLE_VIRTUAL_METHOD
  776. #define AS_ARM
  777. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  778. #define AS_SOFTFP
  779. #define AS_CALLEE_DESTROY_OBJ_BY_VAL
  780. #elif (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  781. // Android Intel x86 (same config as Linux x86). Tested with Intel x86 Atom System Image.
  782. // Support native calling conventions on Intel 32bit CPU
  783. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  784. #define AS_X86
  785. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  786. // Urho3D - Add support for Android Intel x86_64 and Android ARM 64bit
  787. #elif defined(__LP64__) && !defined(__aarch64__)
  788. // Android Intel x86_64 (same config as Linux x86_64). Tested with Intel x86_64 Atom System Image.
  789. #define AS_X64_GCC
  790. #undef AS_NO_THISCALL_FUNCTOR_METHOD
  791. #define HAS_128_BIT_PRIMITIVES
  792. #define SPLIT_OBJS_BY_MEMBER_TYPES
  793. #define AS_LARGE_OBJS_PASSED_BY_REF
  794. #define AS_LARGE_OBJ_MIN_SIZE 5
  795. // STDCALL is not available on 64bit Linux
  796. #undef STDCALL
  797. #define STDCALL
  798. #elif defined(__aarch64__)
  799. // Doesn't support native calling for Android ARM 64bit yet
  800. #define AS_MAX_PORTABILITY
  801. // STDCALL is not available on ARM
  802. #undef STDCALL
  803. #define STDCALL
  804. #endif
  805. // Haiku OS
  806. #elif __HAIKU__
  807. #define AS_HAIKU
  808. // Only x86-32 is currently supported by Haiku, but they do plan to support
  809. // x86-64 and PowerPC in the future, so should go ahead and check the platform
  810. // for future compatibility
  811. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  812. #define AS_X86
  813. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  814. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  815. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  816. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  817. #else
  818. #define AS_MAX_PORTABILITY
  819. #endif
  820. #define AS_POSIX_THREADS
  821. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  822. // Only with GCC 4.1 was the atomic instructions available
  823. #define AS_NO_ATOMIC
  824. #endif
  825. // Illumos
  826. #elif defined(__sun)
  827. #if (defined(i386) || defined(__i386) || defined(__i386__)) && !defined(__LP64__)
  828. #define THISCALL_RETURN_SIMPLE_IN_MEMORY
  829. #define CDECL_RETURN_SIMPLE_IN_MEMORY
  830. #define STDCALL_RETURN_SIMPLE_IN_MEMORY
  831. // Support native calling conventions on Intel 32bit CPU
  832. #define THISCALL_PASS_OBJECT_POINTER_ON_THE_STACK
  833. #define AS_X86
  834. #elif defined(__LP64__)
  835. #define AS_X64_GCC
  836. #define HAS_128_BIT_PRIMITIVES
  837. #define SPLIT_OBJS_BY_MEMBER_TYPES
  838. // STDCALL is not available on 64bit Linux
  839. #undef STDCALL
  840. #define STDCALL
  841. #else
  842. #define AS_MAX_PORTABILITY
  843. #endif
  844. #define AS_ILLUMOS
  845. #define AS_POSIX_THREADS
  846. #if !( ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) )
  847. // Only with GCC 4.1 was the atomic instructions available
  848. #define AS_NO_ATOMIC
  849. #endif
  850. #endif
  851. #define UNREACHABLE_RETURN
  852. #endif
  853. // Sun CC
  854. // Initial information provided by Andrey Bergman
  855. #if defined(__SUNPRO_CC)
  856. #if defined(__sparc)
  857. #define AS_SPARC
  858. #endif
  859. #if defined(__sun)
  860. #define AS_SUN
  861. #endif
  862. // Native calling conventions is not yet supported for Sun CC
  863. #if !defined(AS_MAX_PORTABILITY)
  864. #define AS_MAX_PORTABILITY
  865. #endif
  866. // I presume Sun CC uses a similar structure of method pointers as gnuc
  867. #define MULTI_BASE_OFFSET(x) (*((asPWORD*)(&x)+1))
  868. #if !defined(AS_SIZEOF_BOOL)
  869. #define AS_SIZEOF_BOOL 1 // sizeof(bool) == 1
  870. #endif
  871. #if !defined(UNREACHABLE_RETURN)
  872. #define UNREACHABLE_RETURN
  873. #endif
  874. #if !defined(STDCALL)
  875. #define STDCALL // There is no stdcall on Solaris/SunPro/SPARC
  876. #endif
  877. #if !defined(asVSNPRINTF)
  878. #define asVSNPRINTF(a, b, c, d) vsnprintf(a, b, c, d)
  879. #endif
  880. #endif
  881. //
  882. // Detect target hardware
  883. //------------------------------------------------
  884. // X86, Intel, AMD, etc, i.e. most PCs
  885. #if defined(__i386__) || defined(_M_IX86)
  886. // Nothing special here
  887. #endif
  888. // MIPS architecture (generally PS2 and PSP consoles, potentially supports N64 as well)
  889. #if defined(_MIPS_ARCH) || defined(_mips) || defined(__MIPSEL__) || defined(__PSP__) || defined(__psp__) || defined(_EE_) || defined(_PSP) || defined(_PS2)
  890. #define AS_USE_DOUBLE_AS_FLOAT // use 32bit floats instead of doubles
  891. #endif
  892. // PowerPC, e.g. Mac, GameCube, PS3, XBox 360, Wii
  893. #if defined(__PPC__) || defined(__ppc__) || defined(_PPC_) || defined(EPPC)
  894. #define AS_BIG_ENDIAN
  895. // Gamecube
  896. #if defined(_GC)
  897. #define AS_USE_DOUBLE_AS_FLOAT
  898. #endif
  899. #endif
  900. // Dreamcast console
  901. #ifdef __SH4_SINGLE_ONLY__
  902. #define AS_USE_DOUBLE_AS_FLOAT // use 32bit floats instead of doubles
  903. #endif
  904. // If there are no current support for native calling
  905. // conventions, then compile with AS_MAX_PORTABILITY
  906. #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))
  907. #ifndef AS_MAX_PORTABILITY
  908. #define AS_MAX_PORTABILITY
  909. #endif
  910. #endif
  911. // If the platform doesn't support atomic instructions we can't allow
  912. // multithreading as the reference counters won't be threadsafe
  913. #if defined(AS_NO_ATOMIC) && !defined(AS_NO_THREADS)
  914. #define AS_NO_THREADS
  915. #endif
  916. // If the form of threads to use hasn't been chosen
  917. // then the library will be compiled without support
  918. // for multithreading
  919. #if !defined(AS_POSIX_THREADS) && !defined(AS_WINDOWS_THREADS)
  920. #define AS_NO_THREADS
  921. #endif
  922. // The assert macro
  923. #if defined(ANDROID)
  924. #if defined(AS_DEBUG)
  925. #include <android/log.h>
  926. #include <stdlib.h>
  927. #define asASSERT(x) \
  928. do { \
  929. if (!(x)) { \
  930. __android_log_print(ANDROID_LOG_ERROR, "AngelScript", "Assert failed at %s:%d - %s", __FILE__, __LINE__, #x); \
  931. exit(1); \
  932. } \
  933. } while (0)
  934. #else
  935. #define asASSERT(x)
  936. #endif
  937. #else
  938. #include <assert.h>
  939. #define asASSERT(x) assert(x)
  940. #endif
  941. //
  942. // Internal defines (do not change these)
  943. //----------------------------------------------------------------
  944. #define ARG_W(b) ((asWORD*)&b)
  945. #define ARG_DW(b) ((asDWORD*)&b)
  946. #define ARG_QW(b) ((asQWORD*)&b)
  947. #define ARG_PTR(b) ((asPWORD*)&b)
  948. #define BCARG_W(b) ((asWORD*)&(b)[1])
  949. #define BCARG_DW(b) ((asDWORD*)&(b)[1])
  950. #define BCARG_QW(b) ((asQWORD*)&(b)[1])
  951. #define BCARG_PTR(b) ((asPWORD*)&(b)[1])
  952. // This macro is used to avoid warnings about unused variables.
  953. // Usually where the variables are only used in debug mode.
  954. #define UNUSED_VAR(x) (void)(x)
  955. #include "../include/angelscript.h"
  956. #include "as_memory.h"
  957. #ifdef AS_USE_NAMESPACE
  958. using namespace AngelScript;
  959. #endif
  960. #endif