Apple M1: OS version checking for MAP_JIT

- Added MacOS version checking around MAP_JIT to prepare code for x86 MAP_JIT
This commit is contained in:
Skyler Saleh 2021-04-17 16:18:18 -07:00
parent 948764d37b
commit 4542038cd0
1 changed files with 3 additions and 1 deletions

View File

@ -41,7 +41,9 @@ void* AllocateExecutableMemory(size_t size)
#else
int map_flags = MAP_ANON | MAP_PRIVATE;
#if defined(_M_ARM_64) && defined(__APPLE__)
map_flags |= MAP_JIT;
// This check is in place to prepare for x86_64 MAP_JIT support.
if (__builtin_available(macOS 10.14, *))
map_flags |= MAP_JIT;
#endif
void* ptr = mmap(nullptr, size, PROT_READ | PROT_WRITE | PROT_EXEC, map_flags, -1, 0);
if (ptr == MAP_FAILED)