il2cpp-config-platforms.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. #pragma once
  2. #include <stddef.h> // ptrdiff_t
  3. #if defined(__aarch64__) && defined(__arm__)
  4. #error We assume both __aarch64__ and __arm__ cannot be defined at tha same time.
  5. #endif
  6. #if defined(__aarch64__) || defined(_M_ARM64)
  7. #define IL2CPP_TARGET_ARM64 1
  8. #define IL2CPP_TARGET_ARMV7 0
  9. #elif defined(__arm__)
  10. #define IL2CPP_TARGET_ARM64 0
  11. #define IL2CPP_TARGET_ARMV7 1
  12. #else
  13. #define IL2CPP_TARGET_ARM64 0
  14. #define IL2CPP_TARGET_ARMV7 0
  15. #endif
  16. #if defined(__arm64e__) && defined(__PTRAUTH_INTRINSICS__)
  17. #define IL2CPP_TARGET_ARM64E 1
  18. #else
  19. #define IL2CPP_TARGET_ARM64E 0
  20. #endif
  21. #if defined(__x86_64__) || defined(_M_X64)
  22. #define IL2CPP_TARGET_X64 1
  23. #define IL2CPP_TARGET_X86 0
  24. #elif defined(__i386__) || defined(_M_IX86)
  25. #define IL2CPP_TARGET_X64 0
  26. #define IL2CPP_TARGET_X86 1
  27. #else
  28. #define IL2CPP_TARGET_X64 0
  29. #define IL2CPP_TARGET_X86 0
  30. #endif
  31. #if defined(EMBEDDED_LINUX)
  32. #define IL2CPP_TARGET_EMBEDDED_LINUX 1
  33. #endif
  34. // Large executables on ARM64 and ARMv7 can cause linker errors.
  35. // Specifically, the arm instruction set limits the range a branch can
  36. // take (e.g. 128MB on ARM64). Normally, the linker will insert branch
  37. // islands to bridge gaps larger than the maximum branch range. However,
  38. // branch islands only work within a section, not across sections. So if
  39. // IL2CPP puts managed code into a specific section of the binary, branch
  40. // isalnds won't work. That means that proejcts with a large executable
  41. // size may fail to link.
  42. //
  43. // Set the define IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND to a value of 1
  44. // work around this issue.
  45. //
  46. // The cost of this define is in correctness of managed stack traces.
  47. // With this define enabled, managed stack traces maybe not be correct
  48. // in some cases, because the stack trace generation code must use
  49. // fuzzy heuristics to detemine if a given instrion pointer is in a
  50. // managed method.
  51. #if IL2CPP_TARGET_EMBEDDED_LINUX && IL2CPP_TARGET_ARMV7
  52. // currently on EmbeddedLinux stack unwinding doesn't work properly when using custom code sections on ARMv7
  53. // as a result processing exceptions from managed code and resolving managed stack traces doesn't work
  54. #ifndef IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND
  55. #define IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND 1
  56. #endif
  57. #endif
  58. #if IL2CPP_TARGET_ARM64 || IL2CPP_TARGET_ARMV7
  59. #ifndef IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND
  60. #define IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND 0
  61. #endif
  62. #endif
  63. #define IL2CPP_BINARY_SECTION_NAME "il2cpp"
  64. #if defined(SN_TARGET_PSP2)
  65. #define IL2CPP_TARGET_PSP2 1
  66. #define _UNICODE 1
  67. #define UNICODE 1
  68. #include "il2cpp-config-psp2.h"
  69. #elif defined(SN_TARGET_ORBIS)
  70. #define IL2CPP_TARGET_PS4 1
  71. #define _UNICODE 1
  72. #define UNICODE 1
  73. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS 1
  74. #define IL2CPP_METHOD_ATTR __attribute__((section(IL2CPP_BINARY_SECTION_NAME)))
  75. #elif defined(_MSC_VER)
  76. #define IL2CPP_TARGET_WINDOWS 1
  77. #if IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND
  78. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS 0
  79. #else
  80. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS !IL2CPP_MONO_DEBUGGER
  81. #endif
  82. #define IL2CPP_PLATFORM_SUPPORTS_DEBUGGER_PRESENT 1
  83. #if IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS
  84. #define IL2CPP_METHOD_ATTR __declspec(code_seg (IL2CPP_BINARY_SECTION_NAME))
  85. #endif
  86. #if defined(_XBOX_ONE)
  87. #define IL2CPP_TARGET_XBOXONE 1
  88. #define IL2CPP_PLATFORM_SUPPORTS_DEBUGGER_PRESENT 1
  89. #define IL2CPP_ENABLE_PLATFORM_THREAD_AFFINTY 1
  90. #elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
  91. #define IL2CPP_TARGET_WINRT 1
  92. #define IL2CPP_PLATFORM_SUPPORTS_SYSTEM_CERTIFICATES 1
  93. #elif defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_GAMES)
  94. #define IL2CPP_TARGET_WINDOWS_GAMES 1
  95. #define IL2CPP_PLATFORM_SUPPORTS_SYSTEM_CERTIFICATES 1
  96. #define IL2CPP_ENABLE_PLATFORM_THREAD_AFFINTY 1
  97. #if defined(_GAMING_XBOX)
  98. #define IL2CPP_TARGET_GAMECORE_XBOX 1
  99. #endif
  100. #elif (IL2CPP_CUSTOM_PLATFORM)
  101. #else
  102. #define IL2CPP_TARGET_WINDOWS_DESKTOP 1
  103. #define IL2CPP_PLATFORM_SUPPORTS_SYSTEM_CERTIFICATES 1
  104. #define IL2CPP_PLATFORM_SUPPORTS_CPU_INFO 1
  105. // Windows 7 is the min OS we support, so we cannot link newer APIs
  106. #define NTDDI_VERSION 0x06010000
  107. #define _WIN32_WINNT 0x0601
  108. #define WINVER 0x0601
  109. #endif
  110. #define _UNICODE 1
  111. #define UNICODE 1
  112. #define STRICT 1
  113. #elif defined(__APPLE__)
  114. #define IL2CPP_TARGET_DARWIN 1
  115. #define IL2CPP_PLATFORM_SUPPORTS_CPU_INFO 1
  116. #define IL2CPP_PLATFORM_SUPPORTS_TIMEZONEINFO 1
  117. #include "TargetConditionals.h"
  118. #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR || TARGET_OS_TV || TARGET_TVOS_SIMULATOR || ((defined(TARGET_OS_XR) && TARGET_OS_XR) || (defined(TARGET_OS_VISION) && TARGET_OS_VISION)) || TARGET_VISIONOS_SIMULATOR
  119. #define IL2CPP_TARGET_IOS 1
  120. #define IL2CPP_PLATFORM_SUPPORTS_CPU_INFO 1
  121. #else
  122. #define IL2CPP_TARGET_OSX 1
  123. #define IL2CPP_PLATFORM_SUPPORTS_SYSTEM_CERTIFICATES 1
  124. #endif
  125. #if IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND
  126. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS 0
  127. #else
  128. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS (!(IL2CPP_TARGET_IOS && IL2CPP_TARGET_ARMV7) && !IL2CPP_MONO_DEBUGGER)
  129. #endif
  130. #if IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS
  131. #define IL2CPP_METHOD_ATTR __attribute__((section ("__TEXT," IL2CPP_BINARY_SECTION_NAME ",regular,pure_instructions")))
  132. #endif
  133. #elif defined(__ANDROID__)
  134. #define IL2CPP_TARGET_ANDROID 1
  135. #define IL2CPP_PLATFORM_SUPPORTS_TIMEZONEINFO 1
  136. #define IL2CPP_ENABLE_PLATFORM_THREAD_RENAME 1
  137. #if IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND
  138. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS 0
  139. #else
  140. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS !IL2CPP_MONO_DEBUGGER
  141. #endif
  142. #define IL2CPP_PLATFORM_DISABLE_LIBC_PINVOKE 1
  143. #if IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS
  144. #define IL2CPP_METHOD_ATTR __attribute__((section(IL2CPP_BINARY_SECTION_NAME)))
  145. #endif
  146. #elif defined(__EMSCRIPTEN__)
  147. #define IL2CPP_TARGET_JAVASCRIPT 1
  148. #define IL2CPP_PLATFORM_SUPPORTS_CPU_INFO 1
  149. #elif defined(__linux__)
  150. #define IL2CPP_TARGET_LINUX 1
  151. #define IL2CPP_PLATFORM_SUPPORTS_CPU_INFO 1
  152. #define IL2CPP_PLATFORM_SUPPORTS_SYSTEM_CERTIFICATES 1
  153. #if IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND
  154. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS 0
  155. #else
  156. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS !IL2CPP_MONO_DEBUGGER
  157. #endif
  158. #if IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS
  159. #define IL2CPP_METHOD_ATTR __attribute__((section(IL2CPP_BINARY_SECTION_NAME)))
  160. #endif
  161. #elif defined(__QNX__)
  162. // for calloc, free
  163. #include <stdlib.h>
  164. #define IL2CPP_TARGET_QNX 1
  165. #define IL2CPP_PLATFORM_SUPPORTS_CPU_INFO 1
  166. #define IL2CPP_PLATFORM_SUPPORTS_SYSTEM_CERTIFICATES 1
  167. #define IL2CPP_USE_POSIX_SOCKET_PLATFORM_CONFIG 1
  168. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS 0
  169. #if IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS
  170. #define IL2CPP_METHOD_ATTR __attribute__((section(IL2CPP_BINARY_SECTION_NAME)))
  171. #endif
  172. #elif defined(NN_PLATFORM_CTR)
  173. #define IL2CPP_TARGET_N3DS 1
  174. #elif defined(NN_BUILD_TARGET_PLATFORM_NX)
  175. #define IL2CPP_TARGET_SWITCH 1
  176. #include "il2cpp-config-switch.h"
  177. #elif IL2CPP_TARGET_CUSTOM
  178. // defined handled externally
  179. #else
  180. #error please define your target platform
  181. #endif
  182. #if IL2CPP_TARGET_PS5
  183. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS 1
  184. #define IL2CPP_METHOD_ATTR __attribute__((section(IL2CPP_BINARY_SECTION_NAME)))
  185. #endif
  186. #ifndef IL2CPP_TARGET_WINDOWS
  187. #define IL2CPP_TARGET_WINDOWS 0
  188. #endif
  189. #ifndef IL2CPP_TARGET_WINDOWS_DESKTOP
  190. #define IL2CPP_TARGET_WINDOWS_DESKTOP 0
  191. #endif
  192. #ifndef IL2CPP_TARGET_WINDOWS_GAMES
  193. #define IL2CPP_TARGET_WINDOWS_GAMES 0
  194. #endif
  195. #ifndef IL2CPP_TARGET_GAMECORE_XBOX
  196. #define IL2CPP_TARGET_GAMECORE_XBOX 0
  197. #endif
  198. #ifndef IL2CPP_TARGET_WINRT
  199. #define IL2CPP_TARGET_WINRT 0
  200. #endif
  201. #ifndef IL2CPP_TARGET_XBOXONE
  202. #define IL2CPP_TARGET_XBOXONE 0
  203. #endif
  204. #ifndef IL2CPP_TARGET_DARWIN
  205. #define IL2CPP_TARGET_DARWIN 0
  206. #endif
  207. #ifndef IL2CPP_TARGET_IOS
  208. #define IL2CPP_TARGET_IOS 0
  209. #endif
  210. #ifndef IL2CPP_TARGET_OSX
  211. #define IL2CPP_TARGET_OSX 0
  212. #endif
  213. #ifndef IL2CPP_TARGET_ANDROID
  214. #define IL2CPP_TARGET_ANDROID 0
  215. #endif
  216. #ifndef IL2CPP_TARGET_JAVASCRIPT
  217. #define IL2CPP_TARGET_JAVASCRIPT 0
  218. #endif
  219. #ifndef IL2CPP_TARGET_LINUX
  220. #define IL2CPP_TARGET_LINUX 0
  221. #endif
  222. #ifndef IL2CPP_TARGET_QNX
  223. #define IL2CPP_TARGET_QNX 0
  224. #endif
  225. #ifndef IL2CPP_TARGET_N3DS
  226. #define IL2CPP_TARGET_N3DS 0
  227. #endif
  228. #ifndef IL2CPP_TARGET_PS4
  229. #define IL2CPP_TARGET_PS4 0
  230. #endif
  231. #ifndef IL2CPP_TARGET_PSP2
  232. #define IL2CPP_TARGET_PSP2 0
  233. #endif
  234. #ifndef IL2CPP_TARGET_SWITCH
  235. #define IL2CPP_TARGET_SWITCH 0
  236. #endif
  237. #ifndef IL2CPP_TARGET_EMBEDDED_LINUX
  238. #define IL2CPP_TARGET_EMBEDDED_LINUX 0
  239. #endif
  240. #ifndef IL2CPP_TARGET_POSIX
  241. #define IL2CPP_TARGET_POSIX (IL2CPP_TARGET_DARWIN || IL2CPP_TARGET_JAVASCRIPT || IL2CPP_TARGET_LINUX || IL2CPP_TARGET_QNX || IL2CPP_TARGET_ANDROID || IL2CPP_TARGET_PS4 || IL2CPP_TARGET_PSP2)
  242. #endif
  243. #define RUNTIME_TINY (IL2CPP_TINY && !IL2CPP_MONO_DEBUGGER)
  244. #define IL2CPP_TINY_DEBUGGER (IL2CPP_TINY && IL2CPP_MONO_DEBUGGER)
  245. #define IL2CPP_IL2CPP_TINY_SUPPORT_THREADS IL2CPP_TINY &&IL2CPP_TINY_DEBUGGER
  246. #define IL2CPP_IL2CPP_TINY_SUPPORT_SOCKETS IL2CPP_TINY &&IL2CPP_TINY_DEBUGGER
  247. #ifndef IL2CPP_SUPPORT_THREADS
  248. #define IL2CPP_SUPPORT_THREADS ((!IL2CPP_TARGET_JAVASCRIPT || IL2CPP_TINY_DEBUGGER) && (!IL2CPP_TINY || IL2CPP_IL2CPP_TINY_SUPPORT_THREADS))
  249. #endif
  250. #ifndef IL2CPP_SUPPORT_SOCKETS
  251. #define IL2CPP_SUPPORT_SOCKETS (!IL2CPP_TINY || IL2CPP_IL2CPP_TINY_SUPPORT_SOCKETS)
  252. #endif
  253. #ifndef IL2CPP_PLATFORM_OVERRIDES_STD_FILE_HANDLES
  254. #define IL2CPP_PLATFORM_OVERRIDES_STD_FILE_HANDLES 0
  255. #endif
  256. #ifndef IL2CPP_PLATFORM_SUPPORTS_SYSTEM_CERTIFICATES
  257. #define IL2CPP_PLATFORM_SUPPORTS_SYSTEM_CERTIFICATES 0
  258. #endif
  259. #ifndef IL2CPP_PLATFORM_SUPPORTS_TIMEZONEINFO
  260. #define IL2CPP_PLATFORM_SUPPORTS_TIMEZONEINFO 0
  261. #endif
  262. #ifndef IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS
  263. #define IL2CPP_PLATFORM_SUPPORTS_CUSTOM_SECTIONS 0
  264. #endif
  265. #ifndef IL2CPP_DEBUG
  266. #define IL2CPP_DEBUG 0
  267. #endif
  268. #ifndef IL2CPP_PLATFORM_SUPPORTS_CPU_INFO
  269. #define IL2CPP_PLATFORM_SUPPORTS_CPU_INFO 0
  270. #endif
  271. #ifndef IL2CPP_PLATFORM_SUPPORTS_DEBUGGER_PRESENT
  272. #define IL2CPP_PLATFORM_SUPPORTS_DEBUGGER_PRESENT 0
  273. #endif
  274. #ifndef IL2CPP_PLATFORM_DISABLE_LIBC_PINVOKE
  275. #define IL2CPP_PLATFORM_DISABLE_LIBC_PINVOKE 0
  276. #endif
  277. #ifndef IL2CPP_PLATFORM_SUPPORTS_BACKTRACE_CALL
  278. #define IL2CPP_PLATFORM_SUPPORTS_BACKTRACE_CALL !IL2CPP_TARGET_WINDOWS && !IL2CPP_TARGET_ANDROID && !IL2CPP_TARGET_PS4 && !IL2CPP_TARGET_PS5
  279. #endif //IL2CPP_PLATFORM_SUPPORTS_BACKTRACE_CALL
  280. #ifndef IL2CPP_SUPPORT_SOCKETS_POSIX_API
  281. #define IL2CPP_SUPPORT_SOCKETS_POSIX_API 0
  282. #endif
  283. #define IL2CPP_USE_STD_THREAD 0
  284. #define IL2CPP_THREADS_STD IL2CPP_USE_STD_THREAD
  285. #define IL2CPP_THREADS_PTHREAD (!IL2CPP_THREADS_STD && IL2CPP_TARGET_POSIX)
  286. #define IL2CPP_THREADS_WIN32 (!IL2CPP_THREADS_STD && IL2CPP_TARGET_WINDOWS)
  287. #define IL2CPP_THREADS_N3DS (!IL2CPP_THREADS_STD && IL2CPP_TARGET_N3DS)
  288. #define IL2CPP_THREADS_PS4 (!IL2CPP_THREADS_STD && IL2CPP_TARGET_PS4)
  289. #define IL2CPP_THREADS_PSP2 (!IL2CPP_THREADS_STD && IL2CPP_TARGET_PSP2)
  290. #define IL2CPP_THREADS_SWITCH (!IL2CPP_THREADS_STD && IL2CPP_TARGET_SWITCH)
  291. // Set to 1 to use the baselib based version of the FastReaderReaderWriterLock
  292. // Use if the baselib::Lock implementation on the platform is faster than the il2cpp::os based version
  293. #ifndef IL2CPP_USE_BASELIB_FAST_READER_RWL
  294. #define IL2CPP_USE_BASELIB_FAST_READER_RWL 0
  295. #endif
  296. #define IL2CPP_THREAD_HAS_CPU_SET IL2CPP_TARGET_POSIX && !IL2CPP_THREADS_PS4
  297. // Not supported on TINY because it doesn't support synchronization context
  298. // Not supported on no runtime because it needs to call back into the runtime!
  299. #define IL2CPP_HAS_OS_SYNCHRONIZATION_CONTEXT (IL2CPP_TARGET_WINDOWS) && !IL2CPP_TINY && !RUNTIME_NONE && !IL2CPP_TARGET_WINDOWS_GAMES
  300. /* Trigger assert if 'ptr' is not aligned to 'alignment'. */
  301. #define ASSERT_ALIGNMENT(ptr, alignment) \
  302. IL2CPP_ASSERT((((ptrdiff_t) ptr) & (alignment - 1)) == 0 && "Unaligned pointer!")
  303. #if defined(_MSC_VER)
  304. #if defined(_M_X64) || defined(_M_ARM64)
  305. #define IL2CPP_SIZEOF_VOID_P 8
  306. #elif defined(_M_IX86) || defined(_M_ARM)
  307. #define IL2CPP_SIZEOF_VOID_P 4
  308. #else
  309. #error invalid windows architecture
  310. #endif
  311. #elif defined(__GNUC__) || defined(__SNC__)
  312. #if defined(__x86_64__)
  313. #define IL2CPP_SIZEOF_VOID_P 8
  314. #elif defined(__i386__)
  315. #define IL2CPP_SIZEOF_VOID_P 4
  316. #elif defined(__EMSCRIPTEN__)
  317. #define IL2CPP_SIZEOF_VOID_P 4
  318. #elif defined(__arm__)
  319. #define IL2CPP_SIZEOF_VOID_P 4
  320. #elif defined(__arm64__) || defined(__aarch64__)
  321. #define IL2CPP_SIZEOF_VOID_P 8
  322. #else
  323. #error invalid windows architecture
  324. #endif
  325. #else
  326. #error please define your target architecture size
  327. #endif
  328. #ifndef IL2CPP_USE_GENERIC_CRASH_HELPERS
  329. #define IL2CPP_USE_GENERIC_CRASH_HELPERS (!IL2CPP_TARGET_WINDOWS && !IL2CPP_TARGET_POSIX)
  330. #endif
  331. #ifndef IL2CPP_SUPPORTS_CONSOLE_EXTENSION
  332. #define IL2CPP_SUPPORTS_CONSOLE_EXTENSION IL2CPP_TARGET_ANDROID
  333. #endif
  334. #define IL2CPP_COMPILER_MSVC (IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_XBOXONE)
  335. #if IL2CPP_COMPILER_MSVC
  336. #ifndef STDCALL
  337. #define STDCALL __stdcall
  338. #endif
  339. #ifndef CDECL
  340. #define CDECL __cdecl
  341. #endif
  342. #ifndef FASTCALL
  343. #define FASTCALL __fastcall
  344. #endif
  345. #ifndef THISCALL
  346. #define THISCALL __thiscall
  347. #endif
  348. #else
  349. #define STDCALL
  350. #define CDECL
  351. #define FASTCALL
  352. #define THISCALL
  353. #endif