/* 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
Contributed by Fred Fish at Cygnus Support. fnf@cygnus.com */
-#include "src/internal_config.h"
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
#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
*
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
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);