From 0d1060b3ccc15958fe14712d91f2bb160668d449 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Fri, 18 Feb 2022 12:25:06 +0900 Subject: [PATCH] =?UTF-8?q?Fix=20=E2=80=98MADV=5FHUGEPAGE=E2=80=99=20undec?= =?UTF-8?q?lared=20compilation=20error=20(#1012)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some Linux systems whose kernel version is smaller than 2.6.38, the macro MADV_HUGEPAGE isn't introduced yet which causes compilation error. Add macro control to fix the compilation error. --- core/shared/platform/common/posix/posix_memmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/shared/platform/common/posix/posix_memmap.c b/core/shared/platform/common/posix/posix_memmap.c index 3a22a506..2dfbee45 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; }