Data Structures | Macros | Functions | Variables
omBinPage.c File Reference
#include <mylimits.h>
#include "omalloc.h"
#include "omDefaultConfig.h"
#include "omDebug.h"

Go to the source code of this file.

Data Structures

struct  omBinPageRegion_t
 

Macros

#define OM_KEEP_REGIONS_ORDER
 
#define NEXT_PAGE(page)   *((void**) page)
 
#define OM_IS_EMPTY_REGION(region)   ((region)->current == NULL && (region->init_addr == NULL))
 

Functions

static void * omTakeOutConsecutivePages (omBinPageRegion region, int how_many)
 
static omBinPageRegion omAllocNewBinPagesRegion (int min_pages)
 
static void omFreeBinPagesRegion (omBinPageRegion region)
 
static void omBinPageIndexFault (unsigned long low_index, unsigned long high_index)
 
static void omRegisterBinPages (void *low_addr, int pages)
 
static void omUnregisterBinPages (void *low_addr, int pages)
 
OM_INLINE_LOCAL void omTakeOutRegion (omBinPageRegion region)
 
OM_INLINE_LOCAL void omInsertRegionAfter (omBinPageRegion insert, omBinPageRegion after)
 
OM_INLINE_LOCAL void omInsertRegionBefore (omBinPageRegion insert, omBinPageRegion before)
 
omBinPage omAllocBinPage ()
 
omBinPage omAllocBinPages (int how_many)
 
void omFreeBinPages (omBinPage bin_page, int how_many)
 
int omIsKnownMemoryRegion (omBinPageRegion region)
 
omError_t omCheckBinPageRegion (omBinPageRegion region, int level, omError_t report, OM_FLR_DECL)
 
omError_t omCheckBinPageRegions (int level, omError_t report, OM_FLR_DECL)
 
omBinPageRegion omFindRegionOfAddr (void *addr)
 
int omIsAddrOnFreeBinPage (void *addr)
 

Variables

static omBinPageRegion om_CurrentBinPageRegion = NULL
 
unsigned long om_MaxBinPageIndex = 0
 
unsigned long om_MinBinPageIndex = ULONG_MAX
 
unsigned long * om_BinPageIndicies = NULL
 

Data Structure Documentation

§ omBinPageRegion_s

struct omBinPageRegion_s

Definition at line 20 of file omBinPage.c.

Data Fields
char * addr
void * current
char * init_addr
int init_pages
omBinPageRegion next
int pages
omBinPageRegion prev
int used_pages

Macro Definition Documentation

§ NEXT_PAGE

#define NEXT_PAGE (   page)    *((void**) page)

Definition at line 93 of file omBinPage.c.

§ OM_IS_EMPTY_REGION

#define OM_IS_EMPTY_REGION (   region)    ((region)->current == NULL && (region->init_addr == NULL))

Definition at line 94 of file omBinPage.c.

§ OM_KEEP_REGIONS_ORDER

#define OM_KEEP_REGIONS_ORDER

Definition at line 18 of file omBinPage.c.

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 }
if(0 > strat->sl)
Definition: myNF.cc:73
#define NEXT_PAGE(page)
Definition: omBinPage.c:93
static omBinPageRegion om_CurrentBinPageRegion
Definition: omBinPage.c:33
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
if(0 > strat->sl)
Definition: myNF.cc:73
static omBinPageRegion om_CurrentBinPageRegion
Definition: omBinPage.c:33
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

§ omAllocNewBinPagesRegion()

static omBinPageRegion omAllocNewBinPagesRegion ( int  min_pages)
static

Definition at line 292 of file omBinPage.c.

