Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove unused bits from mmalloc.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 17 Jan 2019 08:21:51 +0000 (09:21 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 17 Jan 2019 16:10:15 +0000 (17:10 +0100)
src/include/xbt/mmalloc.h
src/xbt/mmalloc/mm_legacy.c
src/xbt/mmalloc/mm_module.c
src/xbt/mmalloc/mmprivate.h
src/xbt/mmalloc/mrealloc.c

index 4db7111..60e57c4 100644 (file)
@@ -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()
 
index e18d68c..7523018 100644 (file)
@@ -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) {
index 9f96095..32aadda 100644 (file)
@@ -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];
-  }
-
-}
index 9784131..9e1c9b0 100644 (file)
 #include <pthread.h>
 #include <stdint.h>
 
-#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 <limits.h>
 #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).  */
index 489dce3..89360df 100644 (file)
 
 #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. */