My Project  UNKNOWN_GIT_VERSION
Macros | Functions | Variables
omBinPage.h File Reference

Go to the source code of this file.

Macros

#define omIsAddrPageAligned(addr)   (((long) (addr) & (SIZEOF_SYSTEM_PAGE -1)) == 0)
 
#define omGetPageOfAddr(addr)   ((void*) (((long)addr) & ~(SIZEOF_SYSTEM_PAGE -1)))
 
#define omGetBinPageOfAddr(addr)   ((omBinPage) ((long) (addr) & ~(SIZEOF_SYSTEM_PAGE -1)))
 
#define omIsAddrOnPage(addr, page)   (omGetPageOfAddr(addr) == (void*) (page))
 
#define omAreAddrOnSamePage(a1, a2)   (omGetPageOfAddr(a1) == omGetPageOfAddr(a2))
 
#define OM_SIZEOF_INDEX_PAGE   (((unsigned long) SIZEOF_SYSTEM_PAGE) << LOG_BIT_SIZEOF_LONG)
 
#define omGetPageShiftOfAddr(addr)   ((((unsigned long) addr) & (OM_SIZEOF_INDEX_PAGE -1)) >> LOG_BIT_SIZEOF_SYSTEM_PAGE)
 
#define omGetPageIndexOfAddr(addr)   (((unsigned long) addr) >> (LOG_BIT_SIZEOF_LONG + LOG_BIT_SIZEOF_SYSTEM_PAGE))
 
#define omIsBinPageAddr(addr)   _omIsBinPageAddr(addr)
 
#define omFreeBinPage(addr)   omFreeBinPages(addr, 1)
 

Functions

omBinPage omAllocBinPages (int how_many)
 
omBinPage omAllocBinPage ()
 
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 
)    (omGetPageOfAddr(a1) == omGetPageOfAddr(a2))

Definition at line 27 of file omBinPage.h.

◆ omFreeBinPage

#define omFreeBinPage (   addr)    omFreeBinPages(addr, 1)

Definition at line 88 of file omBinPage.h.

◆ omGetBinPageOfAddr

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

Definition at line 22 of file omBinPage.h.

◆ omGetPageIndexOfAddr

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

Definition at line 63 of file omBinPage.h.

◆ omGetPageOfAddr

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

Definition at line 19 of file omBinPage.h.

◆ omGetPageShiftOfAddr

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

Definition at line 60 of file omBinPage.h.

◆ omIsAddrOnPage

#define omIsAddrOnPage (   addr,
  page 
)    (omGetPageOfAddr(addr) == (void*) (page))

Definition at line 25 of file omBinPage.h.

◆ omIsAddrPageAligned

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

Definition at line 16 of file omBinPage.h.

◆ omIsBinPageAddr

#define omIsBinPageAddr (   addr)    _omIsBinPageAddr(addr)

Definition at line 68 of file omBinPage.h.

Function Documentation

◆ omAllocBinPage()

omBinPage omAllocBinPage ( )

Definition at line 96 of file omBinPage.c.

97 {
98  omBinPage bin_page;
99 
102 
103  while (1)
104  {
105  if (om_CurrentBinPageRegion->current != NULL)
106  {
107  bin_page = om_CurrentBinPageRegion->current;
108  om_CurrentBinPageRegion->current = NEXT_PAGE(bin_page);
109  goto Found;
110  }
111  if (om_CurrentBinPageRegion->init_pages > 0)
112  {
113  bin_page = (omBinPage)om_CurrentBinPageRegion->init_addr;
114  om_CurrentBinPageRegion->init_pages--;
115  if (om_CurrentBinPageRegion->init_pages > 0)
116  om_CurrentBinPageRegion->init_addr += SIZEOF_SYSTEM_PAGE;
117  else
118  om_CurrentBinPageRegion->init_addr = NULL;
119  goto Found;
120  }
121  if (om_CurrentBinPageRegion->next != NULL)
122  {
124  }
125  else
126  {
128  new_region->prev = om_CurrentBinPageRegion;
129  om_CurrentBinPageRegion->next = new_region;
130  om_CurrentBinPageRegion = new_region;
131  }
132  }
133 
134  Found:
135  bin_page->region = om_CurrentBinPageRegion;
136  om_CurrentBinPageRegion->used_pages++;
137 
138  om_Info.UsedPages++;
139  om_Info.AvailPages--;
140  if (om_Info.UsedPages > om_Info.MaxPages)
141  om_Info.MaxPages = om_Info.UsedPages;
142 
143  OM_ALLOC_BINPAGE_HOOK;
144  return bin_page;
145 }
#define NEXT_PAGE(page)
Definition: omBinPage.c:93
static omBinPageRegion om_CurrentBinPageRegion
Definition: omBinPage.c:33
if(yy_init)
Definition: libparse.cc:1418
omInfo_t om_Info
Definition: omStats.c:13
omBinPage_t * omBinPage
Definition: omStructs.h:16
omBinPageRegion_t * omBinPageRegion
Definition: omStructs.h:20
#define NULL
Definition: omList.c:10
static omBinPageRegion omAllocNewBinPagesRegion(int min_pages)
Definition: omBinPage.c:292

◆ omAllocBinPages()

omBinPage omAllocBinPages ( int  how_many)

