X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/66659ce0e491d1307cf48ec9f2da4f24c478ab46..417ed3b671abe3a71fa4106d23d0a432084cc207:/src/xbt/mmalloc/mmorecore.c diff --git a/src/xbt/mmalloc/mmorecore.c b/src/xbt/mmalloc/mmorecore.c index 0e7ce96609..a5f9ff52ac 100644 --- a/src/xbt/mmalloc/mmorecore.c +++ b/src/xbt/mmalloc/mmorecore.c @@ -1,6 +1,6 @@ /* Support for an sbrk-like function that uses mmap. */ -/* Copyright (c) 2010-2022. The SimGrid Team. +/* Copyright (c) 2010-2023. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -10,7 +10,6 @@ Contributed by Fred Fish at Cygnus Support. fnf@cygnus.com */ -#include "src/internal_config.h" #include #include #include @@ -23,7 +22,7 @@ #define MAP_ANONYMOUS MAP_ANON #endif -#define PAGE_ALIGN(addr) (void*)(((long)(addr) + mmalloc_pagesize - 1) & ~((long)mmalloc_pagesize - 1)) +#define PAGE_ALIGN(addr) (void*)(((unsigned long)(addr) + mmalloc_pagesize - 1) & ~(mmalloc_pagesize - 1)) /** @brief Add memory to this heap * @@ -48,9 +47,9 @@ void *mmorecore(struct mdesc *mdp, ssize_t size) return mdp->breakval; } - if (mmalloc_pagesize == 0) { // Not initialized yet - mmalloc_pagesize = (int)sysconf(_SC_PAGESIZE); - } + static unsigned long mmalloc_pagesize = 0; + if (!mmalloc_pagesize) + mmalloc_pagesize = (unsigned long)sysconf(_SC_PAGESIZE); if (size < 0) { /* We are deallocating memory. If the amount requested would cause us to try to deallocate back past the base of @@ -79,7 +78,7 @@ void *mmorecore(struct mdesc *mdp, ssize_t size) if (mapto == MAP_FAILED) { char buff[1024]; - fprintf(stderr, "Internal error: mmap returned MAP_FAILED! pagesize:%d error: %s\n", mmalloc_pagesize, + fprintf(stderr, "Internal error: mmap returned MAP_FAILED! pagesize:%lu error: %s\n", mmalloc_pagesize, strerror(errno)); snprintf(buff, 1024, "cat /proc/%d/maps", getpid()); int status = system(buff);