#ifndef __MMPRIVATE_H
#define __MMPRIVATE_H 1
-#include "mmalloc.h"
+#include "xbt/mmalloc.h"
#ifdef HAVE_LIMITS_H
# include <limits.h>
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) ((PTR) (addr) - (PTR) NULL))
+#define ADDR2UINT(addr) ((unsigned int) ((char*) (addr) - (char*) NULL))
#define RESIDUAL(addr,bsize) ((unsigned int) (ADDR2UINT (addr) % (bsize)))
/* Determine the amount of memory spanned by the initial heap table
/* Address to block number and vice versa. */
-#define BLOCK(A) (((PTR) (A) - mdp -> heapbase) / BLOCKSIZE + 1)
+#define BLOCK(A) (((char*) (A) - (char*) mdp -> heapbase) / BLOCKSIZE + 1)
-#define ADDRESS(B) ((PTR) (((B) - 1) * BLOCKSIZE + mdp -> heapbase))
+#define ADDRESS(B) ((void*) (((ADDR2UINT(B)) - 1) * BLOCKSIZE + (char*) mdp -> heapbase))
/* Data structure giving per-block information. */
struct alignlist
{
struct alignlist *next;
- PTR aligned; /* The address that mmemaligned returned. */
- PTR exact; /* The address that malloc returned. */
+ void* aligned; /* The address that mmemaligned returned. */
+ void* exact; /* The address that malloc returned. */
};
/* Doubly linked lists of free fragments. */
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));
+ void* (*morecore) (struct mdesc *mdp, int size);
/* Pointer to the function that causes an abort when the memory checking
features are activated. By default this is set to abort(), but can
FIXME: For mapped regions shared by more than one process, this
needs to be maintained on a per-process basis. */
- void (*abortfunc) PARAMS ((void));
+ void (*abortfunc) (void);
/* Debugging hook for free.
FIXME: For mapped regions shared by more than one process, this
needs to be maintained on a per-process basis. */
- void (*mfree_hook) PARAMS ((PTR, PTR));
+ void (*mfree_hook) (void* mdp, void* ptr);
/* Debugging hook for `malloc'.
FIXME: For mapped regions shared by more than one process, this
needs to be maintained on a per-process basis. */
- PTR (*mmalloc_hook) PARAMS ((PTR, size_t));
+ void* (*mmalloc_hook) (void* mdp, size_t size);
/* Debugging hook for realloc.
FIXME: For mapped regions shared by more than one process, this
needs to be maintained on a per-process basis. */
- PTR (*mrealloc_hook) PARAMS ((PTR, PTR, size_t));
+ void* (*mrealloc_hook) (void* mdp, void* ptr, size_t size);
/* Number of info entries. */
/* Pointer to first block of the heap (base of the first block). */
- PTR heapbase;
+ void* heapbase;
/* Current search index for the heap table. */
/* Search index in the info table. */
is the location where the bookkeeping data for mmap and for malloc
begins. */
- PTR base;
+ void* base;
/* The current location in the memory region for this malloc heap which
represents the end of memory in use. */
- PTR breakval;
+ void* breakval;
/* The end of the current memory region for this malloc heap. This is
the first location past the end of mapped memory. */
- PTR top;
+ void* top;
/* Open file descriptor for the file to which this malloc heap is mapped.
This will always be a valid file descriptor, since /dev/zero is used
/* An array of keys to data within the mapped region, for use by the
application. */
- PTR keys[MMALLOC_KEYS];
+ void* keys[MMALLOC_KEYS];
};
/* Internal version of `mfree' used in `morecore'. */
-extern void __mmalloc_free PARAMS ((struct mdesc *, PTR));
-
-/* Hooks for debugging versions. */
-
-extern void (*__mfree_hook) PARAMS ((PTR, PTR));
-extern PTR (*__mmalloc_hook) PARAMS ((PTR, size_t));
-extern PTR (*__mrealloc_hook) PARAMS ((PTR, PTR, size_t));
+extern void __mmalloc_free (struct mdesc *mdp, void* ptr);
/* A default malloc descriptor for the single sbrk() managed region. */
/* Initialize the first use of the default malloc descriptor, which uses
an sbrk() region. */
-extern struct mdesc *__mmalloc_sbrk_init PARAMS ((void));
+extern struct mdesc *__mmalloc_sbrk_init (void);
/* Grow or shrink a contiguous mapped region using mmap().
Works much like sbrk() */
#if defined(HAVE_MMAP)
-extern PTR __mmalloc_mmap_morecore PARAMS ((struct mdesc *, int));
+extern void* __mmalloc_mmap_morecore (struct mdesc *mdp, int size);
#endif
/* Remap a mmalloc region that was previously mapped. */
-extern PTR __mmalloc_remap_core PARAMS ((struct mdesc *));
+extern void* __mmalloc_remap_core (struct mdesc *mdp);
/* Macro to convert from a user supplied malloc descriptor to pointer to the
internal malloc descriptor. If the user supplied descriptor is NULL, then