293 {
294  omBinPageRegion region = omAllocFromSystem(sizeof(omBinPageRegion_t));
295  om_Info.InternalUsedBytesMalloc+=sizeof(omBinPageRegion_t);
296  void* addr;
297  int pages = (min_pages>om_Opts.PagesPerRegion ? min_pages : om_Opts.PagesPerRegion);
298  size_t size = pages*SIZEOF_SYSTEM_PAGE;
299 
300  addr = _omVallocFromSystem(size, 1);
301  if (addr == NULL)
302  {
303  pages = min_pages;
304  size = min_pages*SIZEOF_SYSTEM_PAGE;
305  addr = omVallocFromSystem(size);
306  }
307 
308  omRegisterBinPages(addr, pages);
309  region->addr = addr;
310  region->pages = pages;
311  region->used_pages = 0;
312  region->init_addr = addr;
313  region->init_pages = pages;
314  region->current = NULL;
315  region->next = NULL;
316  region->prev = NULL;
317 
318  om_Info.AvailPages += pages;
319 
320  om_Info.CurrentRegionsAlloc++;
321  if (om_Info.CurrentRegionsAlloc > om_Info.MaxRegionsAlloc)
322  om_Info.MaxRegionsAlloc = om_Info.CurrentRegionsAlloc;
323 
324  return region;
325 }
void * omAllocFromSystem(size_t size)
static void omRegisterBinPages(void *low_addr, int pages)
Definition: omBinPage.c:388
#define omVallocFromSystem(size)
Definition: omAllocSystem.h:24
void * _omVallocFromSystem(size_t size, int fail)
omOpts_t om_Opts
Definition: omOpts.c:11
omInfo_t om_Info
Definition: omStats.c:13
omBinPageRegion_t * omBinPageRegion
Definition: omStructs.h:20
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
#define NULL
Definition: omList.c:10

§ omBinPageIndexFault()

static void omBinPageIndexFault ( unsigned long  low_index,
unsigned long  high_index 
)
static

Definition at line 347 of file omBinPage.c.

348 {
349  unsigned long index_diff = high_index - low_index;
350  omAssume(low_index <= high_index &&
351  (high_index > om_MaxBinPageIndex || low_index < om_MinBinPageIndex));
352 
353  if (om_BinPageIndicies == NULL)
354  {
355  unsigned long i;
356  om_BinPageIndicies = (unsigned long*) omAllocFromSystem((index_diff + 1)*SIZEOF_LONG);
357  om_Info.InternalUsedBytesMalloc+=(index_diff + 1)*SIZEOF_LONG;
358  om_MaxBinPageIndex = high_index;
359  om_MinBinPageIndex = low_index;
360  for (i=0; i<=index_diff; i++) om_BinPageIndicies[i] = 0;
361  }
362  else
363  {
364  unsigned long old_length = om_MaxBinPageIndex - om_MinBinPageIndex + 1;
365  unsigned long new_length = (low_index < om_MinBinPageIndex ?
366  om_MaxBinPageIndex - low_index :
367  high_index - om_MinBinPageIndex) + 1;
368  om_BinPageIndicies = (unsigned long*) omReallocSizeFromSystem(om_BinPageIndicies, old_length*SIZEOF_LONG,
369  new_length*SIZEOF_LONG);
370  om_Info.InternalUsedBytesMalloc+= (new_length-old_length)*SIZEOF_LONG;
371  if (low_index < om_MinBinPageIndex)
372  {
373  long i;
374  unsigned long offset = new_length - old_length;
375  for (i=old_length - 1; i >= 0; i--) om_BinPageIndicies[i+offset] = om_BinPageIndicies[i];
376  for (i=offset-1; i>=0; i--) om_BinPageIndicies[i] = 0;
377  om_MinBinPageIndex = low_index;
378  }
379  else
380  {
381  unsigned long i;
382  for (i=old_length; i<new_length; i++) om_BinPageIndicies[i] = 0;
383  om_MaxBinPageIndex = high_index;
384  }
385  }
386 }
void * omAllocFromSystem(size_t size)
unsigned long om_MinBinPageIndex
Definition: omBinPage.c:35
void * omReallocSizeFromSystem(void *addr, size_t oldsize, size_t newsize)
omInfo_t om_Info
Definition: omStats.c:13
#define omAssume(x)
Definition: omError.h:85
int i
Definition: cfEzgcd.cc:123
unsigned long om_MaxBinPageIndex
Definition: omBinPage.c:34
unsigned long * om_BinPageIndicies
Definition: omBinPage.c:36
#define NULL
Definition: omList.c:10
int offset
Definition: libparse.cc:1091

§ omCheckBinPageRegion()

omError_t omCheckBinPageRegion ( omBinPageRegion  region,
int  level,
omError_t  report,
OM_FLR_DECL   
)

Definition at line 503 of file omBinPage.c.

