il2cpp-config-platforms.h 11 KB

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