Fix compilation error on iOS due to macOS-specific API (#2995)

`pthread_jit_write_protect_np` is only available on macOS, and
`sys_icache_invalidate` is available on both iOS and macOS and
has no restrictions on ARM architecture.
This commit is contained in:
modest 2024-01-11 12:35:44 +08:00 committed by GitHub
parent ff25110840
commit 03a2af5095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -5,7 +5,7 @@
#include "platform_api_vmcore.h"
#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__)
#if defined(__APPLE__) || defined(__MACH__)
#include <libkern/OSCacheControl.h>
#endif
@ -40,7 +40,8 @@ void *
os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
{
int map_prot = PROT_NONE;
#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__)
#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__) \
&& defined(TARGET_OS_OSX) && TARGET_OS_OSX != 0
int map_flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_JIT;
#else
int map_flags = MAP_ANONYMOUS | MAP_PRIVATE;
@ -275,7 +276,7 @@ os_dcache_flush(void)
void
os_icache_flush(void *start, size_t len)
{
#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__)
#if defined(__APPLE__) || defined(__MACH__)
sys_icache_invalidate(start, len);
#endif
}

View File

@ -476,7 +476,8 @@ os_thread_get_stack_boundary()
void
os_thread_jit_write_protect_np(bool enabled)
{
#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__)
#if (defined(__APPLE__) || defined(__MACH__)) && defined(__arm64__) \
&& defined(TARGET_OS_OSX) && TARGET_OS_OSX != 0
pthread_jit_write_protect_np(enabled);
#endif
}