diff --git a/core/shared/platform/common/posix/posix_memmap.c b/core/shared/platform/common/posix/posix_memmap.c index 3a22a5064e..2dfbee453f 100644 --- a/core/shared/platform/common/posix/posix_memmap.c +++ b/core/shared/platform/common/posix/posix_memmap.c @@ -16,7 +16,7 @@ static size_t total_size_munmapped = 0; #define HUGE_PAGE_SIZE (2 * 1024 * 1024) -#if !defined(__APPLE__) && !defined(__NuttX__) +#if !defined(__APPLE__) && !defined(__NuttX__) && defined(MADV_HUGEPAGE) static inline uintptr_t round_up(uintptr_t v, uintptr_t b) { @@ -44,7 +44,7 @@ os_mmap(void *hint, size_t size, int prot, int flags) page_size = (uint64)getpagesize(); request_size = (size + page_size - 1) & ~(page_size - 1); -#if !defined(__APPLE__) && !defined(__NuttX__) +#if !defined(__APPLE__) && !defined(__NuttX__) && defined(MADV_HUGEPAGE) /* huge page isn't supported on MacOS and NuttX */ if (request_size >= HUGE_PAGE_SIZE) /* apply one extra huge page */ @@ -148,7 +148,7 @@ os_mmap(void *hint, size_t size, int prot, int flags) addr, request_size, total_size_mmapped, total_size_munmapped); #endif -#if !defined(__APPLE__) && !defined(__NuttX__) +#if !defined(__APPLE__) && !defined(__NuttX__) && defined(MADV_HUGEPAGE) /* huge page isn't supported on MacOS and NuttX */ if (request_size > HUGE_PAGE_SIZE) { uintptr_t huge_start, huge_end; @@ -200,7 +200,7 @@ os_mmap(void *hint, size_t size, int prot, int flags) } } } -#endif /* end of __APPLE__ || __NuttX__ */ +#endif /* end of __APPLE__ || __NuttX__ || !MADV_HUGEPAGE */ return addr; }