il2cpp-config.h 20 KB

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