暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

il2cpp-config-platforms.h 12KB

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