From ad695562522feac5197c19716dd91922f229cf32 Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Mon, 24 Nov 2014 22:31:52 +0000 Subject: [PATCH] [dlmalloc] correct definition of MMAP --- opt/dlmalloc/dlmalloc.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/opt/dlmalloc/dlmalloc.h b/opt/dlmalloc/dlmalloc.h index c846557..d2dda49 100644 --- a/opt/dlmalloc/dlmalloc.h +++ b/opt/dlmalloc/dlmalloc.h @@ -18,7 +18,13 @@ static void init_malloc_global_mutex(void) mtx_init(&malloc_global_mutex, mtx_plain); } -#define MMAP(s) _PDCLIB_allocpages((s)/_PDCLIB_MALLOC_PAGESIZE) +static inline void *MMAP( size_t nbytes ) +{ + void *p = _PDCLIB_allocpages( nbytes / _PDCLIB_MALLOC_PAGESIZE ); + return p ? p : (void*) (~(size_t)0); +} + +#define MMAP(s) MMAP(s) #define DIRECT_MMAP(s) MMAP(s) #define MUNMAP(a, s) ((_PDCLIB_freepages((a), (s)/_PDCLIB_MALLOC_PAGESIZE)), 0) #define MREMAP(a, osz, nsz, mv) _PDCLIB_reallocpages((a), (osz)/_PDCLIB_MALLOC_PAGESIZE, (nsz)/_PDCLIB_MALLOC_PAGESIZE, (mv)) @@ -67,7 +73,7 @@ static void init_malloc_global_mutex(void) #define MAX_RELEASE_CHECK_RATE _PDCLIB_MALLOC_RELEASE_CHECK_RATE /* C standard says this is so */ -#define REALLOC_ZERO_BYTES_FREES 1 +#define REALLOC_ZERO_BYTES_FREES 1 #define LACKS_UNISTD_H #define LACKS_FCNTL_H #define LACKS_SYS_PARAM_H -- 2.40.0