504 {
505  if (level <= 0) return omError_NoError;
506 
507  omCheckReturn(omCheckPtr(region, report, OM_FLR_VAL));
509  omCheckReturnCorrupted(! omIsAddrPageAligned(region->addr) || ! omIsAddrPageAligned(region->current));
510  omCheckReturnCorrupted(region->used_pages < 0);
511  omCheckReturnCorrupted(region->init_pages < 0 || region->init_pages > region->pages);
512 
513  if (region->init_pages)
514  {
515  omCheckReturnCorrupted(! omIsAddrPageAligned(region->init_addr));
516  omCheckReturnCorrupted(! (region->init_addr >= region->addr
517  && region->init_addr <= region->addr + (region->pages -1)*SIZEOF_SYSTEM_PAGE));
518  omCheckReturnCorrupted(region->init_addr !=
519  region->addr + (region->pages - region->init_pages)*SIZEOF_SYSTEM_PAGE);
520  }
521 
522  omCheckReturn(omCheckList(region->current, level, report, OM_FLR_VAL));
523  omCheckReturnCorrupted(region->current == NULL && region->used_pages + region->init_pages != region->pages);
525  omListLength(region->current)+region->used_pages+region->init_pages != region->pages);
526  return omError_NoError;
527 }
int omIsKnownMemoryRegion(omBinPageRegion region)
Definition: omBinPage.c:487
int level(const CanonicalForm &f)
#define omCheckList(ptr, level, report, OM_FLR_VAL)
Definition: omList.h:83
#define omListLength(ptr)
Definition: omList.h:62
#define omCheckReturnCorrupted(cond)
Definition: omDebug.h:174
#define omCheckReturn(cond)
Definition: omDebug.h:170
omError_t omCheckPtr(const void *ptr, omError_t report, OM_FLR_DECL)
Definition: omDebugCheck.c:136
#define NULL
Definition: omList.c:10
#define omIsAddrPageAligned(addr)
Definition: omBinPage.h:16

§ omCheckBinPageRegions()

omError_t omCheckBinPageRegions ( int  level,
omError_t  report,
OM_FLR_DECL   
)

Definition at line 529 of file omBinPage.c.

530 {
532 
533  if (level <= 0) return omError_NoError;
534  if (iter == NULL) return omError_NoError;
535 
540 
541 
542  if (level > 1)
543  {
546 
547  omCheckReturn(omCheckGList(iter, next, level, report, OM_FLR_VAL));
548  omCheckReturn(omCheckGList(iter, prev, level, report, OM_FLR_VAL));
549 
551  !=
552  omGListLength(next_last, prev));
553 
555 
556  iter = om_CurrentBinPageRegion->next;
557  while (iter)
558  {
560 
561  omCheckReturn(omCheckBinPageRegion(iter, level - 1, report, OM_FLR_VAL));
562  iter = iter->next;
563  }
564 
565  iter = om_CurrentBinPageRegion->prev;
566  while (iter)
567  {
569  omCheckReturn(omCheckBinPageRegion(iter, level - 1, report, OM_FLR_VAL));
570  iter = iter->prev;
571  }
572  }
573  return omError_NoError;
574 }
int level(const CanonicalForm &f)
#define omCheckGList(ptr, next, level, report, OM_FLR_VAL)
Definition: omList.h:115
omError_t omCheckBinPageRegion(omBinPageRegion region, int level, omError_t report, OM_FLR_DECL)
Definition: omBinPage.c:503
CFFListIterator iter
Definition: facAbsBiFact.cc:54
#define omCheckReturnError(cond, error)
Definition: omDebug.h:172
#define omCheckReturnCorrupted(cond)
Definition: omDebug.h:174
static omBinPageRegion om_CurrentBinPageRegion
Definition: omBinPage.c:33
#define omGListLast(ptr, next)
Definition: omList.h:96
#define omCheckReturn(cond)
Definition: omDebug.h:170
#define omGListLength(ptr, next)
Definition: omList.h:94
omBinPageRegion_t * omBinPageRegion
Definition: omStructs.h:20
#define NULL
Definition: omList.c:10
#define OM_IS_EMPTY_REGION(region)
Definition: omBinPage.c:94
ListNode * next
Definition: janet.h:31

