暫無描述
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.h 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  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. #if (IL2CPP_SUPPORT_THREADS && (!IL2CPP_THREADS_STD && !IL2CPP_THREADS_PTHREAD && !IL2CPP_THREADS_WIN32 && !IL2CPP_THREADS_N3DS && !IL2CPP_THREADS_PS4 && !IL2CPP_THREADS_PSP2 && !IL2CPP_THREADS_SWITCH && !IL2CPP_THREADS_CUSTOM))
  105. #error "No thread implementation defined"
  106. #endif
  107. /* Platform support to cleanup attached threads even when native threads are not exited cleanly */
  108. #define IL2CPP_HAS_NATIVE_THREAD_CLEANUP (IL2CPP_THREADS_PTHREAD || IL2CPP_THREADS_WIN32 || IL2CPP_TARGET_SWITCH)
  109. #define IL2CPP_THREAD_IMPL_HAS_COM_APARTMENTS IL2CPP_TARGET_WINDOWS
  110. #if !defined(IL2CPP_ENABLE_PLATFORM_THREAD_STACKSIZE) && IL2CPP_TARGET_IOS
  111. #define IL2CPP_ENABLE_PLATFORM_THREAD_STACKSIZE 1
  112. #endif
  113. #define IL2CPP_ENABLE_STACKTRACES !IL2CPP_TARGET_QNX
  114. /* Platforms which use OS specific implementation to extract stracktrace */
  115. #if !defined(IL2CPP_ENABLE_NATIVE_STACKTRACES)
  116. #define IL2CPP_ENABLE_NATIVE_STACKTRACES (IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_LINUX || IL2CPP_TARGET_DARWIN || IL2CPP_TARGET_IOS || IL2CPP_TARGET_ANDROID)
  117. #endif
  118. /* Platforms which support native IP emission to crash reporting to enable server-side reconstruction of C# exception stack trace line numbers */
  119. #if !defined(IL2CPP_ENABLE_NATIVE_INSTRUCTION_POINTER_EMISSION)
  120. #define IL2CPP_ENABLE_NATIVE_INSTRUCTION_POINTER_EMISSION (IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_LINUX || IL2CPP_TARGET_DARWIN || IL2CPP_TARGET_IOS || IL2CPP_TARGET_ANDROID)
  121. #endif
  122. #if IL2CPP_ENABLE_STACKTRACES
  123. /* Platforms which use stacktrace sentries */
  124. #if !defined(IL2CPP_ENABLE_STACKTRACE_SENTRIES)
  125. #define IL2CPP_ENABLE_STACKTRACE_SENTRIES (IL2CPP_TARGET_JAVASCRIPT || IL2CPP_TARGET_N3DS || IL2CPP_TARGET_SWITCH)
  126. #endif
  127. #endif // IL2CPP_ENABLE_STACKTRACES
  128. #if (IL2CPP_ENABLE_STACKTRACES && !IL2CPP_ENABLE_NATIVE_STACKTRACES && !IL2CPP_ENABLE_STACKTRACE_SENTRIES)
  129. #error "If stacktraces are supported, then either native stack traces must be supported, or usage of stacktrace sentries must be enabled!"
  130. #endif
  131. #if (IL2CPP_ENABLE_NATIVE_STACKTRACES + IL2CPP_ENABLE_STACKTRACE_SENTRIES) > 1
  132. #error "Only one type of stacktraces are allowed"
  133. #endif
  134. #define IL2CPP_CAN_USE_MULTIPLE_SYMBOL_MAPS IL2CPP_TARGET_IOS
  135. /* GC defines*/
  136. #define IL2CPP_GC_BOEHM 1
  137. #define IL2CPP_GC_NULL !IL2CPP_GC_BOEHM
  138. #define IL2CPP_ENABLE_DEFERRED_GC IL2CPP_TARGET_JAVASCRIPT
  139. /* we always need to NULL pointer free memory with our current allocators */
  140. #define NEED_TO_ZERO_PTRFREE 1
  141. #define IL2CPP_HAS_GC_DESCRIPTORS 1
  142. #if defined(_MSC_VER)
  143. #define IL2CPP_ZERO_LEN_ARRAY 0
  144. #else
  145. #define IL2CPP_ZERO_LEN_ARRAY 0
  146. #endif
  147. #if defined(_MSC_VER)
  148. #define IL2CPP_HAS_CXX_CONSTEXPR (_MSC_VER >= 1900)
  149. #else
  150. #define IL2CPP_HAS_CXX_CONSTEXPR (__has_feature (cxx_constexpr))
  151. #endif
  152. #if IL2CPP_HAS_CXX_CONSTEXPR
  153. #define COMPILE_TIME_CONST constexpr
  154. #else
  155. #define COMPILE_TIME_CONST const
  156. #endif
  157. /* clang specific __has_builtin check */
  158. #ifndef __has_builtin
  159. #define __has_builtin(x) 0 // Compatibility with non-clang compilers.
  160. #endif
  161. #if _MSC_VER
  162. #define IL2CPP_UNREACHABLE __assume(0)
  163. #elif __has_builtin(__builtin_unreachable) || IL2CPP_TARGET_QNX
  164. #define IL2CPP_UNREACHABLE __builtin_unreachable()
  165. #else
  166. #define IL2CPP_UNREACHABLE
  167. #endif
  168. typedef uint16_t Il2CppMethodSlot;
  169. static const uint16_t kInvalidIl2CppMethodSlot = 65535;
  170. /* Debug macros */
  171. #if defined(_MSC_VER) && _MSC_VER >= 1900 // UTF-8 literals are only supported in VS2015+
  172. // On MSVC, __FILE__ will expand to ANSI string literal and will fail to compile if there are unicode characters in the path
  173. // So we specify it to be UTF-8 literal explicitly
  174. #define MAKE_UTF8_LITERAL_HELPER(x) u8 ## x
  175. #define MAKE_UTF8_LITERAL(x) MAKE_UTF8_LITERAL_HELPER(x)
  176. #else
  177. #define MAKE_UTF8_LITERAL(x) x
  178. #endif
  179. #define __FILE_UTF8__ MAKE_UTF8_LITERAL(__FILE__)
  180. #define STRINGIZE(L) #L
  181. #define MAKE_STRING(M, L) M(L)
  182. #define $Line MAKE_STRING( STRINGIZE, __LINE__ )
  183. #define FIXME "FIXME: "
  184. #define ICALLMESSAGE(name) __FILE_UTF8__ "(" $Line ") : FIXME: Missing internal call implementation: " name
  185. #define RUNTIMEMESSAGE(name) __FILE_UTF8__ "(" $Line ") : FIXME: Missing runtime implementation: " name
  186. #define NOTSUPPORTEDICALLMESSAGE(target, name, reason) __FILE_UTF8__ "(" $Line ") : Unsupported internal call for " target ":" name " - " reason
  187. // Keeping this for future usage if needed.
  188. //#if defined(_MSC_VER)
  189. // #define PRAGMA_MESSAGE(value) __pragma(message(value))
  190. //#else
  191. // #define PRAGMA_MESSAGE(value) _Pragma(STRINGIZE(value))
  192. //#endif
  193. #define PRAGMA_MESSAGE(value)
  194. #if !defined(__EMSCRIPTEN__)
  195. #define IL2CPP_NOT_IMPLEMENTED_ICALL(func) \
  196. PRAGMA_MESSAGE(ICALLMESSAGE(#func)) \
  197. IL2CPP_ASSERT(0 && #func)
  198. #define IL2CPP_NOT_IMPLEMENTED_ICALL_NO_ASSERT(func, reason) \
  199. PRAGMA_MESSAGE(ICALLMESSAGE(#func))
  200. #define IL2CPP_NOT_IMPLEMENTED(func) \
  201. PRAGMA_MESSAGE(RUNTIMEMESSAGE(#func)) \
  202. IL2CPP_ASSERT(0 && #func)
  203. #define IL2CPP_NOT_IMPLEMENTED_NO_ASSERT(func, reason) \
  204. PRAGMA_MESSAGE(RUNTIMEMESSAGE(#func))
  205. #else
  206. #include <stdio.h>
  207. #include <emscripten/emscripten.h>
  208. // emscripten's assert will throw an exception in js.
  209. // For now, we don't want that, so just printf and move on.
  210. #define IL2CPP_NOT_IMPLEMENTED_ICALL(func) \
  211. PRAGMA_MESSAGE(message(ICALLMESSAGE(#func))) \
  212. emscripten_log(EM_LOG_NO_PATHS | EM_LOG_CONSOLE | EM_LOG_ERROR | EM_LOG_JS_STACK, "Not implemented icall: %s\n", #func);
  213. #define IL2CPP_NOT_IMPLEMENTED_ICALL_NO_ASSERT(func, reason) \
  214. PRAGMA_MESSAGE(message(ICALLMESSAGE(#func)))
  215. #define IL2CPP_NOT_IMPLEMENTED(func) \
  216. PRAGMA_MESSAGE(message(RUNTIMEMESSAGE(#func))) \
  217. printf("Not implemented: %s\n", #func);
  218. #define IL2CPP_NOT_IMPLEMENTED_NO_ASSERT(func, reason) \
  219. PRAGMA_MESSAGE(message(RUNTIMEMESSAGE(#func)))
  220. #endif
  221. #define NOT_SUPPORTED_IL2CPP(func, reason) \
  222. il2cpp::vm::Exception::Raise (il2cpp::vm::Exception::GetNotSupportedException ( NOTSUPPORTEDICALLMESSAGE ("IL2CPP", #func, #reason) ))
  223. #define NOT_SUPPORTED_SRE(func) \
  224. il2cpp::vm::Exception::Raise (il2cpp::vm::Exception::GetNotSupportedException ( NOTSUPPORTEDICALLMESSAGE ("IL2CPP", #func, "System.Reflection.Emit is not supported.") ))
  225. #define NOT_SUPPORTED_REMOTING(func) \
  226. il2cpp::vm::Exception::Raise (il2cpp::vm::Exception::GetNotSupportedException ( NOTSUPPORTEDICALLMESSAGE ("IL2CPP", #func, "System.Runtime.Remoting is not supported.") ))
  227. #if IL2CPP_TARGET_JAVASCRIPT
  228. #define NOT_SUPPORTED_WEBGL(func, reason) \
  229. il2cpp::vm::Exception::Raise (il2cpp::vm::Exception::GetNotSupportedException ( NOTSUPPORTEDICALLMESSAGE ("WebGL", #func, #reason) ))
  230. #else
  231. #define NOT_SUPPORTED_WEBGL(func, reason)
  232. #endif
  233. #if IL2CPP_COMPILER_MSVC
  234. #define IL2CPP_DIR_SEPARATOR '\\' /* backslash */
  235. #else
  236. #define IL2CPP_DIR_SEPARATOR '/' /* forward slash */
  237. #endif
  238. #ifndef IL2CPP_DISABLE_FULL_MESSAGES
  239. #define IL2CPP_DISABLE_FULL_MESSAGES 1
  240. #endif
  241. #if IL2CPP_COMPILER_MSVC
  242. #define IL2CPP_USE_GENERIC_SOCKET_IMPL 0
  243. #else
  244. #define IL2CPP_USE_GENERIC_SOCKET_IMPL !(IL2CPP_TARGET_POSIX || IL2CPP_TARGET_SWITCH || IL2CPP_SUPPORT_SOCKETS_POSIX_API)
  245. #endif
  246. #ifndef IL2CPP_USE_GENERIC_SOCKET_BRIDGE
  247. #define IL2CPP_USE_GENERIC_SOCKET_BRIDGE !IL2CPP_TARGET_JAVASCRIPT
  248. #endif
  249. /* Set by platforms that require special handling of SIGPIPE signalling during socket sends. */
  250. /* Is redefined by platform specific headers. Enabled for common Linux desktop platforms. */
  251. #ifndef IL2CPP_USE_SEND_NOSIGNAL
  252. #define IL2CPP_USE_SEND_NOSIGNAL IL2CPP_TARGET_LINUX
  253. #endif
  254. #ifndef IL2CPP_USE_GENERIC_ENVIRONMENT
  255. #define IL2CPP_USE_GENERIC_ENVIRONMENT (!IL2CPP_TARGET_WINDOWS && !IL2CPP_TARGET_POSIX)
  256. #endif
  257. #define IL2CPP_USE_GENERIC_COM (!IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_WINDOWS_GAMES)
  258. #define IL2CPP_USE_GENERIC_COM_SAFEARRAYS (!IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_WINDOWS_GAMES)
  259. #define IL2CPP_USE_GENERIC_WINDOWSRUNTIME (!IL2CPP_TARGET_WINDOWS || RUNTIME_NONE || IL2CPP_TARGET_WINDOWS_GAMES)
  260. #ifndef IL2CPP_USE_GENERIC_MEMORY_MAPPED_FILE
  261. #define IL2CPP_USE_GENERIC_MEMORY_MAPPED_FILE (IL2CPP_TARGET_WINDOWS_GAMES || IL2CPP_TARGET_JAVASCRIPT || (!IL2CPP_TARGET_WINDOWS && !IL2CPP_TARGET_POSIX))
  262. #endif
  263. #ifndef IL2CPP_HAS_CLOSE_EXEC
  264. #define IL2CPP_HAS_CLOSE_EXEC (IL2CPP_TARGET_POSIX && !IL2CPP_TARGET_PS4)
  265. #endif
  266. #ifndef IL2CPP_HAS_DUP
  267. #define IL2CPP_HAS_DUP (IL2CPP_TARGET_POSIX && !IL2CPP_TARGET_PS4)
  268. #endif
  269. #ifndef IL2CPP_USE_GENERIC_FILE
  270. #define IL2CPP_USE_GENERIC_FILE (!IL2CPP_TARGET_WINDOWS && !IL2CPP_TARGET_DARWIN)
  271. #endif
  272. #ifndef IL2CPP_USE_GENERIC_DEBUG_LOG
  273. #define IL2CPP_USE_GENERIC_DEBUG_LOG !IL2CPP_TARGET_WINDOWS
  274. #endif
  275. #ifndef IL2CPP_USE_GENERIC_PROCESS
  276. #define IL2CPP_USE_GENERIC_PROCESS 1
  277. #endif
  278. #ifndef IL2CPP_USE_GENERIC_THREAD
  279. #define IL2CPP_USE_GENERIC_THREAD (!IL2CPP_TARGET_WINDOWS && !IL2CPP_TARGET_POSIX && !IL2CPP_TARGET_DARWIN)
  280. #endif
  281. #define IL2CPP_SIZEOF_STRUCT_WITH_NO_INSTANCE_FIELDS 1
  282. #define IL2CPP_VALIDATE_FIELD_LAYOUT 0
  283. #if IL2CPP_MONO_DEBUGGER
  284. #define STORE_SEQ_POINT(storage, seqPoint) (storage).currentSequencePoint = seqPoint;
  285. #define STORE_TRY_ID(storage, id) (storage).tryId = id;
  286. #define CHECK_SEQ_POINT(storage, seqPoint) il2cpp_codegen_check_sequence_point(&(storage), seqPoint);
  287. #define CHECK_METHOD_ENTRY_SEQ_POINT(storage, seqPoint) il2cpp_codegen_check_sequence_point_entry(&(storage), seqPoint);
  288. #define CHECK_METHOD_EXIT_SEQ_POINT(name, storage, seqPoint) MethodExitSequencePointChecker name(&(storage), seqPoint);
  289. #define DECLARE_METHOD_THIS(variableName, thisAddress) void* variableName[] = { thisAddress }
  290. #define DECLARE_METHOD_PARAMS(variableName, ...) void* variableName[] = { __VA_ARGS__ }
  291. #define DECLARE_METHOD_LOCALS(variableName, ...) void* variableName[] = { __VA_ARGS__ }
  292. #define DECLARE_METHOD_EXEC_CTX(ctxVariable, method, thisVariable, paramsVariable, localsVariable) Il2CppSequencePointExecutionContext ctxVariable(method, thisVariable, paramsVariable, localsVariable)
  293. #define CHECK_PAUSE_POINT il2cpp_codegen_check_pause_point()
  294. #else
  295. #define STORE_SEQ_POINT(storage, seqPoint)
  296. #define STORE_TRY_ID(storage, id)
  297. #define CHECK_SEQ_POINT(storage, seqPoint)
  298. #define CHECK_METHOD_ENTRY_SEQ_POINT(storage, seqPoint)
  299. #define CHECK_METHOD_EXIT_SEQ_POINT(name, storage, seqPoint)
  300. #define DECLARE_METHOD_THIS(variableName, thisAddress)
  301. #define DECLARE_METHOD_PARAMS(variableName, ...)
  302. #define DECLARE_METHOD_LOCALS(variableName, ...)
  303. #define DECLARE_METHOD_EXEC_CTX(ctxVariable, method, thisVariable, paramsVariable, localsVariable)
  304. #define CHECK_PAUSE_POINT
  305. #endif
  306. #ifdef __cplusplus
  307. template<bool value>
  308. struct Il2CppStaticAssertHelper;
  309. template<>
  310. struct Il2CppStaticAssertHelper<true>
  311. {
  312. };
  313. #define Assert(x) do { (void)(x); IL2CPP_ASSERT(x); } while (false)
  314. #define Il2CppStaticAssert(...) do { Il2CppStaticAssertHelper<(__VA_ARGS__)>(); } while (false)
  315. #endif
  316. static const int32_t kIl2CppInt32Min = INT32_MIN;
  317. static const int32_t kIl2CppInt32Max = INT32_MAX;
  318. static const uint32_t kIl2CppUInt32Max = UINT32_MAX;
  319. static const int64_t kIl2CppInt64Min = INT64_MIN;
  320. static const int64_t kIl2CppInt64Max = INT64_MAX;
  321. static const uint64_t kIl2CppUInt64Max = UINT64_MAX;
  322. #if IL2CPP_SIZEOF_VOID_P == 8
  323. static const intptr_t kIl2CppIntPtrMin = INT64_MIN;
  324. static const intptr_t kIl2CppIntPtrMax = INT64_MAX;
  325. static const uintptr_t kIl2CppUIntPtrMax = UINT64_MAX;
  326. #else
  327. static const intptr_t kIl2CppIntPtrMin = INT32_MIN;
  328. static const intptr_t kIl2CppIntPtrMax = INT32_MAX;
  329. static const uintptr_t kIl2CppUIntPtrMax = UINT32_MAX;
  330. #endif
  331. static const int ipv6AddressSize = 16;
  332. #if !defined(IL2CPP_SUPPORT_IPV6)
  333. #define IL2CPP_SUPPORT_IPV6 !IL2CPP_TARGET_PS4 && !IL2CPP_TARGET_SWITCH
  334. #endif
  335. #define IL2CPP_SUPPORT_IPV6_SUPPORT_QUERY (IL2CPP_SUPPORT_IPV6 && IL2CPP_TARGET_LINUX)
  336. #if !defined(IL2CPP_SUPPORT_SEND_FILE)
  337. #define IL2CPP_SUPPORT_SEND_FILE (!IL2CPP_TARGET_SWITCH && !IL2CPP_TARGET_JAVASCRIPT)
  338. #endif
  339. #if !defined(IL2CPP_SUPPORT_RECV_MSG)
  340. #define IL2CPP_SUPPORT_RECV_MSG (!IL2CPP_TARGET_SWITCH)
  341. #endif
  342. #if !defined(IL2CPP_SUPPORT_SEND_MSG)
  343. #define IL2CPP_SUPPORT_SEND_MSG (!IL2CPP_TARGET_SWITCH)
  344. #endif
  345. #ifndef IL2CPP_USE_NETWORK_ACCESS_HANDLER
  346. #define IL2CPP_USE_NETWORK_ACCESS_HANDLER 0
  347. #endif
  348. // Android: "There is no support for locales in the C library" https://code.google.com/p/android/issues/detail?id=57313
  349. // PS4/PS2: strtol_d doesn't exist
  350. #if !defined(IL2CPP_SUPPORT_LOCALE_INDEPENDENT_PARSING)
  351. #define IL2CPP_SUPPORT_LOCALE_INDEPENDENT_PARSING (!IL2CPP_TARGET_QNX && !IL2CPP_TARGET_ANDROID && !IL2CPP_TARGET_PS4 && !IL2CPP_TARGET_PSP2)
  352. #endif
  353. #define NO_UNUSED_WARNING(expr) (void)(expr)
  354. typedef int32_t il2cpp_hresult_t;
  355. // Sorted numerically!
  356. #define IL2CPP_S_OK ((il2cpp_hresult_t)0)
  357. #define IL2CPP_S_FALSE ((il2cpp_hresult_t)1)
  358. #define IL2CPP_E_BOUNDS ((il2cpp_hresult_t)0x8000000B)
  359. #define IL2CPP_E_CHANGED_STATE ((il2cpp_hresult_t)0x8000000C)
  360. #define IL2CPP_E_ILLEGAL_METHOD_CALL ((il2cpp_hresult_t)0x8000000E)
  361. #define IL2CPP_RO_E_CLOSED ((il2cpp_hresult_t)0x80000013)
  362. #define IL2CPP_E_NOTIMPL ((il2cpp_hresult_t)0x80004001)
  363. #define IL2CPP_E_NOINTERFACE ((il2cpp_hresult_t)0x80004002)
  364. #define IL2CPP_E_POINTER ((il2cpp_hresult_t)0x80004003)
  365. #define IL2CPP_E_ABORT ((il2cpp_hresult_t)0x80004004)
  366. #define IL2CPP_E_FAIL ((il2cpp_hresult_t)0x80004005)
  367. #define IL2CPP_E_UNEXPECTED ((il2cpp_hresult_t)0x8000FFFF)
  368. #define IL2CPP_RPC_E_DISCONNECTED ((il2cpp_hresult_t)0x80010108)
  369. #define IL2CPP_RPC_E_WRONG_THREAD ((il2cpp_hresult_t)0x8001010E)
  370. #define IL2CPP_DISP_E_PARAMNOTFOUND ((il2cpp_hresult_t)0x80020004)
  371. #define IL2CPP_REGDB_E_CLASSNOTREG ((il2cpp_hresult_t)0x80040154)
  372. #define IL2CPP_E_FILE_NOT_FOUND ((il2cpp_hresult_t)0x80070002)
  373. #define IL2CPP_E_ACCESS_DENIED ((il2cpp_hresult_t)0x80070005)
  374. #define IL2CPP_E_OUTOFMEMORY ((il2cpp_hresult_t)0x8007000E)
  375. #define IL2CPP_E_INVALIDARG ((il2cpp_hresult_t)0x80070057)
  376. #define IL2CPP_COR_E_EXCEPTION ((il2cpp_hresult_t)0x80131500)
  377. #define IL2CPP_COR_E_EXECUTIONENGINE ((il2cpp_hresult_t)0x80131506)
  378. #define IL2CPP_COR_E_INVALIDOPERATION ((il2cpp_hresult_t)0x80131509)
  379. #define IL2CPP_COR_E_PLATFORMNOTSUPPORTED ((il2cpp_hresult_t)0x80131539)
  380. #define IL2CPP_COR_E_OPERATIONCANCELED ((il2cpp_hresult_t)0x8013153B)
  381. #define IL2CPP_COR_E_OBJECTDISPOSED ((il2cpp_hresult_t)0x80131622)
  382. #define IL2CPP_HR_SUCCEEDED(hr) (((il2cpp_hresult_t)(hr)) >= 0)
  383. #define IL2CPP_HR_FAILED(hr) (((il2cpp_hresult_t)(hr)) < 0)
  384. #define IL2CPP_LITTLE_ENDIAN 1
  385. #define IL2CPP_BIG_ENDIAN 2
  386. #define IL2CPP_BYTE_ORDER IL2CPP_LITTLE_ENDIAN
  387. #if (defined(_MSC_VER) && _MSC_VER > 1600) || (__has_feature(cxx_override_control))
  388. #define IL2CPP_OVERRIDE override
  389. #define IL2CPP_FINAL final
  390. #else
  391. #define IL2CPP_OVERRIDE
  392. #define IL2CPP_FINAL
  393. #endif
  394. #if (__has_feature(cxx_deleted_functions) || (defined(_MSC_VER) && _MSC_VER >= 1800))
  395. #define IL2CPP_HAS_DELETED_FUNCTIONS 1
  396. #else
  397. #define IL2CPP_HAS_DELETED_FUNCTIONS 0
  398. #endif
  399. #if IL2CPP_TARGET_WINDOWS
  400. static const Il2CppChar kIl2CppNewLine[] = { '\r', '\n', '\0' };
  401. #else
  402. static const Il2CppChar kIl2CppNewLine[] = { '\n', '\0' };
  403. #endif
  404. #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"
  405. #if IL2CPP_COMPILER_MSVC
  406. #define IL2CPP_ATTRIBUTE_WEAK
  407. #else
  408. #define IL2CPP_ATTRIBUTE_WEAK __attribute__((weak))
  409. #endif
  410. #if IL2CPP_TARGET_ANDROID || IL2CPP_TARGET_PS4 || IL2CPP_TARGET_PSP2
  411. #define IL2CPP_USE_GENERIC_CPU_INFO 1
  412. #else
  413. #define IL2CPP_USE_GENERIC_CPU_INFO 0
  414. #endif
  415. #if !defined(IL2CPP_CAN_CHECK_EXECUTABLE)
  416. #define IL2CPP_CAN_CHECK_EXECUTABLE IL2CPP_TARGET_WINDOWS || (IL2CPP_TARGET_POSIX && !IL2CPP_TARGET_PS4)
  417. #endif
  418. #if IL2CPP_MONO_DEBUGGER
  419. #define IL2CPP_DEBUG_BREAK() il2cpp::utils::Debugger::UserBreak()
  420. #else
  421. #ifdef _MSC_VER
  422. #define IL2CPP_DEBUG_BREAK() __debugbreak()
  423. #else
  424. #define IL2CPP_DEBUG_BREAK()
  425. #endif
  426. #endif
  427. #if defined(__cplusplus)
  428. template<typename Type, size_t Size>
  429. char(*il2cpp_array_size_helper(Type(&array)[Size]))[Size];
  430. #define IL2CPP_ARRAY_SIZE(array) (sizeof(*il2cpp_array_size_helper(array)))
  431. #endif // __cplusplus
  432. #ifndef IL2CPP_MUTATE_METHOD_POINTERS
  433. #define IL2CPP_MUTATE_METHOD_POINTERS !IL2CPP_TARGET_PS4
  434. #endif
  435. #define IL2CPP_USE_GENERIC_ASSERT !(IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_PS4 || IL2CPP_TARGET_PS5)
  436. #ifndef IL2CPP_USE_SPARSEHASH
  437. #define IL2CPP_USE_SPARSEHASH (IL2CPP_TARGET_ANDROID || IL2CPP_TARGET_IOS)
  438. #endif
  439. #if !IL2CPP_DEBUG
  440. #define IL2CPP_ASSERT(expr) void(0)
  441. #else
  442. #if defined(__cplusplus)
  443. #define IL2CPP_ASSERT(expr) (static_cast<bool>(expr) ? void(0) : il2cpp_assert(#expr, __FILE__, __LINE__))
  444. #else
  445. #define IL2CPP_ASSERT(expr) (expr) ? void(0) : il2cpp_assert(#expr, __FILE__, __LINE__))
  446. #endif
  447. extern void il2cpp_assert(const char* assertion, const char* file, unsigned int line);
  448. #endif
  449. #if !defined(IL2CPP_SUPPORTS_BROKERED_FILESYSTEM)
  450. #define IL2CPP_SUPPORTS_BROKERED_FILESYSTEM IL2CPP_TARGET_WINRT
  451. #endif