11#include "omDefaultConfig.h"
20#define OM_KEEP_REGIONS_ORDER
53 if (region->prev !=
NULL)
55 omAssume(region->prev != region && region->prev != region->next);
56 region->prev->next = region->next;
59 if (region->next !=
NULL)
61 omAssume(region->next != region && region->prev != region->next);
62 region->next->prev = region->prev;
69 insert->next = after->next;
82 insert->prev = before->prev;
95#define NEXT_PAGE(page) *((void**) page)
96#define OM_IS_EMPTY_REGION(region) ((region)->current == NULL && (region->init_addr == NULL))
145 OM_ALLOC_BINPAGE_HOOK;
160 if (region->init_pages >= how_many)
163 region->init_pages -= how_many;
164 if (region->init_pages)
165 region->init_addr += how_many*SIZEOF_SYSTEM_PAGE;
167 region->init_addr =
NULL;
174 if (region->next !=
NULL)
176 region = region->next;
181 region->next = new_region;
182 new_region->prev = region;
189 bin_page->region = region;
190 region->used_pages += how_many;
198 om_Info.AvailPages -= how_many;
202 OM_ALLOC_BINPAGE_HOOK;
210 region->used_pages -= how_many;
211 if (region->used_pages == 0)
215 if (region->next !=
NULL)
233 char* page = (
char *)bin_page;
237 NEXT_PAGE(page) = page + SIZEOF_SYSTEM_PAGE;
247 region->current = (
void*) bin_page;
249 om_Info.AvailPages += how_many;
251 OM_FREE_BINPAGE_HOOK;
261 current = region->current;
262 while (current !=
NULL)
275 if (current == region->current)
297 om_Info.InternalUsedBytesMalloc+=
sizeof(omBinPageRegion_t);
299 int pages = (min_pages>
om_Opts.PagesPerRegion ? min_pages :
om_Opts.PagesPerRegion);
300 size_t size = ((size_t)pages)*SIZEOF_SYSTEM_PAGE;
306 size = min_pages*SIZEOF_SYSTEM_PAGE;
312 region->pages = pages;
313 region->used_pages = 0;
314 region->init_addr = addr;
315 region->init_pages = pages;
316 region->current =
NULL;
334 om_Info.AvailPages -= region->pages;
340 om_Info.InternalUsedBytesMalloc-=
sizeof(omBinPageRegion_t);
351 unsigned long index_diff = high_index - low_index;
359 om_Info.InternalUsedBytesMalloc+=(index_diff + 1)*SIZEOF_LONG;
371 new_length*SIZEOF_LONG);
372 om_Info.InternalUsedBytesMalloc+= (new_length-old_length)*SIZEOF_LONG;
376 unsigned long offset = new_length - old_length;
393 char* high_addr = (
char *)low_addr + (pages-1)*SIZEOF_SYSTEM_PAGE;
401 if (low_index < high_index)
411 for (shift = low_index+1; shift < high_index; shift++)
428 while (high_index > shift)
440 char* high_addr = (
char *)low_addr + (pages-1)*SIZEOF_SYSTEM_PAGE;
445 if (low_index < high_index)
455 for (shift = low_index+1; shift < high_index; shift++)
472 while (high_index > shift)
497 if (region ==
iter)
return 1;
515 if (region->init_pages)
519 && region->init_addr <= region->addr + (region->pages -1)*SIZEOF_SYSTEM_PAGE));
521 region->addr + (region->pages - region->init_pages)*SIZEOF_SYSTEM_PAGE);
527 omListLength(region->current)+region->used_pages+region->init_pages != region->pages);
582 if (region ==
NULL)
return 0;
586 if ((
char *)addr >= region->addr
587 && (
char *)addr < region->addr + (region->pages)*SIZEOF_SYSTEM_PAGE)
589 region = region->next;
591 while (region !=
NULL);
597 char *c_addr=(
char *)addr;
600 if (region ==
NULL)
return 0;
603 if (c_addr > region->addr && c_addr < region->addr + (region->pages)*SIZEOF_SYSTEM_PAGE)
608 region = region->next;
610 while (region !=
NULL);
result insert(CFAFactor(LcF, 1, 1))
if(!FE_OPT_NO_SHELL_FLAG)(void) system(sys)
void * _omVallocFromSystem(size_t size, int fail)
void * omAllocFromSystem(size_t size)
void omVfreeToSystem(void *page, size_t size)
void omFreeSizeToSystem(void *addr, size_t size)
void * omReallocSizeFromSystem(void *addr, size_t oldsize, size_t newsize)
#define omVallocFromSystem(size)
omError_t omCheckBinPageRegions(int level, omError_t report, OM_FLR_DECL)
unsigned long om_MaxBinPageIndex
void omFreeBinPages(omBinPage bin_page, int how_many)
OM_INLINE_LOCAL void omInsertRegionAfter(omBinPageRegion insert, omBinPageRegion after)
#define OM_IS_EMPTY_REGION(region)
unsigned long om_MinBinPageIndex
static void omUnregisterBinPages(void *low_addr, int pages)
omBinPageRegion omFindRegionOfAddr(void *addr)
static omBinPageRegion om_CurrentBinPageRegion
static void omFreeBinPagesRegion(omBinPageRegion region)
int omIsKnownMemoryRegion(omBinPageRegion region)
omBinPage omAllocBinPages(int how_many)
omError_t omCheckBinPageRegion(omBinPageRegion region, int level, omError_t report, OM_FLR_DECL)
OM_INLINE_LOCAL void omInsertRegionBefore(omBinPageRegion insert, omBinPageRegion before)
static void omBinPageIndexFault(unsigned long low_index, unsigned long high_index)
static omBinPageRegion omAllocNewBinPagesRegion(int min_pages)
int omIsAddrOnFreeBinPage(void *addr)
omBinPage omAllocBinPage()
unsigned long * om_BinPageIndicies
static void * omTakeOutConsecutivePages(omBinPageRegion region, int how_many)
OM_INLINE_LOCAL void omTakeOutRegion(omBinPageRegion region)
static void omRegisterBinPages(void *low_addr, int pages)
#define omIsAddrPageAligned(addr)
#define omGetPageOfAddr(addr)
#define omGetPageShiftOfAddr(addr)
#define omGetPageIndexOfAddr(addr)
omError_t omCheckPtr(const void *ptr, omError_t report, OM_FLR_DECL)
#define omCheckReturnError(cond, error)
#define omCheckReturnCorrupted(cond)
#define omCheckReturn(cond)
#define omIsOnList(ptr, addr)
#define omCheckGList(ptr, next, level, report, OM_FLR_VAL)
#define omGListLength(ptr, next)
#define omListLength(ptr)
#define omGListLast(ptr, next)
#define omCheckList(ptr, level, report, OM_FLR_VAL)
omBinPageRegion_t * omBinPageRegion