X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fposix%2FOSMem.c;h=bfe12964a23cea2f5f13dda3e4f7dad432e0f371;hb=c5b178be60a5a44abd2f4ddf8c399857678326e2;hp=f8e484f982a71e425218d59393b73edcc7950739;hpb=e10324c192bb47ef4f7b3e3c53af7480902282fe;p=ghc-hetmet.git diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c index f8e484f..bfe1296 100644 --- a/rts/posix/OSMem.c +++ b/rts/posix/OSMem.c @@ -37,16 +37,7 @@ #include #endif -/* keep track of maps returned by my_mmap */ -typedef struct _map_rec { - char* base; /* base addr */ - int size; /* map size */ - struct _map_rec* next; /* next pointer */ -} map_rec; - - static caddr_t next_request = 0; -static map_rec* mmap_rec = NULL; void osMemInit(void) { @@ -187,7 +178,6 @@ osGetMBlocks(nat n) { caddr_t ret; lnat size = MBLOCK_SIZE * (lnat)n; - map_rec* rec; if (next_request == 0) { // use gen_map_mblocks the first time. @@ -209,11 +199,6 @@ osGetMBlocks(nat n) ret = gen_map_mblocks(size); } } - rec = (map_rec*)stgMallocBytes(sizeof(map_rec),"OSMem: osGetMBlocks"); - rec->size = size; - rec->base = ret; - rec->next = mmap_rec; - mmap_rec = rec; // Next time, we'll try to allocate right after the block we just got. // ToDo: check that we haven't already grabbed the memory at next_request next_request = ret + size; @@ -221,18 +206,23 @@ osGetMBlocks(nat n) return ret; } -void osFreeAllMBlocks(void) +void osFreeMBlocks(char *addr, nat n) { - map_rec* tmp = mmap_rec; - map_rec* next = NULL; + munmap(addr, n * MBLOCK_SIZE); +} - for(; tmp!=NULL;) { - if(munmap(tmp->base,tmp->size)) - barf("osFreeAllMBlocks: munmap failed!"); +void osReleaseFreeMemory(void) { + /* Nothing to do on POSIX */ +} + +void osFreeAllMBlocks(void) +{ + void *mblock; - next = tmp->next; - stgFree(tmp); - tmp = next; + for (mblock = getFirstMBlock(); + mblock != NULL; + mblock = getNextMBlock(mblock)) { + munmap(mblock, MBLOCK_SIZE); } }