From 80ef3269276b1f479c0830fd5e44263c8c3cb64b Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 9 Oct 2018 19:11:47 +0200 Subject: [PATCH] Fix map loading on OS X. @DanielGibson pointed out that _SC_PAGESIZE itself is too big, _SC_PAGESIZE - 1 is correct. Also apply a small performance optimization by querying _SC_PAGESIZE only once. --- src/backends/unix/shared/hunk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backends/unix/shared/hunk.c b/src/backends/unix/shared/hunk.c index 924cc42e..1a2af9cd 100644 --- a/src/backends/unix/shared/hunk.c +++ b/src/backends/unix/shared/hunk.c @@ -99,7 +99,8 @@ Hunk_End(void) n = (byte *)mremap(membase, maxhunksize, curhunksize + sizeof(size_t), 0); #else #ifndef round_page - #define round_page(x) ((((size_t)(x)) + sysconf(_SC_PAGESIZE)) & ~(_SC_PAGESIZE)) + size_t page_size = sysconf(_SC_PAGESIZE); + #define round_page(x) ((((size_t)(x)) + page_size-1) & ~(page_size-1)) #endif size_t old_size = round_page(maxhunksize);