il2cpp-config.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. #pragma once
  2. #include <string.h>
  3. /* first setup platform defines*/
  4. #include "os/c-api/il2cpp-config-platforms.h"
  5. #include "os/c-api/il2cpp-config-api-platforms.h"
  6. #include "il2cpp-config-api.h"
  7. #include "il2cpp-sanitizers.h"
  8. #ifdef LIBIL2CPP_EXPORT_CODEGEN_API
  9. # define LIBIL2CPP_CODEGEN_API IL2CPP_EXPORT
  10. #elif LIBIL2CPP_IMPORT_CODEGEN_API
  11. # define LIBIL2CPP_CODEGEN_API IL2CPP_IMPORT
  12. #else
  13. # define LIBIL2CPP_CODEGEN_API
  14. #endif
  15. #if defined(__ARMCC_VERSION)
  16. #include <wchar.h>
  17. #include <ctype.h>
  18. #define INTPTR_MAX 2147483647
  19. #endif
  20. #ifndef IL2CPP_METHOD_ATTR
  21. #define IL2CPP_METHOD_ATTR
  22. #endif
  23. #if defined(_MSC_VER)
  24. #define IL2CPP_CXX_ABI_MSVC 1
  25. #else
  26. #define IL2CPP_CXX_ABI_MSVC 0
  27. #endif
  28. #if defined(__GNUC__)
  29. #define IL2CPP_GCC_VERSION (__GNUC__ * 10000 \
  30. + __GNUC_MINOR__ * 100 \
  31. + __GNU_PATCHLEVEL__)
  32. #endif
  33. typedef void (STDCALL *SynchronizationContextCallback)(intptr_t arg);
  34. typedef void (STDCALL *CultureInfoChangedCallback)(const Il2CppChar* arg);
  35. #if defined(__cplusplus)
  36. #define IL2CPP_EXTERN_C extern "C"
  37. #define IL2CPP_EXTERN_C_CONST extern "C" const
  38. #define IL2CPP_EXTERN_C_BEGIN extern "C" {
  39. #define IL2CPP_EXTERN_C_END }
  40. #else
  41. #define IL2CPP_EXTERN_C
  42. #define IL2CPP_EXTERN_C_CONST extern const
  43. #define IL2CPP_EXTERN_C_BEGIN
  44. #define IL2CPP_EXTERN_C_END
  45. #endif
  46. #if IL2CPP_COMPILER_MSVC || defined(__ARMCC_VERSION)
  47. #define IL2CPP_NO_INLINE __declspec(noinline)
  48. #define IL2CPP_NO_ALIAS __declspec(noalias)
  49. #define IL2CPP_PARAMETER_RESTRICT __restrict
  50. #define IL2CPP_METHOD_RESTRICT __declspec(restrict)
  51. #define IL2CPP_ASSUME(x) __assume(x)
  52. #else
  53. #define IL2CPP_NO_INLINE __attribute__ ((noinline))
  54. #define IL2CPP_NO_ALIAS
  55. #define IL2CPP_PARAMETER_RESTRICT
  56. #define IL2CPP_METHOD_RESTRICT
  57. #define IL2CPP_ASSUME(x)
  58. #endif
  59. #if IL2CPP_COMPILER_MSVC
  60. #define NOVTABLE __declspec(novtable)
  61. #else
  62. #define NOVTABLE
  63. #endif
  64. #define IL2CPP_ENABLE_MONO_BUG_EMULATION 1
  65. #ifndef ALIGN_OF // Baselib header can also define this - if so use their definition.
  66. #if defined(__GNUC__) || defined(__SNC__) || defined(__clang__)
  67. #define ALIGN_OF(T) __alignof__(T)
  68. #define ALIGN_TYPE(val) __attribute__((aligned(val)))
  69. #define ALIGN_FIELD(val) ALIGN_TYPE(val)
  70. // GCC earlier than 10.1 are unable to compile properly with the always_inline attribute
  71. #if defined(__GNUC__) && IL2CPP_GCC_VERSION < 100100
  72. #define IL2CPP_FORCE_INLINE inline
  73. #else
  74. #define IL2CPP_FORCE_INLINE inline __attribute__ ((always_inline))
  75. #endif
  76. #define IL2CPP_MANAGED_FORCE_INLINE IL2CPP_FORCE_INLINE
  77. #elif defined(_MSC_VER)
  78. #define ALIGN_OF(T) __alignof(T)
  79. #if _MSC_VER >= 1900 && defined(__cplusplus)
  80. #define ALIGN_TYPE(val) alignas(val)
  81. #else
  82. #define ALIGN_TYPE(val) __declspec(align(val))
  83. #endif
  84. #define ALIGN_FIELD(val) __declspec(align(val))
  85. #define IL2CPP_FORCE_INLINE __forceinline
  86. #define IL2CPP_MANAGED_FORCE_INLINE inline
  87. #else
  88. #define ALIGN_TYPE(size)
  89. #define ALIGN_FIELD(size)
  90. #define IL2CPP_FORCE_INLINE inline
  91. #define IL2CPP_MANAGED_FORCE_INLINE IL2CPP_FORCE_INLINE
  92. #endif
  93. #endif
  94. #define IL2CPP_PAGE_SIZE 4096
  95. // 64-bit types are aligned to 8 bytes on 64-bit platforms
  96. #define IL2CPP_ENABLE_INTERLOCKED_64_REQUIRED_ALIGNMENT (IL2CPP_SIZEOF_VOID_P == 8)
  97. /* Debugging */
  98. #ifndef IL2CPP_DEBUG
  99. #define IL2CPP_DEBUG 0
  100. #endif
  101. #ifndef IL2CPP_DEVELOPMENT
  102. #define IL2CPP_DEVELOPMENT 0
  103. #endif
  104. #define IL2CPP_THREADS_ALL_ACCESS (!IL2CPP_THREADS_STD && IL2CPP_TARGET_XBOXONE)
  105. #if (IL2CPP_SUPPORT_THREADS && (!IL2CPP_THREADS_STD && !IL2CPP_THREADS_PTHREAD && !IL2CPP_THREADS_WIN32 && !IL2CPP_THREADS_XBOXONE && !IL2CPP_THREADS_N3DS && !IL2CPP_THREADS_PS4 && !IL2CPP_THREADS_PSP2 && !IL2CPP_THREADS_SWITCH && !IL2CPP_THREADS_CUSTOM))
  106. #error "No thread implementation defined"
  107. #endif
  108. /* Platform support to cleanup attached threads even when native threads are not exited cleanly */
  109. #define IL2CPP_HAS_NATIVE_THREAD_CLEANUP (IL2CPP_THREADS_PTHREAD || IL2CPP_THREADS_WIN32 || IL2CPP_TARGET_SWITCH)
  110. #define IL2CPP_THREAD_IMPL_HAS_COM_APARTMENTS IL2CPP_TARGET_WINDOWS
  111. #if !defined(IL2CPP_ENABLE_PLATFORM_THREAD_STACKSIZE) && IL2CPP_TARGET_IOS
  112. #define IL2CPP_ENABLE_PLATFORM_THREAD_STACKSIZE 1
  113. #endif
  114. #if IL2CPP_TINY
  115. #if IL2CPP_TINY_DEBUG_METADATA || IL2CPP_TINY_DEBUGGER
  116. #define IL2CPP_ENABLE_STACKTRACES 1
  117. #else
  118. #define IL2CPP_ENABLE_STACKTRACES 0
  119. #endif // IL2CPP_TINY_DEBUG_METADATA
  120. #else
  121. #define IL2CPP_ENABLE_STACKTRACES !IL2CPP_TARGET_QNX
  122. #endif // IL2CPP_TINY
  123. #ifndef IL2CPP_DISABLE_GC
  124. #if IL2CPP_TINY && IL2CPP_TARGET_JAVASCRIPT
  125. #define IL2CPP_DISABLE_GC 1
  126. #endif
  127. #endif
  128. #ifndef FORCE_PINVOKE_INTERNAL
  129. #if IL2CPP_TINY && IL2CPP_TARGET_IOS
  130. #define FORCE_PINVOKE_INTERNAL 1
  131. #endif
  132. #endif
  133. #ifndef HOST_WASM
  134. #if IL2CPP_TINY_DEBUGGER && IL2CPP_TARGET_JAVASCRIPT
  135. #define HOST_WASM 1
  136. #endif
  137. #endif
  138. /* Platforms which use OS specific implementation to extract stracktrace */
  139. #if !defined(IL2CPP_ENABLE_NATIVE_STACKTRACES)
  140. #define IL2CPP_ENABLE_NATIVE_STACKTRACES (IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_LINUX || IL2CPP_TARGET_DARWIN || IL2CPP_TARGET_IOS || IL2CPP_TARGET_ANDROID)
  141. #endif
  142. /* Platforms which support native IP emission to crash reporting to enable server-side reconstruction of C# exception stack trace line numbers */
  143. #if !defined(IL2CPP_ENABLE_NATIVE_INSTRUCTION_POINTER_EMISSION)
  144. #define IL2CPP_ENABLE_NATIVE_INSTRUCTION_POINTER_EMISSION (IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_LINUX || IL2CPP_TARGET_DARWIN || IL2CPP_TARGET_IOS || IL2CPP_TARGET_ANDROID)
  145. #endif
  146. #if IL2CPP_ENABLE_STACKTRACES
  147. /* Platforms which use stacktrace sentries */
  148. #if !defined(IL2CPP_ENABLE_STACKTRACE_SENTRIES)
  149. #define IL2CPP_ENABLE_STACKTRACE_SENTRIES (IL2CPP_TARGET_JAVASCRIPT || IL2CPP_TARGET_N3DS || IL2CPP_TARGET_SWITCH)
  150. #endif
  151. #endif // IL2CPP_ENABLE_STACKTRACES
  152. #if (IL2CPP_ENABLE_STACKTRACES && !IL2CPP_ENABLE_NATIVE_STACKTRACES && !IL2CPP_ENABLE_STACKTRACE_SENTRIES)
  153. #error "If stacktraces are supported, then either native stack traces must be supported, or usage of stacktrace sentries must be enabled!"
  154. #endif
  155. #if (IL2CPP_ENABLE_NATIVE_STACKTRACES + IL2CPP_ENABLE_STACKTRACE_SENTRIES) > 1
  156. #error "Only one type of stacktraces are allowed"
  157. #endif
  158. #define IL2CPP_CAN_USE_MULTIPLE_SYMBOL_MAPS IL2CPP_TARGET_IOS
  159. /* GC defines*/
  160. #define IL2CPP_GC_BOEHM 1
  161. #define IL2CPP_GC_NULL !IL2CPP_GC_BOEHM
  162. #define IL2CPP_ENABLE_DEFERRED_GC IL2CPP_TARGET_JAVASCRIPT
  163. /* we always need to NULL pointer free memory with our current allocators */
  164. #define NEED_TO_ZERO_PTRFREE 1
  165. #define IL2CPP_HAS_GC_DESCRIPTORS 1
  166. #if defined(_MSC_VER)
  167. #define IL2CPP_ZERO_LEN_ARRAY 0
  168. #else
  169. #define IL2CPP_ZERO_LEN_ARRAY 0
  170. #endif
  171. #if defined(_MSC_VER)
  172. #define IL2CPP_HAS_CXX_CONSTEXPR (_MSC_VER >= 1900)
  173. #else
  174. #define IL2CPP_HAS_CXX_CONSTEXPR (__has_feature (cxx_constexpr))
  175. #endif
  176. #if IL2CPP_HAS_CXX_CONSTEXPR
  177. #define COMPILE_TIME_CONST constexpr
  178. #else
  179. #define COMPILE_TIME_CONST const
  180. #endif
  181. /* clang specific __has_builtin check */
  182. #ifndef __has_builtin
  183. #define __has_builtin(x) 0 // Compatibility with non-clang compilers.
  184. #endif
  185. #if _MSC_VER
  186. #define IL2CPP_UNREACHABLE __assume(0)
  187. #elif __has_builtin(__builtin_unreachable) || IL2CPP_TARGET_QNX
  188. #define IL2CPP_UNREACHABLE __builtin_unreachable()
  189. #else
  190. #define IL2CPP_UNREACHABLE
  191. #endif
  192. typedef uint16_t Il2CppMethodSlot;
  193. static const uint16_t kInvalidIl2CppMethodSlot = 65535;
  194. /* Debug macros */
  195. #if defined(_MSC_VER) && _MSC_VER >= 1900 // UTF-8 literals are only supported in VS2015+
  196. // On MSVC, __FILE__ will expand to ANSI string literal and will fail to compile if there are unicode characters in the path
  197. // So we specify it to be UTF-8 literal explicitly
  198. #define MAKE_UTF8_LITERAL_HELPER(x) u8 ## x
  199. #define MAKE_UTF8_LITERAL(x) MAKE_UTF8_LITERAL_HELPER(x)
  200. #else
  201. #define MAKE_UTF8_LITERAL(x) x
  202. #endif
  203. #define __FILE_UTF8__ MAKE_UTF8_LITERAL(__FILE__)
  204. #define STRINGIZE(L) #L
  205. #define MAKE_STRING(M, L) M(L)
  206. #define $Line MAKE_STRING( STRINGIZE, __LINE__ )
  207. #define FIXME "FIXME: "
  208. #define ICALLMESSAGE(name) __FILE_UTF8__ "(" $Line ") : FIXME: Missing internal call implementation: " name
  209. #define RUNTIMEMESSAGE(name) __FILE_UTF8__ "(" $Line ") : FIXME: Missing runtime implementation: " name
  210. #define NOTSUPPORTEDICALLMESSAGE(target, name, reason) __FILE_UTF8__ "(" $Line ") : Unsupported internal call for " target ":" name " - " reason
  211. // Keeping this for future usage if needed.
  212. //#if defined(_MSC_VER)
  213. // #define PRAGMA_MESSAGE(value) __pragma(message(value))
  214. //#else
  215. // #define PRAGMA_MESSAGE(value) _Pragma(STRINGIZE(value))
  216. //#endif
  217. #define PRAGMA_MESSAGE(value)
  218. #if !defined(__EMSCRIPTEN__)
  219. #define IL2CPP_NOT_IMPLEMENTED_ICALL(func) \
  220. PRAGMA_MESSAGE(ICALLMESSAGE(#func)) \
  221. IL2CPP_ASSERT(0 && #func)
  222. #define IL2CPP_NOT_IMPLEMENTED_ICALL_NO_ASSERT(func, reason) \
  223. PRAGMA_MESSAGE(ICALLMESSAGE(#func))
  224. #define IL2CPP_NOT_IMPLEMENTED(func) \
  225. PRAGMA_MESSAGE(RUNTIMEMESSAGE(#func)) \
  226. IL2CPP_ASSERT(0 && #func)
  227. #define IL2CPP_NOT_IMPLEMENTED_NO_ASSERT(func, reason) \
  228. PRAGMA_MESSAGE(RUNTIMEMESSAGE(#func))
  229. #else
  230. #include <stdio.h>
  231. #include <emscripten/emscripten.h>
  232. // emscripten's assert will throw an exception in js.
  233. // For now, we don't want that, so just printf and move on.
  234. #define IL2CPP_NOT_IMPLEMENTED_ICALL(func) \
  235. PRAGMA_MESSAGE(message(ICALLMESSAGE(#func))) \
  236. emscripten_log(EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK, "Not implemented icall: %s\n", #func);
  237. #define IL2CPP_NOT_IMPLEMENTED_ICALL_NO_ASSERT(func, reason) \
  238. PRAGMA_MESSAGE(message(ICALLMESSAGE(#func)))
  239. #define IL2CPP_NOT_IMPLEMENTED(func) \
  240. PRAGMA_MESSAGE(message(RUNTIMEMESSAGE(#func))) \
  241. printf("Not implemented: %s\n", #func);
  242. #define IL2CPP_NOT_IMPLEMENTED_NO_ASSERT(func, reason) \
  243. PRAGMA_MESSAGE(message(RUNTIMEMESSAGE(#func)))
  244. #endif
  245. #if !RUNTIME_TINY
  246. #define NOT_SUPPORTED_IL2CPP(func, reason) \
  247. il2cpp::vm::Exception::Raise (il2cpp::vm::Exception::GetNotSupportedException ( NOTSUPPORTEDICALLMESSAGE ("IL2CPP", #func, #reason) ))
  248. #define NOT_SUPPORTED_SRE(func) \
  249. il2cpp::vm::Exception::Raise (il2cpp::vm::Exception::GetNotSupportedException ( NOTSUPPORTEDICALLMESSAGE ("IL2CPP", #func, "System.Reflection.Emit is not supported.") ))
  250. #define NOT_SUPPORTED_REMOTING(func) \
  251. il2cpp::vm::Exception::Raise (il2cpp::vm::Exception::GetNotSupportedException ( NOTSUPPORTEDICALLMESSAGE ("IL2CPP", #func, "System.Runtime.Remoting is not supported.") ))
  252. #if IL2CPP_TARGET_JAVASCRIPT
  253. #define NOT_SUPPORTED_WEBGL(func, reason) \
  254. il2cpp::vm::Exception::Raise (il2cpp::vm::Exception::GetNotSupportedException ( NOTSUPPORTEDICALLMESSAGE ("WebGL", #func, #reason) ))
  255. #else
  256. #define NOT_SUPPORTED_WEBGL(func, reason)
  257. #endif
  258. #else
  259. #define NOT_SUPPORTED_IL2CPP(func, reason)
  260. #define NOT_SUPPORTED_SRE(func)
  261. #define NOT_SUPPORTED_REMOTING(func)
  262. #define NOT_SUPPORTED_WEBGL(func, reason)
  263. #endif // #if !RUNTIME_TINY
  264. #if IL2CPP_COMPILER_MSVC
  265. #define IL2CPP_DIR_SEPARATOR '\\' /* backslash */
  266. #else
  267. #define IL2CPP_DIR_SEPARATOR '/' /* forward slash */
  268. #endif
  269. #ifndef IL2CPP_DISABLE_FULL_MESSAGES
  270. #define IL2CPP_DISABLE_FULL_MESSAGES 1
  271. #endif
  272. #if IL2CPP_COMPILER_MSVC
  273. #define IL2CPP_USE_GENERIC_SOCKET_IMPL 0
  274. #else
  275. #define IL2CPP_USE_GENERIC_SOCKET_IMPL !(IL2CPP_TARGET_POSIX || IL2CPP_TARGET_SWITCH || IL2CPP_SUPPORT_SOCKETS_POSIX_API)
  276. #endif
  277. #ifndef IL2CPP_USE_GENERIC_SOCKET_BRIDGE
  278. #define IL2CPP_USE_GENERIC_SOCKET_BRIDGE !IL2CPP_TARGET_JAVASCRIPT
  279. #endif
  280. /* Set by platforms that require special handling of SIGPIPE signalling during socket sends. */
  281. /* Is redefined by platform specific headers. Enabled for common Linux desktop platforms. */
  282. #ifndef IL2CPP_USE_SEND_NOSIGNAL
  283. #define IL2CPP_USE_SEND_NOSIGNAL IL2CPP_TARGET_LINUX
  284. #endif
  285. #ifndef IL2CPP_USE_GENERIC_ENVIRONMENT
  286. #define IL2CPP_USE_GENERIC_ENVIRONMENT (!IL2CPP_TARGET_WINDOWS && !IL2CPP_TARGET_POSIX)
  287. #endif
  288. #define IL2CPP_USE_GENERIC_COM (!IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_WINDOWS_GAMES)
  289. #define IL2CPP_USE_GENERIC_COM_SAFEARRAYS (!IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_XBOXONE || IL2CPP_TARGET_WINDOWS_GAMES)
  290. #define IL2CPP_USE_GENERIC_WINDOWSRUNTIME (!IL2CPP_TARGET_WINDOWS || RUNTIME_NONE || IL2CPP_TINY || IL2CPP_TARGET_WINDOWS_GAMES)
  291. #ifndef IL2CPP_USE_GENERIC_MEMORY_MAPPED_FILE
  292. #define IL2CPP_USE_GENERIC_MEMORY_MAPPED_FILE (IL2CPP_TARGET_XBOXONE || IL2CPP_TARGET_WINDOWS_GAMES || IL2CPP_TARGET_JAVASCRIPT || (!IL2CPP_TARGET_WINDOWS && !IL2CPP_TARGET_POSIX))
  293. #endif
  294. #ifndef IL2CPP_HAS_CLOSE_EXEC
  295. #define IL2CPP_HAS_CLOSE_EXEC (IL2CPP_TARGET_POSIX && !IL2CPP_TARGET_PS4)
  296. #endif
  297. #ifndef IL2CPP_HAS_DUP
  298. #define IL2CPP_HAS_DUP (IL2CPP_TARGET_POSIX && !IL2CPP_TARGET_PS4)
  299. #endif
  300. #ifndef IL2CPP_USE_GENERIC_FILE
  301. #define IL2CPP_USE_GENERIC_FILE (!IL2CPP_TARGET_WINDOWS && !IL2CPP_TARGET_DARWIN)
  302. #endif
  303. #ifndef IL2CPP_USE_GENERIC_DEBUG_LOG
  304. #define IL2CPP_USE_GENERIC_DEBUG_LOG !IL2CPP_TARGET_WINDOWS
  305. #endif
  306. #ifndef IL2CPP_USE_GENERIC_PROCESS
  307. #define IL2CPP_USE_GENERIC_PROCESS 1
  308. #endif
  309. #ifndef IL2CPP_USE_GENERIC_THREAD
  310. #define IL2CPP_USE_GENERIC_THREAD (!IL2CPP_TARGET_WINDOWS && !IL2CPP_TARGET_POSIX && !IL2CPP_TARGET_DARWIN)
  311. #endif
  312. #define IL2CPP_SIZEOF_STRUCT_WITH_NO_INSTANCE_FIELDS 1
  313. #define IL2CPP_VALIDATE_FIELD_LAYOUT 0
  314. #if IL2CPP_MONO_DEBUGGER
  315. #define STORE_SEQ_POINT(storage, seqPoint) (storage).currentSequencePoint = seqPoint;
  316. #define STORE_TRY_ID(storage, id) (storage).tryId = id;
  317. #define CHECK_SEQ_POINT(storage, seqPoint) il2cpp_codegen_check_sequence_point(&(storage), seqPoint);
  318. #define CHECK_METHOD_ENTRY_SEQ_POINT(storage, seqPoint) il2cpp_codegen_check_sequence_point_entry(&(storage), seqPoint);
  319. #define CHECK_METHOD_EXIT_SEQ_POINT(name, storage, seqPoint) MethodExitSequencePointChecker name(&(storage), seqPoint);
  320. #define DECLARE_METHOD_THIS(variableName, thisAddress) void* variableName[] = { thisAddress }
  321. #define DECLARE_METHOD_PARAMS(variableName, ...) void* variableName[] = { __VA_ARGS__ }
  322. #define DECLARE_METHOD_LOCALS(variableName, ...) void* variableName[] = { __VA_ARGS__ }
  323. #define DECLARE_METHOD_EXEC_CTX(ctxVariable, method, thisVariable, paramsVariable, localsVariable) Il2CppSequencePointExecutionContext ctxVariable(method, thisVariable, paramsVariable, localsVariable)
  324. #define CHECK_PAUSE_POINT il2cpp_codegen_check_pause_point()
  325. #else
  326. #define STORE_SEQ_POINT(storage, seqPoint)
  327. #define STORE_TRY_ID(storage, id)
  328. #define CHECK_SEQ_POINT(storage, seqPoint)
  329. #define CHECK_METHOD_ENTRY_SEQ_POINT(storage, seqPoint)
  330. #define CHECK_METHOD_EXIT_SEQ_POINT(name, storage, seqPoint)
  331. #define DECLARE_METHOD_THIS(variableName, thisAddress)
  332. #define DECLARE_METHOD_PARAMS(variableName, ...)
  333. #define DECLARE_METHOD_LOCALS(variableName, ...)
  334. #define DECLARE_METHOD_EXEC_CTX(ctxVariable, method, thisVariable, paramsVariable, localsVariable)
  335. #define CHECK_PAUSE_POINT
  336. #endif
  337. #ifdef __cplusplus
  338. template<bool value>
  339. struct Il2CppStaticAssertHelper;
  340. template<>
  341. struct Il2CppStaticAssertHelper<true>
  342. {
  343. };
  344. #define Assert(x) do { (void)(x); IL2CPP_ASSERT(x); } while (false)
  345. #define Il2CppStaticAssert(...) do { Il2CppStaticAssertHelper<(__VA_ARGS__)>(); } while (false)
  346. #endif
  347. static const int32_t kIl2CppInt32Min = INT32_MIN;
  348. static const int32_t kIl2CppInt32Max = INT32_MAX;
  349. static const uint32_t kIl2CppUInt32Max = UINT32_MAX;
  350. static const int64_t kIl2CppInt64Min = INT64_MIN;
  351. static const int64_t kIl2CppInt64Max = INT64_MAX;
  352. static const uint64_t kIl2CppUInt64Max = UINT64_MAX;
  353. #if IL2CPP_SIZEOF_VOID_P == 8
  354. static const intptr_t kIl2CppIntPtrMin = INT64_MIN;
  355. static const intptr_t kIl2CppIntPtrMax = INT64_MAX;
  356. static const uintptr_t kIl2CppUIntPtrMax = UINT64_MAX;
  357. #else
  358. static const intptr_t kIl2CppIntPtrMin = INT32_MIN;
  359. static const intptr_t kIl2CppIntPtrMax = INT32_MAX;
  360. static const uintptr_t kIl2CppUIntPtrMax = UINT32_MAX;
  361. #endif
  362. static const int ipv6AddressSize = 16;
  363. #if !defined(IL2CPP_SUPPORT_IPV6)
  364. #define IL2CPP_SUPPORT_IPV6 !IL2CPP_TARGET_PS4 && !IL2CPP_TARGET_SWITCH
  365. #endif
  366. #define IL2CPP_SUPPORT_IPV6_SUPPORT_QUERY (IL2CPP_SUPPORT_IPV6 && IL2CPP_TARGET_LINUX)
  367. #if !defined(IL2CPP_SUPPORT_SEND_FILE)
  368. #define IL2CPP_SUPPORT_SEND_FILE (!IL2CPP_TARGET_SWITCH && !IL2CPP_TARGET_QNX && !IL2CPP_TARGET_JAVASCRIPT)
  369. #endif
  370. #if !defined(IL2CPP_SUPPORT_RECV_MSG)
  371. #define IL2CPP_SUPPORT_RECV_MSG (!IL2CPP_TARGET_SWITCH)
  372. #endif
  373. #if !defined(IL2CPP_SUPPORT_SEND_MSG)
  374. #define IL2CPP_SUPPORT_SEND_MSG (!IL2CPP_TARGET_SWITCH)
  375. #endif
  376. #ifndef IL2CPP_USE_NETWORK_ACCESS_HANDLER
  377. #define IL2CPP_USE_NETWORK_ACCESS_HANDLER 0
  378. #endif
  379. // Android: "There is no support for locales in the C library" https://code.google.com/p/android/issues/detail?id=57313
  380. // PS4/PS2: strtol_d doesn't exist
  381. #if !defined(IL2CPP_SUPPORT_LOCALE_INDEPENDENT_PARSING)
  382. #define IL2CPP_SUPPORT_LOCALE_INDEPENDENT_PARSING (!IL2CPP_TARGET_QNX && !IL2CPP_TARGET_ANDROID && !IL2CPP_TARGET_PS4 && !IL2CPP_TARGET_PSP2)
  383. #endif
  384. #define NO_UNUSED_WARNING(expr) (void)(expr)
  385. typedef int32_t il2cpp_hresult_t;
  386. // Sorted numerically!
  387. #define IL2CPP_S_OK ((il2cpp_hresult_t)0)
  388. #define IL2CPP_S_FALSE ((il2cpp_hresult_t)1)
  389. #define IL2CPP_E_BOUNDS ((il2cpp_hresult_t)0x8000000B)
  390. #define IL2CPP_E_CHANGED_STATE ((il2cpp_hresult_t)0x8000000C)
  391. #define IL2CPP_E_ILLEGAL_METHOD_CALL ((il2cpp_hresult_t)0x8000000E)
  392. #define IL2CPP_RO_E_CLOSED ((il2cpp_hresult_t)0x80000013)
  393. #define IL2CPP_E_NOTIMPL ((il2cpp_hresult_t)0x80004001)
  394. #define IL2CPP_E_NOINTERFACE ((il2cpp_hresult_t)0x80004002)
  395. #define IL2CPP_E_POINTER ((il2cpp_hresult_t)0x80004003)
  396. #define IL2CPP_E_ABORT ((il2cpp_hresult_t)0x80004004)
  397. #define IL2CPP_E_FAIL ((il2cpp_hresult_t)0x80004005)
  398. #define IL2CPP_E_UNEXPECTED ((il2cpp_hresult_t)0x8000FFFF)
  399. #define IL2CPP_RPC_E_DISCONNECTED ((il2cpp_hresult_t)0x80010108)
  400. #define IL2CPP_RPC_E_WRONG_THREAD ((il2cpp_hresult_t)0x8001010E)
  401. #define IL2CPP_DISP_E_PARAMNOTFOUND ((il2cpp_hresult_t)0x80020004)
  402. #define IL2CPP_REGDB_E_CLASSNOTREG ((il2cpp_hresult_t)0x80040154)
  403. #define IL2CPP_E_FILE_NOT_FOUND ((il2cpp_hresult_t)0x80070002)
  404. #define IL2CPP_E_ACCESS_DENIED ((il2cpp_hresult_t)0x80070005)
  405. #define IL2CPP_E_OUTOFMEMORY ((il2cpp_hresult_t)0x8007000E)
  406. #define IL2CPP_E_INVALIDARG ((il2cpp_hresult_t)0x80070057)
  407. #define IL2CPP_COR_E_EXCEPTION ((il2cpp_hresult_t)0x80131500)
  408. #define IL2CPP_COR_E_EXECUTIONENGINE ((il2cpp_hresult_t)0x80131506)
  409. #define IL2CPP_COR_E_INVALIDOPERATION ((il2cpp_hresult_t)0x80131509)
  410. #define IL2CPP_COR_E_PLATFORMNOTSUPPORTED ((il2cpp_hresult_t)0x80131539)
  411. #define IL2CPP_COR_E_OPERATIONCANCELED ((il2cpp_hresult_t)0x8013153B)
  412. #define IL2CPP_COR_E_OBJECTDISPOSED ((il2cpp_hresult_t)0x80131622)
  413. #define IL2CPP_HR_SUCCEEDED(hr) (((il2cpp_hresult_t)(hr)) >= 0)
  414. #define IL2CPP_HR_FAILED(hr) (((il2cpp_hresult_t)(hr)) < 0)
  415. #define IL2CPP_LITTLE_ENDIAN 1
  416. #define IL2CPP_BIG_ENDIAN 2
  417. #define IL2CPP_BYTE_ORDER IL2CPP_LITTLE_ENDIAN
  418. #if (defined(_MSC_VER) && _MSC_VER > 1600) || (__has_feature(cxx_override_control))
  419. #define IL2CPP_OVERRIDE override
  420. #define IL2CPP_FINAL final
  421. #else
  422. #define IL2CPP_OVERRIDE
  423. #define IL2CPP_FINAL
  424. #endif
  425. #if (__has_feature(cxx_deleted_functions) || (defined(_MSC_VER) && _MSC_VER >= 1800))
  426. #define IL2CPP_HAS_DELETED_FUNCTIONS 1
  427. #else
  428. #define IL2CPP_HAS_DELETED_FUNCTIONS 0
  429. #endif
  430. #if IL2CPP_TARGET_WINDOWS
  431. static const Il2CppChar kIl2CppNewLine[] = { '\r', '\n', '\0' };
  432. #else
  433. static const Il2CppChar kIl2CppNewLine[] = { '\n', '\0' };
  434. #endif
  435. #define MAXIMUM_NESTED_GENERICS_EXCEPTION_MESSAGE "IL2CPP encountered a managed type which it cannot convert ahead-of-time. The type uses generic or array types which are nested beyond the maximum depth which can be converted. Consider increasing the --maximum-recursive-generic-depth=%d argument"
  436. #if IL2CPP_COMPILER_MSVC
  437. #define IL2CPP_ATTRIBUTE_WEAK
  438. #else
  439. #define IL2CPP_ATTRIBUTE_WEAK __attribute__((weak))
  440. #endif
  441. #if IL2CPP_TARGET_XBOXONE || IL2CPP_TARGET_WINRT || IL2CPP_TARGET_ANDROID || IL2CPP_TARGET_PS4 || IL2CPP_TARGET_PSP2
  442. #define IL2CPP_USE_GENERIC_CPU_INFO 1
  443. #else
  444. #define IL2CPP_USE_GENERIC_CPU_INFO 0
  445. #endif
  446. #if !defined(IL2CPP_CAN_CHECK_EXECUTABLE)
  447. #define IL2CPP_CAN_CHECK_EXECUTABLE IL2CPP_TARGET_WINDOWS || (IL2CPP_TARGET_POSIX && !IL2CPP_TARGET_PS4)
  448. #endif
  449. #if IL2CPP_MONO_DEBUGGER
  450. #define IL2CPP_DEBUG_BREAK() il2cpp::utils::Debugger::UserBreak()
  451. #else
  452. #ifdef _MSC_VER
  453. #define IL2CPP_DEBUG_BREAK() __debugbreak()
  454. #else
  455. #define IL2CPP_DEBUG_BREAK()
  456. #endif
  457. #endif
  458. #if defined(__cplusplus)
  459. template<typename Type, size_t Size>
  460. char(*il2cpp_array_size_helper(Type(&array)[Size]))[Size];
  461. #define IL2CPP_ARRAY_SIZE(array) (sizeof(*il2cpp_array_size_helper(array)))
  462. #endif // __cplusplus
  463. #ifndef IL2CPP_MUTATE_METHOD_POINTERS
  464. #define IL2CPP_MUTATE_METHOD_POINTERS !IL2CPP_TARGET_PS4
  465. #endif
  466. #define IL2CPP_USE_GENERIC_ASSERT !(IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_XBOXONE || IL2CPP_TARGET_WINRT || IL2CPP_TARGET_PS4 || IL2CPP_TARGET_PS5)
  467. #ifndef IL2CPP_USE_SPARSEHASH
  468. #define IL2CPP_USE_SPARSEHASH (IL2CPP_TARGET_ANDROID || IL2CPP_TARGET_IOS)
  469. #endif
  470. #if !IL2CPP_DEBUG
  471. #define IL2CPP_ASSERT(expr) void(0)
  472. #else
  473. #if defined(__cplusplus)
  474. #define IL2CPP_ASSERT(expr) (static_cast<bool>(expr) ? void(0) : il2cpp_assert(#expr, __FILE__, __LINE__))
  475. #else
  476. #define IL2CPP_ASSERT(expr) (expr) ? void(0) : il2cpp_assert(#expr, __FILE__, __LINE__))
  477. #endif
  478. extern void il2cpp_assert(const char* assertion, const char* file, unsigned int line);
  479. #endif
  480. #if !defined(IL2CPP_SUPPORTS_BROKERED_FILESYSTEM)
  481. #define IL2CPP_SUPPORTS_BROKERED_FILESYSTEM IL2CPP_TARGET_WINRT
  482. #endif