From 144066156efebcf50b400b338f1c8dc3e180f0d7 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Tue, 26 May 2009 12:52:51 +0100 Subject: [PATCH] Patch for large 64 bit allocations (Jason Ganetsky). --- mmalloc/mmalloc.h | 2 +- mmalloc/mmap-sup.c | 7 ++++--- mmalloc/mmprivate.h | 10 +++++----- mmalloc/sbrk-sup.c | 6 +++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/mmalloc/mmalloc.h b/mmalloc/mmalloc.h index 082547e..bca67b9 100644 --- a/mmalloc/mmalloc.h +++ b/mmalloc/mmalloc.h @@ -57,6 +57,6 @@ extern int mmalloc_errno PARAMS ((PTR)); extern int mmtrace PARAMS ((void)); -extern PTR mmalloc_findbase PARAMS ((int)); +extern PTR mmalloc_findbase PARAMS ((size_t)); #endif /* MMALLOC_H */ diff --git a/mmalloc/mmap-sup.c b/mmalloc/mmap-sup.c index b12e43c..8f1e1fb 100644 --- a/mmalloc/mmap-sup.c +++ b/mmalloc/mmap-sup.c @@ -64,7 +64,7 @@ extern int getpagesize PARAMS ((void)); PTR __mmalloc_mmap_morecore (mdp, size) struct mdesc *mdp; - int size; + size_t size; { PTR result = NULL; off_t foffset; /* File offset at which new mapping will start */ @@ -169,7 +169,7 @@ __mmalloc_remap_core (mdp) PTR mmalloc_findbase (size) - int size; + size_t size; { int fd; int flags; @@ -205,7 +205,8 @@ mmalloc_findbase (size) to signal an error return, and besides, it is useful to catch NULL pointers if it is unmapped. Instead start at the next page boundary. */ - base = (caddr_t) getpagesize (); + size_t tmp_pagesize = getpagesize (); + base = (caddr_t) tmp_pagesize; } else if (base == (caddr_t) -1) { diff --git a/mmalloc/mmprivate.h b/mmalloc/mmprivate.h index 4576262..e1faa51 100644 --- a/mmalloc/mmprivate.h +++ b/mmalloc/mmprivate.h @@ -53,7 +53,7 @@ Boston, MA 02111-1307, USA. #define INT_BIT (CHAR_BIT * sizeof(int)) #define BLOCKLOG (INT_BIT > 16 ? 12 : 9) -#define BLOCKSIZE ((unsigned int) 1 << BLOCKLOG) +#define BLOCKSIZE ((size_t) 1L << BLOCKLOG) #define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) /* The difference between two pointers is a signed int. On machines where @@ -63,8 +63,8 @@ Boston, MA 02111-1307, USA. sign of the result is machine dependent for negative values, so force it to be treated as an unsigned int. */ -#define ADDR2UINT(addr) ((unsigned int) ((char *) (addr) - (char *) NULL)) -#define RESIDUAL(addr,bsize) ((unsigned int) (ADDR2UINT (addr) % (bsize))) +#define ADDR2UINT(addr) ((size_t) ((char *) (addr) - (char *) NULL)) +#define RESIDUAL(addr,bsize) ((size_t) (ADDR2UINT (addr) % (bsize))) /* Determine the amount of memory spanned by the initial heap table (not an absolute limit). */ @@ -191,7 +191,7 @@ struct mdesc FIXME: For mapped regions shared by more than one process, this needs to be maintained on a per-process basis. */ - PTR (*morecore) PARAMS ((struct mdesc *, int)); + PTR (*morecore) PARAMS ((struct mdesc *, size_t)); /* Pointer to the function that causes an abort when the memory checking features are activated. By default this is set to abort(), but can @@ -319,7 +319,7 @@ extern struct mdesc *__mmalloc_sbrk_init PARAMS ((void)); #if defined(HAVE_MMAP) -extern PTR __mmalloc_mmap_morecore PARAMS ((struct mdesc *, int)); +extern PTR __mmalloc_mmap_morecore PARAMS ((struct mdesc *, size_t)); #endif diff --git a/mmalloc/sbrk-sup.c b/mmalloc/sbrk-sup.c index 93c078b..e02749a 100644 --- a/mmalloc/sbrk-sup.c +++ b/mmalloc/sbrk-sup.c @@ -26,9 +26,9 @@ Boston, MA 02111-1307, USA. */ #include "mmprivate.h" -static PTR sbrk_morecore PARAMS ((struct mdesc *, int)); +static PTR sbrk_morecore PARAMS ((struct mdesc *, size_t)); #if NEED_DECLARATION_SBRK -extern PTR sbrk PARAMS ((int)); +extern PTR sbrk PARAMS ((size_t)); #endif /* The mmalloc() package can use a single implicit malloc descriptor @@ -44,7 +44,7 @@ struct mdesc *__mmalloc_default_mdp; static PTR sbrk_morecore (mdp, size) struct mdesc *mdp; - int size; + size_t size; { PTR result; -- 1.8.3.1