Definition at line 147 of file omBinPage.c.

148 {
149  omBinPage bin_page;
150  omBinPageRegion region;
151 
154 
155  region = om_CurrentBinPageRegion;
156  while (1)
157  {
158  if (region->init_pages >= how_many)
159  {
160  bin_page = (omBinPage)region->init_addr;
161  region->init_pages -= how_many;
162  if (region->init_pages)
163  region->init_addr += how_many*SIZEOF_SYSTEM_PAGE;
164  else
165  region->init_addr = NULL;
166  goto Found;
167  }
168  if ((bin_page = omTakeOutConsecutivePages(region, how_many)) != NULL)
169  {
170  goto Found;
171  }
172  if (region->next != NULL)
173  {
174  region = region->next;
175  }
176  else
177  {
178  omBinPageRegion new_region = omAllocNewBinPagesRegion(how_many);
179  region->next = new_region;
180  new_region->prev = region;
181  region = new_region;
182  }
183  }
184  /*while (1) */
185 
186  Found:
187  bin_page->region = region;
188  region->used_pages += how_many;
189 
190  if (region != om_CurrentBinPageRegion && OM_IS_EMPTY_REGION(region))
191  {
192  omTakeOutRegion(region);
194  }
195  om_Info.UsedPages += how_many;
196  om_Info.AvailPages -= how_many;
197  if (om_Info.UsedPages > om_Info.MaxPages)
198  om_Info.MaxPages = om_Info.UsedPages;
199 
200  OM_ALLOC_BINPAGE_HOOK;
201  return bin_page;
202 }
OM_INLINE_LOCAL void omInsertRegionBefore(omBinPageRegion insert, omBinPageRegion before)
Definition: omBinPage.c:77
static void * omTakeOutConsecutivePages(omBinPageRegion region, int how_many)
Definition: omBinPage.c:252
static omBinPageRegion om_CurrentBinPageRegion
Definition: omBinPage.c:33
if(yy_init)
Definition: libparse.cc:1418
omInfo_t om_Info
Definition: omStats.c:13
omBinPage_t * omBinPage
Definition: omStructs.h:16
omBinPageRegion_t * omBinPageRegion
Definition: omStructs.h:20
#define NULL
Definition: omList.c:10
#define OM_IS_EMPTY_REGION(region)
Definition: omBinPage.c:94
static omBinPageRegion omAllocNewBinPagesRegion(int min_pages)
Definition: omBinPage.c:292
OM_INLINE_LOCAL void omTakeOutRegion(omBinPageRegion region)
Definition: omBinPage.c:47

◆ omFreeBinPages()

void omFreeBinPages ( omBinPage  page,
int  how_many 
)

Definition at line 204 of file omBinPage.c.

205 {
206  omBinPageRegion region = bin_page->region;
207 
208  region->used_pages -= how_many;
209  if (region->used_pages == 0)
210  {
211  if (region == om_CurrentBinPageRegion)
212  {
213  if (region->next != NULL)
214  om_CurrentBinPageRegion = region->next;
215  else
216  om_CurrentBinPageRegion = region->prev;
217  }
218  omTakeOutRegion(region);
219  omFreeBinPagesRegion(region);
220  }
221  else
222  {
223  if (region != om_CurrentBinPageRegion && OM_IS_EMPTY_REGION(region))
224  {
225  omTakeOutRegion(region);
227  }
228  if (how_many > 1)
229  {
230  int i = how_many;
231  char* page = (char *)bin_page;
232 
233  while (i > 1)
234  {
235  NEXT_PAGE(page) = page + SIZEOF_SYSTEM_PAGE;
236  page = NEXT_PAGE(page);
237  i--;
238  }
239  NEXT_PAGE(page) = region->current;
240  }
241  else
242  {
243  NEXT_PAGE(bin_page) = region->current;
244  }
245  region->current = (void*) bin_page;
246  }
247  om_Info.AvailPages += how_many;
248  om_Info.UsedPages -= how_many;
249  OM_FREE_BINPAGE_HOOK;
250 }
static void omFreeBinPagesRegion(omBinPageRegion region)
Definition: omBinPage.c:328
#define NEXT_PAGE(page)
Definition: omBinPage.c:93
static omBinPageRegion om_CurrentBinPageRegion
Definition: omBinPage.c:33
omInfo_t om_Info
Definition: omStats.c:13
omBinPageRegion_t * omBinPageRegion
Definition: omStructs.h:20
int i
Definition: cfEzgcd.cc:125
#define NULL
Definition: omList.c:10
#define OM_IS_EMPTY_REGION(region)
Definition: omBinPage.c:94
OM_INLINE_LOCAL void omInsertRegionAfter(omBinPageRegion insert, omBinPageRegion after)
Definition: omBinPage.c:64
OM_INLINE_LOCAL void omTakeOutRegion(omBinPageRegion region)
Definition: omBinPage.c:47

Variable Documentation

◆ om_BinPageIndicies

unsigned long* om_BinPageIndicies

Definition at line 36 of file omBinPage.c.

◆ om_MaxBinPageIndex

unsigned long om_MaxBinPageIndex

Definition at line 34 of file omBinPage.c.

◆ om_MinBinPageIndex

unsigned long om_MinBinPageIndex

Definition at line 35 of file omBinPage.c.