§ omFindRegionOfAddr()

omBinPageRegion omFindRegionOfAddr ( void *  addr)

Definition at line 576 of file omBinPage.c.

577 {
579 
580  if (region == NULL) return 0;
581  region = omGListLast(region, prev);
582  do
583  {
584  if ((char *)addr >= region->addr
585  && (char *)addr < region->addr + (region->pages)*SIZEOF_SYSTEM_PAGE)
586  return region;
587  region = region->next;
588  }
589  while (region != NULL);
590  return NULL;
591 }
static omBinPageRegion om_CurrentBinPageRegion
Definition: omBinPage.c:33
#define omGListLast(ptr, next)
Definition: omList.h:96
omBinPageRegion_t * omBinPageRegion
Definition: omStructs.h:20
#define NULL
Definition: omList.c:10

§ omFreeBinPages()

void omFreeBinPages ( omBinPage  bin_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:123
#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

§ omFreeBinPagesRegion()

static void omFreeBinPagesRegion ( omBinPageRegion  region)
static

Definition at line 328 of file omBinPage.c.

329 {
330  omAssume(region != NULL && region->used_pages == 0);
331 
332  om_Info.AvailPages -= region->pages;
333  om_Info.CurrentRegionsAlloc--;
334 
335  omUnregisterBinPages(region->addr, region->pages);
336  omVfreeToSystem(region->addr, region->pages*SIZEOF_SYSTEM_PAGE);
337  omFreeSizeToSystem(region, sizeof(omBinPageRegion_t));
338  om_Info.InternalUsedBytesMalloc-=sizeof(omBinPageRegion_t);
339 }
void omFreeSizeToSystem(void *addr, size_t size)
static void omUnregisterBinPages(void *low_addr, int pages)
Definition: omBinPage.c:435
omInfo_t om_Info
Definition: omStats.c:13
#define omAssume(x)
Definition: omError.h:85
void omVfreeToSystem(void *page, size_t size)
#define NULL
Definition: omList.c:10

§ omInsertRegionAfter()

OM_INLINE_LOCAL void omInsertRegionAfter ( omBinPageRegion  insert,
omBinPageRegion  after 
)

Definition at line 64 of file omBinPage.c.

65 {
66  omAssume(insert != NULL && after != NULL && insert != after);
67  insert->next = after->next;
68  insert->prev = after;
69  after->next = insert;
70  if (insert->next != NULL)
71  {
72  omAssume(insert->next != insert && insert->next != after);
73  insert->next->prev = insert;
74  }
75 }
#define omAssume(x)
Definition: omError.h:85
result insert(CFAFactor(LcF, 1, 1))
#define NULL
Definition: omList.c:10

§ omInsertRegionBefore()

OM_INLINE_LOCAL void omInsertRegionBefore ( omBinPageRegion  insert,
omBinPageRegion  before 
)

Definition at line 77 of file omBinPage.c.

78 {
79  omAssume(insert != NULL && before != NULL && insert != before);
80  insert->prev = before->prev;
81  insert->next = before;
82  before->prev = insert;
83  if (insert->prev != NULL)
84  insert->prev->next = insert;
85 }
#define omAssume(x)
Definition: omError.h:85
result insert(CFAFactor(LcF, 1, 1))
#define NULL
Definition: omList.c:10

§ omIsAddrOnFreeBinPage()

int omIsAddrOnFreeBinPage ( void *  addr)

Definition at line 593 of file omBinPage.c.

594 {
595  char *c_addr=(char *)addr;
597 
598  if (region == NULL) return 0;
599  do
600  {
601  if (c_addr > region->addr && c_addr < region->addr + (region->pages)*SIZEOF_SYSTEM_PAGE)
602  {
603  if (omIsOnList(region->current, omGetPageOfAddr(addr))) return 1;
604  return 0;
605  }
606  region = region->next;
607  }
608  while (region != NULL);
609  return 0;
610 }
#define omIsOnList(ptr, addr)
Definition: omList.h:68
static omBinPageRegion om_CurrentBinPageRegion
Definition: omBinPage.c:33
omBinPageRegion_t * omBinPageRegion
Definition: omStructs.h:20
#define NULL
Definition: omList.c:10
#define omGetPageOfAddr(addr)
Definition: omBinPage.h:19

§ omIsKnownMemoryRegion()

int omIsKnownMemoryRegion ( omBinPageRegion  region)

Definition at line 487 of file omBinPage.c.

488 {
490 
491  if (region == NULL || iter == NULL) return 0;
492  iter = omGListLast(om_CurrentBinPageRegion, prev);
493  do
494  {
495  if (region == iter) return 1;
496  iter = iter->next;
497  }
498  while (iter != NULL);
499  return 0;
500 }
CFFListIterator iter
Definition: facAbsBiFact.cc:54
static omBinPageRegion om_CurrentBinPageRegion
Definition: omBinPage.c:33
#define omGListLast(ptr, next)
Definition: omList.h:96
omBinPageRegion_t * omBinPageRegion
Definition: omStructs.h:20
#define NULL
Definition: omList.c:10

§ omRegisterBinPages()

static void omRegisterBinPages ( void *  low_addr,
int  pages 
)
static

Definition at line 388 of file omBinPage.c.

389 {
390  unsigned long low_index = omGetPageIndexOfAddr(low_addr);
391  char* high_addr = (char *)low_addr + (pages-1)*SIZEOF_SYSTEM_PAGE;
392  unsigned long high_index = omGetPageIndexOfAddr(high_addr);
393  unsigned long shift;
394 
395  if (low_index < om_MinBinPageIndex || high_index > om_MaxBinPageIndex)
396  omBinPageIndexFault(low_index, high_index);
397 
398  shift = omGetPageShiftOfAddr(low_addr);
399  if (low_index < high_index)
400  {
401  if (shift == 0)
402  {
403  om_BinPageIndicies[low_index-om_MinBinPageIndex] = ULONG_MAX;
404  }
405  else
406  {
407  om_BinPageIndicies[low_index-om_MinBinPageIndex] |= ~ ((((unsigned long) 1) << shift) - 1);
408  }
409  for (shift = low_index+1; shift < high_index; shift++)
410  {
411  om_BinPageIndicies[shift-om_MinBinPageIndex] = ULONG_MAX;
412  }
413  shift = omGetPageShiftOfAddr(high_addr);
414  if (shift == BIT_SIZEOF_LONG - 1)
415  {
416  om_BinPageIndicies[high_index - om_MinBinPageIndex] = ULONG_MAX;
417  }
418  else
419  {
420  om_BinPageIndicies[high_index-om_MinBinPageIndex] |= ((((unsigned long) 1) << (shift + 1)) - 1);
421  }
422  }
423  else
424  {
425  high_index = omGetPageShiftOfAddr(high_addr);
426  while (high_index > shift)
427  {
428  om_BinPageIndicies[low_index-om_MinBinPageIndex] |= (((unsigned long) 1) << high_index);
429  high_index--;
430  }
431  om_BinPageIndicies[low_index-om_MinBinPageIndex] |= (((unsigned long) 1) << shift);
432  }
433 }
unsigned long om_MinBinPageIndex
Definition: omBinPage.c:35
#define omGetPageIndexOfAddr(addr)
Definition: omBinPage.h:63
unsigned long om_MaxBinPageIndex
Definition: omBinPage.c:34
unsigned long * om_BinPageIndicies
Definition: omBinPage.c:36
static void omBinPageIndexFault(unsigned long low_index, unsigned long high_index)
Definition: omBinPage.c:347
#define omGetPageShiftOfAddr(addr)
Definition: omBinPage.h:60
#define BIT_SIZEOF_LONG
Definition: auxiliary.h:78

§ omTakeOutConsecutivePages()

static void * omTakeOutConsecutivePages ( omBinPageRegion  region,
int  how_many 
)
static

Definition at line 252 of file omBinPage.c.

253 {
254  void* current;
255  char* iter;
256  void* prev = NULL;
257  void* bin_page;
258  int found;
259  current = region->current;
260  while (current != NULL)
261  {
262  found = 1;
263  iter = current;
264  while (NEXT_PAGE(iter) == (iter + SIZEOF_SYSTEM_PAGE))
265  {
266  iter = NEXT_PAGE(iter);
267  /* handle pathological case that iter + SIZEOF_SYSTEM_PAGE == 0 */
268  if (iter == NULL) return NULL;
269  found++;
270  if (found == pages)
271  {
272  bin_page = current;
273  if (current == region->current)
274  {
275  region->current = NEXT_PAGE(iter);
276  }
277  else
278  {
279  omAssume(prev != NULL);
280  NEXT_PAGE(prev) = NEXT_PAGE(iter);
281  }
282  return bin_page;
283  }
284  }
285  prev = iter;
286  current = NEXT_PAGE(iter);
287  }
288  return NULL;
289 }
#define NEXT_PAGE(page)
Definition: omBinPage.c:93
CFFListIterator iter
Definition: facAbsBiFact.cc:54
bool found
Definition: facFactorize.cc:56
#define omAssume(x)
Definition: omError.h:85
#define NULL
Definition: omList.c:10

§ omTakeOutRegion()

OM_INLINE_LOCAL void omTakeOutRegion ( omBinPageRegion  region)

Definition at line 47 of file omBinPage.c.

48 {
49  omAssume(region != NULL);
50 
51  if (region->prev != NULL)
52  {
53  omAssume(region->prev != region && region->prev != region->next);
54  region->prev->next = region->next;
55  }
56 
57  if (region->next != NULL)
58  {
59  omAssume(region->next != region && region->prev != region->next);
60  region->next->prev = region->prev;
61  }
62 }
#define omAssume(x)
Definition: omError.h:85
#define NULL
Definition: omList.c:10

§ omUnregisterBinPages()

static void omUnregisterBinPages ( void *  low_addr,
int  pages 
)
static

Definition at line 435 of file omBinPage.c.

436 {
437  unsigned long low_index = omGetPageIndexOfAddr(low_addr);
438  char* high_addr = (char *)low_addr + (pages-1)*SIZEOF_SYSTEM_PAGE;
439  unsigned long high_index = omGetPageIndexOfAddr(high_addr);
440  unsigned long shift;
441 
442  shift = omGetPageShiftOfAddr(low_addr);
443  if (low_index < high_index)
444  {
445  if (shift == 0)
446  {
447  om_BinPageIndicies[low_index-om_MinBinPageIndex] = 0;
448  }
449  else
450  {
451  om_BinPageIndicies[low_index-om_MinBinPageIndex] &= ((((unsigned long) 1) << shift) - 1);
452  }
453  for (shift = low_index+1; shift < high_index; shift++)
454  {
456  }
457  shift = omGetPageShiftOfAddr(high_addr);
458  if (shift == BIT_SIZEOF_LONG - 1)
459  {
460  om_BinPageIndicies[high_index - om_MinBinPageIndex] = 0;
461  }
462  else
463  {
464  om_BinPageIndicies[high_index-om_MinBinPageIndex] &= ~ ((((unsigned long) 1) << (shift + 1)) - 1);
465  }
466  }
467  else
468  {
469  high_index = omGetPageShiftOfAddr(high_addr);
470  while (high_index > shift)
471  {
472  om_BinPageIndicies[low_index-om_MinBinPageIndex] &= ~(((unsigned long) 1) << high_index);
473  high_index--;
474  }
475  om_BinPageIndicies[low_index-om_MinBinPageIndex] &= ~(((unsigned long) 1) << shift);
476  }
477 }
unsigned long om_MinBinPageIndex
Definition: omBinPage.c:35
#define omGetPageIndexOfAddr(addr)
Definition: omBinPage.h:63
unsigned long * om_BinPageIndicies
Definition: omBinPage.c:36
#define omGetPageShiftOfAddr(addr)
Definition: omBinPage.h:60
#define BIT_SIZEOF_LONG
Definition: auxiliary.h:78

Variable Documentation

§ om_BinPageIndicies

unsigned long* om_BinPageIndicies = NULL

Definition at line 36 of file omBinPage.c.

§ om_CurrentBinPageRegion

omBinPageRegion om_CurrentBinPageRegion = NULL
static

Definition at line 33 of file omBinPage.c.

§ om_MaxBinPageIndex

unsigned long om_MaxBinPageIndex = 0

Definition at line 34 of file omBinPage.c.

§ om_MinBinPageIndex

unsigned long om_MinBinPageIndex = ULONG_MAX

Definition at line 35 of file omBinPage.c.