Loading...
Searching...
No Matches
omBinPage.h File Reference

Go to the source code of this file.

## Macros

#define | omIsAddrPageAligned(addr)
#define | omGetPageOfAddr(addr)
#define | omGetBinPageOfAddr(addr)
#define | omIsAddrOnPage(addr, page)
#define | omAreAddrOnSamePage(a1, a2)
#define | OM_SIZEOF_INDEX_PAGE (((unsigned long) SIZEOF_SYSTEM_PAGE) << LOG_BIT_SIZEOF_LONG)
#define | omGetPageShiftOfAddr(addr)
#define | omGetPageIndexOfAddr(addr)
#define | omIsBinPageAddr(addr)
#define | omFreeBinPage(addr)

## Functions

omBinPage | omAllocBinPages (int how_many)
omBinPage | omAllocBinPage (void)
void | omFreeBinPages (omBinPage page, int how_many)

## Variables

unsigned long | om_MaxBinPageIndex
unsigned long | om_MinBinPageIndex
unsigned long * | om_BinPageIndicies

## Macro Definition Documentation

## OM_SIZEOF_INDEX_PAGE

#define OM_SIZEOF_INDEX_PAGE (((unsigned long) SIZEOF_SYSTEM_PAGE) << LOG_BIT_SIZEOF_LONG)

Definition at line 58 of file omBinPage.h.

## omAreAddrOnSamePage

#define omAreAddrOnSamePage | ( |  | a1,
|  |  | a2 )

Value:
(omGetPageOfAddr(a1) == omGetPageOfAddr(a2))
omGetPageOfAddr
#define omGetPageOfAddr(addr)
Definition omBinPage.h:19

Definition at line 27 of file omBinPage.h.

#define omAreAddrOnSamePage(a1, a2) \
(omGetPageOfAddr(a1) == omGetPageOfAddr(a2))

## omFreeBinPage

#define omFreeBinPage | ( |  | addr | ) |

Value:
omFreeBinPages(addr, 1)
omFreeBinPages
void omFreeBinPages(omBinPage bin_page, int how_many)
Definition omBinPage.c:206

Definition at line 88 of file omBinPage.h.

## omGetBinPageOfAddr

#define omGetBinPageOfAddr | ( |  | addr | ) |

Value:
((omBinPage) ((long) (addr) & ~(SIZEOF_SYSTEM_PAGE -1)))
omBinPage
omBinPage_t * omBinPage
Definition omStructs.h:16

Definition at line 22 of file omBinPage.h.

#define omGetBinPageOfAddr(addr) \
((omBinPage) ((long) (addr) & ~(SIZEOF_SYSTEM_PAGE -1)))

## omGetPageIndexOfAddr

#define omGetPageIndexOfAddr | ( |  | addr | ) |

Value:
(((unsigned long) addr) >> (LOG_BIT_SIZEOF_LONG + LOG_BIT_SIZEOF_SYSTEM_PAGE))

Definition at line 63 of file omBinPage.h.

#define omGetPageIndexOfAddr(addr) \
(((unsigned long) addr) >> (LOG_BIT_SIZEOF_LONG + LOG_BIT_SIZEOF_SYSTEM_PAGE))

## omGetPageOfAddr

#define omGetPageOfAddr | ( |  | addr | ) |

Value:
((void*) (((long)addr) & ~(SIZEOF_SYSTEM_PAGE -1)))

Definition at line 19 of file omBinPage.h.

#define omGetPageOfAddr(addr) \
((void*) (((long)addr) & ~(SIZEOF_SYSTEM_PAGE -1)))

## omGetPageShiftOfAddr

#define omGetPageShiftOfAddr | ( |  | addr | ) |

Value:
((((unsigned long) addr) & (OM_SIZEOF_INDEX_PAGE -1)) >> LOG_BIT_SIZEOF_SYSTEM_PAGE)
OM_SIZEOF_INDEX_PAGE
#define OM_SIZEOF_INDEX_PAGE
Definition omBinPage.h:58

