From: Arnaud Giersch Date: Thu, 17 Jan 2019 08:21:51 +0000 (+0100) Subject: Remove unused bits from mmalloc. X-Git-Tag: v3_22~536 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/99c64fec9d54f28cfa4e27923d886020c1db26d3?hp=202b3c34671d1e0825b32532564366d3129d1422 Remove unused bits from mmalloc. --- diff --git a/src/include/xbt/mmalloc.h b/src/include/xbt/mmalloc.h index 4db71119f6..60e57c4963 100644 --- a/src/include/xbt/mmalloc.h +++ b/src/include/xbt/mmalloc.h @@ -51,18 +51,9 @@ XBT_PUBLIC void xbt_mheap_destroy_no_free(xbt_mheap_t md); XBT_PUBLIC void* xbt_mheap_destroy(xbt_mheap_t md); -/* return the heap used when NULL is passed as first argument to any mm* function */ -XBT_PUBLIC xbt_mheap_t mmalloc_get_default_md(void); - -/* To change the heap used when using the legacy version malloc/free/realloc and such */ -xbt_mheap_t mmalloc_set_current_heap(xbt_mheap_t new_heap); +/* To get the heap used when using the legacy version malloc/free/realloc and such */ xbt_mheap_t mmalloc_get_current_heap(void); -size_t mmalloc_get_bytes_used(xbt_mheap_t); -ssize_t mmalloc_get_busy_size(xbt_mheap_t, void* ptr); - -void* malloc_no_memset(size_t n); - #endif SG_END_DECL() diff --git a/src/xbt/mmalloc/mm_legacy.c b/src/xbt/mmalloc/mm_legacy.c index e18d68c5a5..7523018d3a 100644 --- a/src/xbt/mmalloc/mm_legacy.c +++ b/src/xbt/mmalloc/mm_legacy.c @@ -43,13 +43,6 @@ xbt_mheap_t mmalloc_get_current_heap(void) return __mmalloc_current_heap; } -xbt_mheap_t mmalloc_set_current_heap(xbt_mheap_t new_heap) -{ - xbt_mheap_t heap = __mmalloc_current_heap; - __mmalloc_current_heap = new_heap; - return heap; -} - /* Override the malloc-like functions if MC is activated at compile time */ #if SIMGRID_HAVE_MC @@ -155,28 +148,6 @@ XBT_ATTRIB_CONSTRUCTOR(101) static void mm_legacy_constructor() #define GET_HEAP() __mmalloc_current_heap -void* malloc_no_memset(size_t n) -{ - if (!mm_initialized) { - if (mm_initializing) - return mm_fake_malloc(n); - mm_legacy_constructor(); - } - - if (!__malloc_use_mmalloc) { - return mm_real_malloc(n); - } - - xbt_mheap_t mdp = GET_HEAP(); - if (!mdp) - return NULL; - - LOCK(mdp); - void *ret = mmalloc_no_memset(mdp, n); - UNLOCK(mdp); - return ret; -} - void *malloc(size_t n) { if (!mm_initialized) { diff --git a/src/xbt/mmalloc/mm_module.c b/src/xbt/mmalloc/mm_module.c index 9f960956a6..32aaddac6a 100644 --- a/src/xbt/mmalloc/mm_module.c +++ b/src/xbt/mmalloc/mm_module.c @@ -272,12 +272,6 @@ void *xbt_mheap_destroy(xbt_mheap_t mdp) * Try to increase this first if you experience strange errors under valgrind. */ #define HEAP_OFFSET (128UL<<20) -xbt_mheap_t mmalloc_get_default_md(void) -{ - xbt_assert(__mmalloc_default_mdp); - return __mmalloc_default_mdp; -} - static void mmalloc_fork_prepare(void) { xbt_mheap_t mdp = NULL; @@ -360,22 +354,3 @@ size_t mmalloc_get_bytes_used_remote(size_t heaplimit, const malloc_info* heapin } return bytes; } - -size_t mmalloc_get_bytes_used(const xbt_mheap_t heap){ - const struct mdesc* heap_data = (const struct mdesc *) heap; - return mmalloc_get_bytes_used_remote(heap_data->heaplimit, heap_data->heapinfo); -} - -ssize_t mmalloc_get_busy_size(xbt_mheap_t heap, void *ptr){ - - ssize_t block = ((char*)ptr - (char*)(heap->heapbase)) / BLOCKSIZE + 1; - if(heap->heapinfo[block].type < 0) - return -1; - else if(heap->heapinfo[block].type == MMALLOC_TYPE_UNFRAGMENTED) - return heap->heapinfo[block].busy_block.busy_size; - else{ - ssize_t frag = ((uintptr_t) (ADDR2UINT (ptr) % (BLOCKSIZE))) >> heap->heapinfo[block].type; - return heap->heapinfo[block].busy_frag.frag_size[frag]; - } - -} diff --git a/src/xbt/mmalloc/mmprivate.h b/src/xbt/mmalloc/mmprivate.h index 97841313e8..9e1c9b0e04 100644 --- a/src/xbt/mmalloc/mmprivate.h +++ b/src/xbt/mmalloc/mmprivate.h @@ -25,13 +25,6 @@ #include #include -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif - #ifdef HAVE_LIMITS_H # include #else @@ -65,7 +58,6 @@ * need to enlist the free fragments. */ -//#define SMALLEST_POSSIBLE_MALLOC (sizeof(struct list)) #define SMALLEST_POSSIBLE_MALLOC (16*sizeof(struct list)) #define MAX_FRAGMENT_PER_BLOCK (BLOCKSIZE / SMALLEST_POSSIBLE_MALLOC) @@ -160,14 +152,11 @@ typedef struct { struct { size_t nfree; /* Free fragments in a fragmented block. */ ssize_t frag_size[MAX_FRAGMENT_PER_BLOCK]; - //void *bt[MAX_FRAGMENT_PER_BLOCK][XBT_BACKTRACE_SIZE]; /* Where it was malloced (or realloced lastly) */ int ignore[MAX_FRAGMENT_PER_BLOCK]; } busy_frag; struct { size_t size; /* Size (in blocks) of a large cluster. */ size_t busy_size; /* Actually used space, in bytes */ - //void *bt[XBT_BACKTRACE_SIZE]; /* Where it was malloced (or realloced lastly) */ - //int bt_size; int ignore; } busy_block; /* Heap information for a free block (that may be the first of a free cluster). */ diff --git a/src/xbt/mmalloc/mrealloc.c b/src/xbt/mmalloc/mrealloc.c index 489dce3ff8..89360df661 100644 --- a/src/xbt/mmalloc/mrealloc.c +++ b/src/xbt/mmalloc/mrealloc.c @@ -14,6 +14,10 @@ #include "mmprivate.h" +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + /* Resize the given region to the new size, returning a pointer to the (possibly moved) region. This is optimized for * speed; some benchmarks seem to indicate that greater compactness is achieved by unconditionally allocating and * copying to a new region. This module has incestuous knowledge of the internals of both mfree and mmalloc. */