From a9dda0de1ef7c428209ca9faa19b0b1edb01bf97 Mon Sep 17 00:00:00 2001 From: Juergen Beisert Date: Thu, 10 Dec 2009 13:09:02 +0100 Subject: Remove win32 support Remove never used code. Signed-off-by: Juergen Beisert --- common/dlmalloc.c | 186 ------------------------------------------------------ 1 file changed, 186 deletions(-) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index c3e81ccfdd..3f618c86ef 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -628,192 +628,6 @@ struct mallinfo { #define malloc_getpagesize 4096 -/* - Emulation of sbrk for WIN32 - All code within the ifdef WIN32 is untested by me. - - Thanks to Martin Fong and others for supplying this. -*/ - - -#ifdef WIN32 - -#define AlignPage(add) (((add) + (malloc_getpagesize-1)) & \ -~(malloc_getpagesize-1)) -#define AlignPage64K(add) (((add) + (0x10000 - 1)) & ~(0x10000 - 1)) - -/* resrve 64MB to insure large contiguous space */ -#define RESERVED_SIZE (1024*1024*64) -#define NEXT_SIZE (2048*1024) -#define TOP_MEMORY ((unsigned long)2*1024*1024*1024) - -struct GmListElement; -typedef struct GmListElement GmListElement; - -struct GmListElement -{ - GmListElement* next; - void* base; -}; - -static GmListElement* head = 0; -static unsigned int gNextAddress = 0; -static unsigned int gAddressBase = 0; -static unsigned int gAllocatedSize = 0; - -static -GmListElement* makeGmListElement (void* bas) -{ - GmListElement* this; - this = (GmListElement*)(void*)LocalAlloc (0, sizeof (GmListElement)); - if (this) - { - this->base = bas; - this->next = head; - head = this; - } - return this; -} - -void gcleanup () -{ - BOOL rval; - if (gAddressBase && (gNextAddress - gAddressBase)) - { - rval = VirtualFree ((void*)gAddressBase, - gNextAddress - gAddressBase, - MEM_DECOMMIT); - } - while (head) - { - GmListElement* next = head->next; - rval = VirtualFree (head->base, 0, MEM_RELEASE); - LocalFree (head); - head = next; - } -} - -static -void* findRegion (void* start_address, unsigned long size) -{ - MEMORY_BASIC_INFORMATION info; - if (size >= TOP_MEMORY) return NULL; - - while ((unsigned long)start_address + size < TOP_MEMORY) - { - VirtualQuery (start_address, &info, sizeof (info)); - if ((info.State == MEM_FREE) && (info.RegionSize >= size)) - return start_address; - else - { - /* Requested region is not available so see if the */ - /* next region is available. Set 'start_address' */ - /* to the next region and call 'VirtualQuery()' */ - /* again. */ - - start_address = (char*)info.BaseAddress + info.RegionSize; - - /* Make sure we start looking for the next region */ - /* on the *next* 64K boundary. Otherwise, even if */ - /* the new region is free according to */ - /* 'VirtualQuery()', the subsequent call to */ - /* 'VirtualAlloc()' (which follows the call to */ - /* this routine in 'wsbrk()') will round *down* */ - /* the requested address to a 64K boundary which */ - /* we already know is an address in the */ - /* unavailable region. Thus, the subsequent call */ - /* to 'VirtualAlloc()' will fail and bring us back */ - /* here, causing us to go into an infinite loop. */ - - start_address = - (void *) AlignPage64K((unsigned long) start_address); - } - } - return NULL; - -} - - -void* wsbrk (long size) -{ - void* tmp; - if (size > 0) - { - if (gAddressBase == 0) - { - gAllocatedSize = max (RESERVED_SIZE, AlignPage (size)); - gNextAddress = gAddressBase = - (unsigned int)VirtualAlloc (NULL, gAllocatedSize, - MEM_RESERVE, PAGE_NOACCESS); - } else if (AlignPage (gNextAddress + size) > (gAddressBase + -gAllocatedSize)) - { - long new_size = max (NEXT_SIZE, AlignPage (size)); - void* new_address = (void*)(gAddressBase+gAllocatedSize); - do - { - new_address = findRegion (new_address, new_size); - - if (new_address == 0) - return (void*)-1; - - gAddressBase = gNextAddress = - (unsigned int)VirtualAlloc (new_address, new_size, - MEM_RESERVE, PAGE_NOACCESS); - /* repeat in case of race condition */ - /* The region that we found has been snagged */ - /* by another thread */ - } - while (gAddressBase == 0); - - gAllocatedSize = new_size; - - if (!makeGmListElement ((void*)gAddressBase)) - return (void*)-1; - } - if ((size + gNextAddress) > AlignPage (gNextAddress)) - { - void* res; - res = VirtualAlloc ((void*)AlignPage (gNextAddress), - (size + gNextAddress - - AlignPage (gNextAddress)), - MEM_COMMIT, PAGE_READWRITE); - if (res == 0) - return (void*)-1; - } - tmp = (void*)gNextAddress; - gNextAddress = (unsigned int)tmp + size; - return tmp; - } - else if (size < 0) - { - unsigned int alignedGoal = AlignPage (gNextAddress + size); - /* Trim by releasing the virtual memory */ - if (alignedGoal >= gAddressBase) - { - VirtualFree ((void*)alignedGoal, gNextAddress - alignedGoal, - MEM_DECOMMIT); - gNextAddress = gNextAddress + size; - return (void*)gNextAddress; - } - else - { - VirtualFree ((void*)gAddressBase, gNextAddress - gAddressBase, - MEM_DECOMMIT); - gNextAddress = gAddressBase; - return (void*)-1; - } - } - else - { - return (void*)gNextAddress; - } -} - -#endif - - - /* Type declarations */ -- cgit v1.2.3