Definition at line 60 of file omBinPage.h.

#define omGetPageShiftOfAddr(addr) \
((((unsigned long) addr) & (OM_SIZEOF_INDEX_PAGE -1)) >> LOG_BIT_SIZEOF_SYSTEM_PAGE)

## omIsAddrOnPage

#define omIsAddrOnPage | ( |  | addr,
|  |  | page )

Value:
(omGetPageOfAddr(addr) == (void*) (page))

Definition at line 25 of file omBinPage.h.

## omIsAddrPageAligned

#define omIsAddrPageAligned | ( |  | addr | ) |

Value:
(((long) (addr) & (SIZEOF_SYSTEM_PAGE -1)) == 0)

Definition at line 16 of file omBinPage.h.

#define omIsAddrPageAligned(addr) \
(((long) (addr) & (SIZEOF_SYSTEM_PAGE -1)) == 0)

## omIsBinPageAddr

#define omIsBinPageAddr | ( |  | addr | ) |

Value:
_omIsBinPageAddr(addr)
_omIsBinPageAddr
OM_INLINE_DECL int _omIsBinPageAddr(const void *addr)

Definition at line 68 of file omBinPage.h.

## Function Documentation

## omAllocBinPage()

omBinPage omAllocBinPage | ( | void |  | ) |

extern

Definition at line 98 of file omBinPage.c.

{
omBinPage bin_page;
if (om_CurrentBinPageRegion == NULL)
om_CurrentBinPageRegion = omAllocNewBinPagesRegion(1);
while (1)
{
if (om_CurrentBinPageRegion->current != NULL)
{
bin_page = om_CurrentBinPageRegion->current;
om_CurrentBinPageRegion->current = NEXT_PAGE(bin_page);
goto Found;
}
if (om_CurrentBinPageRegion->init_pages > 0)
{
bin_page = (omBinPage)om_CurrentBinPageRegion->init_addr;
om_CurrentBinPageRegion->init_pages--;
if (om_CurrentBinPageRegion->init_pages > 0)
om_CurrentBinPageRegion->init_addr += SIZEOF_SYSTEM_PAGE;
else
om_CurrentBinPageRegion->init_addr = NULL;
goto Found;
}
if (om_CurrentBinPageRegion->next != NULL)
{
om_CurrentBinPageRegion = om_CurrentBinPageRegion->next;
}
else
{
omBinPageRegion new_region = omAllocNewBinPagesRegion(1);
new_region->prev = om_CurrentBinPageRegion;
om_CurrentBinPageRegion->next = new_region;
om_CurrentBinPageRegion = new_region;
}
}
Found:
bin_page->region = om_CurrentBinPageRegion;
om_CurrentBinPageRegion->used_pages++;
om_Info.UsedPages++;
om_Info.AvailPages--;
if (om_Info.UsedPages > om_Info.MaxPages)
om_Info.MaxPages = om_Info.UsedPages;
OM_ALLOC_BINPAGE_HOOK;
return bin_page;
}
NEXT_PAGE
#define NEXT_PAGE(page)
Definition omBinPage.c:95
om_CurrentBinPageRegion
static omBinPageRegion om_CurrentBinPageRegion
Definition omBinPage.c:35
omAllocNewBinPagesRegion
static omBinPageRegion omAllocNewBinPagesRegion(int min_pages)
Definition omBinPage.c:294
NULL
#define NULL
Definition omList.c:12
om_Info
omInfo_t om_Info
Definition omStats.c:16
omBinPageRegion
omBinPageRegion_t * omBinPageRegion
Definition omStructs.h:20

## omAllocBinPages()

omBinPage omAllocBinPages | ( | int | how_many | ) |

extern

Definition at line 149 of file omBinPage.c.

