mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-13 05:01:13 +00:00
Fix ‘MADV_HUGEPAGE’ undeclared compilation error (#1012)
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.
This commit is contained in:
parent
9fc124b06f
commit
0d1060b3cc
|
@ -16,7 +16,7 @@ static size_t total_size_munmapped = 0;
|
||||||
|
|
||||||
#define HUGE_PAGE_SIZE (2 * 1024 * 1024)
|
#define HUGE_PAGE_SIZE (2 * 1024 * 1024)
|
||||||
|
|
||||||
#if !defined(__APPLE__) && !defined(__NuttX__)
|
#if !defined(__APPLE__) && !defined(__NuttX__) && defined(MADV_HUGEPAGE)
|
||||||
static inline uintptr_t
|
static inline uintptr_t
|
||||||
round_up(uintptr_t v, uintptr_t b)
|
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();
|
page_size = (uint64)getpagesize();
|
||||||
request_size = (size + page_size - 1) & ~(page_size - 1);
|
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 */
|
/* huge page isn't supported on MacOS and NuttX */
|
||||||
if (request_size >= HUGE_PAGE_SIZE)
|
if (request_size >= HUGE_PAGE_SIZE)
|
||||||
/* apply one extra huge page */
|
/* 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);
|
addr, request_size, total_size_mmapped, total_size_munmapped);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(__APPLE__) && !defined(__NuttX__)
|
#if !defined(__APPLE__) && !defined(__NuttX__) && defined(MADV_HUGEPAGE)
|
||||||
/* huge page isn't supported on MacOS and NuttX */
|
/* huge page isn't supported on MacOS and NuttX */
|
||||||
if (request_size > HUGE_PAGE_SIZE) {
|
if (request_size > HUGE_PAGE_SIZE) {
|
||||||
uintptr_t huge_start, huge_end;
|
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;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user