/* Initialization for access to a mmap'd malloc managed region. */
-/* Copyright (c) 2012-2022. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2023. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
xbt_mheap_t mmalloc_preinit(void)
{
if (__mmalloc_default_mdp == NULL) {
- if (!mmalloc_pagesize)
- mmalloc_pagesize = getpagesize();
- unsigned long mask = ~((unsigned long)mmalloc_pagesize - 1);
+ unsigned long mmalloc_pagesize = (unsigned long)sysconf(_SC_PAGESIZE);
+ unsigned long mask = ~(mmalloc_pagesize - 1);
void* addr = (void*)(((unsigned long)sbrk(0) + HEAP_OFFSET) & mask);
__mmalloc_default_mdp = xbt_mheap_new(addr, XBT_MHEAP_OPTION_MEMSET);
}