{
omBinPage bin_page;
omBinPageRegion region;
if (om_CurrentBinPageRegion == NULL)
om_CurrentBinPageRegion = omAllocNewBinPagesRegion(how_many);
region = om_CurrentBinPageRegion;
while (1)
{
if (region->init_pages >= how_many)
{
bin_page = (omBinPage)region->init_addr;
region->init_pages -= how_many;
if (region->init_pages)
region->init_addr += how_many*SIZEOF_SYSTEM_PAGE;
else
region->init_addr = NULL;
goto Found;
}
if ((bin_page = omTakeOutConsecutivePages(region, how_many)) != NULL)
{
goto Found;
}
if (region->next != NULL)
{
region = region->next;
}
else
{
omBinPageRegion new_region = omAllocNewBinPagesRegion(how_many);
region->next = new_region;
new_region->prev = region;
region = new_region;
}
}
/*while (1) */
Found:
bin_page->region = region;
region->used_pages += how_many;
if (region != om_CurrentBinPageRegion && OM_IS_EMPTY_REGION(region))
{
omTakeOutRegion(region);
omInsertRegionBefore(region, om_CurrentBinPageRegion);
}
om_Info.UsedPages += how_many;
om_Info.AvailPages -= how_many;
if (om_Info.UsedPages > om_Info.MaxPages)
om_Info.MaxPages = om_Info.UsedPages;
OM_ALLOC_BINPAGE_HOOK;
return bin_page;
}
OM_IS_EMPTY_REGION
#define OM_IS_EMPTY_REGION(region)
Definition omBinPage.c:96
omInsertRegionBefore
OM_INLINE_LOCAL void omInsertRegionBefore(omBinPageRegion insert, omBinPageRegion before)
Definition omBinPage.c:79
omTakeOutConsecutivePages
static void * omTakeOutConsecutivePages(omBinPageRegion region, int how_many)
Definition omBinPage.c:254
omTakeOutRegion
OM_INLINE_LOCAL void omTakeOutRegion(omBinPageRegion region)
Definition omBinPage.c:49

## omFreeBinPages()

void omFreeBinPages | ( | omBinPage | page,
|  | int | how_many )

extern

Definition at line 206 of file omBinPage.c.

{
omBinPageRegion region = bin_page->region;
region->used_pages -= how_many;
if (region->used_pages == 0)
{
if (region == om_CurrentBinPageRegion)
{
if (region->next != NULL)
om_CurrentBinPageRegion = region->next;
else
om_CurrentBinPageRegion = region->prev;
}
omTakeOutRegion(region);
omFreeBinPagesRegion(region);
}
else
{
if (region != om_CurrentBinPageRegion && OM_IS_EMPTY_REGION(region))
{
omTakeOutRegion(region);
omInsertRegionAfter(region, om_CurrentBinPageRegion);
}
if (how_many > 1)
{
int i = how_many;
char* page = (char *)bin_page;
while (i > 1)
{
NEXT_PAGE(page) = page + SIZEOF_SYSTEM_PAGE;
page = NEXT_PAGE(page);
i--;
}
NEXT_PAGE(page) = region->current;
}
else
{
NEXT_PAGE(bin_page) = region->current;
}
region->current = (void*) bin_page;
}
om_Info.AvailPages += how_many;
om_Info.UsedPages -= how_many;
OM_FREE_BINPAGE_HOOK;
}
i
int i
Definition cfEzgcd.cc:132
omInsertRegionAfter
OM_INLINE_LOCAL void omInsertRegionAfter(omBinPageRegion insert, omBinPageRegion after)
Definition omBinPage.c:66
omFreeBinPagesRegion
static void omFreeBinPagesRegion(omBinPageRegion region)
Definition omBinPage.c:330

## Variable Documentation

## om_BinPageIndicies

unsigned long* om_BinPageIndicies

extern

Definition at line 38 of file omBinPage.c.

## om_MaxBinPageIndex

unsigned long om_MaxBinPageIndex

extern

Definition at line 36 of file omBinPage.c.

## om_MinBinPageIndex

unsigned long om_MinBinPageIndex

extern

Definition at line 37 of file omBinPage.c.