Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / src / xbt / mmalloc / mm_module.c
index 1eca509..f4bd97a 100644 (file)
@@ -1,6 +1,6 @@
 /* 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. */
@@ -141,9 +141,8 @@ void *xbt_mheap_destroy(xbt_mheap_t mdp)
 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);
   }