il2cpp-config.h 19 KB

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