X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c5ad8ca1a68bbaa9152471c8d0eeb99d762f0d86..c40ca1c8de2080575f5b3a0de33a6d4bf6474f10:/src/xbt/mmalloc/mm_legacy.c diff --git a/src/xbt/mmalloc/mm_legacy.c b/src/xbt/mmalloc/mm_legacy.c index c75d10b9b6..1415ad6f64 100644 --- a/src/xbt/mmalloc/mm_legacy.c +++ b/src/xbt/mmalloc/mm_legacy.c @@ -13,6 +13,13 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_mm_legacy, xbt, "Logging specific to mm_legacy in mmalloc"); +/* The mmalloc() package can use a single implicit malloc descriptor + for mmalloc/mrealloc/mfree operations which do not supply an explicit + descriptor. This allows mmalloc() to provide + backwards compatibility with the non-mmap'd version. */ +struct mdesc *__mmalloc_default_mdp; + + static void *__mmalloc_current_heap = NULL; /* The heap we are currently using. */ #include "xbt_modinter.h" @@ -177,54 +184,13 @@ int mmalloc_compare_heap(void *h1, void *h2, void *std_heap_addr){ /* Heapstats */ - int errors = 0; - - struct mstats ms1 = mmstats(h1); - struct mstats ms2 = mmstats(h2); - - if(ms1.chunks_used != ms2.chunks_used){ - if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ - XBT_DEBUG("Different chunks allocated by the user : %zu - %zu", ms1.chunks_used, ms2.chunks_used); - errors++; - }else{ - return 1; - } - } - - if(ms1.bytes_used != ms2.bytes_used){ - if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ - XBT_DEBUG("Different byte total of user-allocated chunks : %zu - %zu", ms1.bytes_used, ms2.bytes_used); - errors++; - }else{ - return 1; - } - } - - if(ms1.bytes_free != ms2.bytes_free){ - if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ - XBT_DEBUG("Different byte total of chunks in the free list : %zu - %zu", ms1.bytes_free, ms2.bytes_free); - errors++; - }else{ - return 1; - } - } - - if(ms1.chunks_free != ms2.chunks_free){ - if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ - XBT_DEBUG("Different chunks in the free list : %zu - %zu", ms1.chunks_free, ms2.chunks_free); - errors++; - }else{ - return 1; - } - } - struct mdesc *mdp1, *mdp2; mdp1 = MD_TO_MDP(h1); mdp2 = MD_TO_MDP(h2); - int res = mmalloc_compare_mdesc(mdp1, mdp2, std_heap_addr); + int errors = mmalloc_compare_mdesc(mdp1, mdp2, std_heap_addr); - return ((errors + res ) > 0); + return (errors > 0); } @@ -345,16 +311,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void *std_heap } } - if(mdp1->saved_errno != mdp2->saved_errno){ - if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ - XBT_DEBUG("Different errno"); - errors++; - }else{ - return 1; - } - } - - if(mdp1->version != mdp2->version){ + if(mdp1->version != mdp2->version){ if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ XBT_DEBUG("Different version of the mmalloc package"); errors++; @@ -440,7 +397,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void *std_heap switch(mdp1->heapinfo[i].busy.type){ case 0 : - if(mdp1->heapinfo[i].busy.info.size != mdp2->heapinfo[i].busy.info.size){ + if(mdp1->heapinfo[i].busy.info.block.size != mdp2->heapinfo[i].busy.info.block.size){ if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ XBT_DEBUG("Different size of a large cluster"); errors++; @@ -448,16 +405,16 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void *std_heap return 1; } }else{ - if(memcmp(addr_block1, addr_block2, (mdp1->heapinfo[i].busy.info.size * BLOCKSIZE)) != 0){ + if(memcmp(addr_block1, addr_block2, (mdp1->heapinfo[i].busy.info.block.size * BLOCKSIZE)) != 0){ if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ - XBT_DEBUG("Different data in block %zu (size = %zu) (addr_block1 = %p (current = %p) - addr_block2 = %p)", i, mdp1->heapinfo[i].busy.info.size, addr_block1, (char *)std_heap_addr + sizeof(struct mdesc) + ((i-1) * BLOCKSIZE), addr_block2); + XBT_DEBUG("Different data in block %zu (size = %zu) (addr_block1 = %p (current = %p) - addr_block2 = %p)", i, mdp1->heapinfo[i].busy.info.block.size, addr_block1, (char *)std_heap_addr + sizeof(struct mdesc) + ((i-1) * BLOCKSIZE), addr_block2); errors++; }else{ return 1; } } } - i = i+mdp1->heapinfo[i].busy.info.size; + i = i+mdp1->heapinfo[i].busy.info.block.size; break; default : @@ -533,7 +490,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void *std_heap switch(mdp1->heapinfo[i].busy.type){ case 0 : - if(mdp1->heapinfo[i].busy.info.size != mdp2->heapinfo[i].busy.info.size){ + if(mdp1->heapinfo[i].busy.info.block.size != mdp2->heapinfo[i].busy.info.block.size){ if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ XBT_DEBUG("Different size of a large cluster"); errors++; @@ -541,7 +498,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void *std_heap return 1; } }else{ - if(memcmp(addr_block1, addr_block2, (mdp1->heapinfo[i].busy.info.size * BLOCKSIZE)) != 0){ + if(memcmp(addr_block1, addr_block2, (mdp1->heapinfo[i].busy.info.block.size * BLOCKSIZE)) != 0){ if(XBT_LOG_ISENABLED(xbt_mm_legacy, xbt_log_priority_debug)){ XBT_DEBUG("Different data in block %zu (addr_block1 = %p (current = %p) - addr_block2 = %p)", i, addr_block1, (char *)std_heap_addr + sizeof(struct mdesc) + ((i-1) * BLOCKSIZE), addr_block2); errors++; @@ -551,7 +508,7 @@ int mmalloc_compare_mdesc(struct mdesc *mdp1, struct mdesc *mdp2, void *std_heap } } - i = i+mdp1->heapinfo[i].busy.info.size; + i = i+mdp1->heapinfo[i].busy.info.block.size; break; default :