-
- MC_SET_RAW_MEM;
-
-/* Get the start address and size of libsimgrid's data segment */
-/* CAVEAT: Here we are assuming several things, first that get_memory_map() */
-/* returns an array with the maps sorted from lower addresses to higher */
-/* ones. Second, that libsimgrid's data takes ONLY ONE page. */
- int i;
- char *libname, *tmp;
-
- /* Get memory map */
- memory_map_t maps;
- maps = get_memory_map();
-
- for(i=0; i < maps->mapsize; i++){
-
- if(maps->regions[i].inode != 0){
-
- tmp = xbt_strdup(maps->regions[i].pathname);
- libname = basename(tmp);
-
- if( strncmp("libsimgrid.so.2.0.0", libname, 18) == 0 && maps->regions[i].perms & MAP_WRITE){ //FIXME: do not hardcode
- libsimgrid_data_addr_start = maps->regions[i].start_addr;
- libsimgrid_data_size = (size_t)((char *)maps->regions[i+1].end_addr - (char *)maps->regions[i].start_addr);
- xbt_free(tmp);
- break;
- }
- xbt_free(tmp);
- }
- }
-
- xbt_assert0(libsimgrid_data_addr_start != NULL,
- "Cannot determine libsimgrid's .data segment address");
-
- MC_UNSET_RAW_MEM;
-}
-
-/* Finish the memory subsystem */
-void MC_memory_exit()
-{
- mmalloc_detach(std_heap);
- mmalloc_detach(raw_heap);
- actual_heap = NULL;
-}
-
-void *malloc(size_t n)
-{
- void *ret = mmalloc(actual_heap, n);
-
- DEBUG2("%zu bytes were allocated at %p",n, ret);
- return ret;
-}
-
-void *calloc(size_t nmemb, size_t size)
-{
- size_t total_size = nmemb * size;
- void *ret = mmalloc(actual_heap, total_size);
-
-/* Fill the allocated memory with zeroes to mimic calloc behaviour */
- memset(ret,'\0', total_size);
-
- DEBUG2("%zu bytes were mallocated and zeroed at %p",total_size, ret);
- return ret;
-}
-
-void *realloc(void *p, size_t s)
-{
- void *ret = NULL;
-
- if (s) {
- if (p)
- ret = mrealloc(actual_heap, p,s);
- else
- ret = malloc(s); /* FIXME: shouldn't this be mmalloc? */
- } else {
- if (p) {
- free(p);
- }
- }
-
- DEBUG2("%zu bytes were reallocated at %p",s,ret);
- return ret;