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.
This commit is contained in:
Yamagi Burmeister 2018-10-09 19:11:47 +02:00
parent cbe89b982a
commit 80ef326927
1 changed files with 2 additions and 1 deletions

View File

@ -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);