My Project
Loading...
Searching...
No Matches
Macros | Functions
omBin.h File Reference

Go to the source code of this file.

Macros

#define omGetAlignedSpecBin(size)   _omGetSpecBin(size, 1, 0)
 
#define omGetSpecBin(size)   _omGetSpecBin(size, 0, 0)
 
#define omUnGetSpecBin(bin_ptr)   _omUnGetSpecBin(bin_ptr, 0)
 
#define omDeleteSpecBin(bin_ptr)   _omUnGetSpecBin(bin_ptr, 1)
 
#define omIsStickyBin(bin)   (bin->sticky >= SIZEOF_VOIDP)
 
#define omIsStaticNormalBin(bin)
 
#define omIsNormalBin(bin)   omIsStaticNormalBin(bin) || omFindInGList(om_SpecBin, next, bin, bin) || omIsStickyBin(bin)
 
#define omIsSpecBin(bin)   (!omIsStaticNormalBin(bin) && !omIsStickyBin(bin))
 
#define omIsKnownTopBin(bin, normal_bin)   1
 
#define omIsStaticTrackBin(bin)   0
 
#define omIsTrackBin(bin)   0
 
#define omIsStaticBin(bin)   omIsStaticNormalBin(bin) || omIsStaticTrackBin(bin)
 

Functions

omBin _omGetSpecBin (size_t size, int align, int track)
 
void _omUnGetSpecBin (omBin *bin, int force)
 
long omGetUsedBinBytes (void)
 
omBin omGetStickyBinOfBin (omBin bin)
 
void omMergeStickyBinIntoBin (omBin sticky_bin, omBin into_bin)
 
unsigned long omGetNewStickyBinTag (omBin bin)
 
void omSetStickyBinTag (omBin bin, unsigned long sticky)
 
void omUnSetStickyBinTag (omBin bin, unsigned long sticky)
 
void omDeleteStickyBinTag (omBin bin, unsigned long sticky)
 
unsigned long omGetNewStickyAllBinTag (void)
 
void omSetStickyAllBinTag (unsigned long sticky)
 
void omUnSetStickyAllBinTag (unsigned long sticky)
 
void omDeleteStickyAllBinTag (unsigned long sticky)
 
void omPrintBinStats (FILE *fd)
 
int omIsKnownTopBin (omBin bin, int normal_bin)
 

Macro Definition Documentation

◆ omDeleteSpecBin

#define omDeleteSpecBin (   bin_ptr)    _omUnGetSpecBin(bin_ptr, 1)

Definition at line 15 of file omBin.h.

◆ omGetAlignedSpecBin

#define omGetAlignedSpecBin (   size)    _omGetSpecBin(size, 1, 0)

Definition at line 10 of file omBin.h.

◆ omGetSpecBin

#define omGetSpecBin (   size)    _omGetSpecBin(size, 0, 0)

Definition at line 11 of file omBin.h.

◆ omIsKnownTopBin

#define omIsKnownTopBin (   bin,
  normal_bin 
)    1

Definition at line 55 of file omBin.h.

◆ omIsNormalBin

#define omIsNormalBin (   bin)    omIsStaticNormalBin(bin) || omFindInGList(om_SpecBin, next, bin, bin) || omIsStickyBin(bin)

Definition at line 46 of file omBin.h.

◆ omIsSpecBin

#define omIsSpecBin (   bin)    (!omIsStaticNormalBin(bin) && !omIsStickyBin(bin))

Definition at line 47 of file omBin.h.

◆ omIsStaticBin

#define omIsStaticBin (   bin)    omIsStaticNormalBin(bin) || omIsStaticTrackBin(bin)

Definition at line 59 of file omBin.h.

◆ omIsStaticNormalBin

#define omIsStaticNormalBin (   bin)
Value:
((unsigned long) bin >= ((unsigned long) &om_StaticBin[0]) && \
(unsigned long) bin <= ((unsigned long) &om_StaticBin[OM_MAX_BIN_INDEX]))
omBin_t om_StaticBin[]
#define OM_MAX_BIN_INDEX
Definition omTables.h:4

Definition at line 43 of file omBin.h.

◆ omIsStaticTrackBin

#define omIsStaticTrackBin (   bin)    0

Definition at line 56 of file omBin.h.

◆ omIsStickyBin

#define omIsStickyBin (   bin)    (bin->sticky >= SIZEOF_VOIDP)

Definition at line 33 of file omBin.h.

◆ omIsTrackBin

#define omIsTrackBin (   bin)    0

Definition at line 57 of file omBin.h.

◆ omUnGetSpecBin

#define omUnGetSpecBin (   bin_ptr)    _omUnGetSpecBin(bin_ptr, 0)

Definition at line 14 of file omBin.h.

Function Documentation

◆ _omGetSpecBin()

omBin _omGetSpecBin ( size_t  size,
int  align,
int  track 
)

Definition at line 26 of file omBin.c.

28{
30 long max_blocks;
31 long sizeW;
32
33
35#ifdef OM_ALIGNMENT_NEEDS_WORK
37 {
38 align = 1;
40 }
41#else
42 align = 0;
43#endif
44
46 {
47 /* need page header */
48 max_blocks = - (long)
51 sizeW = ((-max_blocks*SIZEOF_SYSTEM_PAGE) -
54 }
55 else
56 {
57 /* SIZEOF_OM_BIN_PAGE == max_blocks*size + r1; r1 < size */
58 /* r1 = max_blocks*(size_padding) + r2; r2 < max_blocks */
59 max_blocks = SIZEOF_OM_BIN_PAGE / size;
60 sizeW = (SIZEOF_OM_BIN_PAGE % size) / max_blocks;
61#ifdef OM_ALIGNMENT_NEEDS_WORK
62 if (align)
63 sizeW = ((size + sizeW) & ~ (SIZEOF_STRICT_ALIGNMENT - 1));
64 else
65#endif
66 sizeW = ((size + sizeW) & ~ (SIZEOF_OM_ALIGNMENT - 1));
67
68 omAssume(sizeW >= size);
69 omAssume(max_blocks*sizeW <= SIZEOF_OM_BIN_PAGE);
70 omAssume((max_blocks+1)*sizeW > SIZEOF_OM_BIN_PAGE ||
71 max_blocks*(sizeW + SIZEOF_STRICT_ALIGNMENT) > SIZEOF_OM_BIN_PAGE);
72
73 sizeW = sizeW >> LOG_SIZEOF_LONG;
75 {
77 }
78#ifdef OM_ALIGNMENT_NEEDS_WORK
79 else if (align)
80 {
82 }
83#endif
84#ifdef OM_HAVE_TRACK
85 else if (track)
86 {
88 }
89#endif
90 else
91 {
93 }
94 }
95
97 om_new_specBin->max_blocks < max_blocks)
98 {
100#ifdef OM_HAVE_TRACK
101 if (track)
102 s_bin = omFindInSortedGList(om_SpecTrackBin, next, max_blocks, max_blocks);
103 else
104#endif
105 s_bin = omFindInSortedGList(om_SpecBin, next, max_blocks, max_blocks);
106
107 if (s_bin != NULL)
108 {
109 (s_bin->ref)++;
110 omAssume(s_bin->bin != NULL &&
111 s_bin->bin->max_blocks == s_bin->max_blocks &&
112 s_bin->bin->sizeW == sizeW);
113 return s_bin->bin;
114 }
115 s_bin = (omSpecBin) omAlloc(sizeof(omSpecBin_t));
116 s_bin->ref = 1;
117 s_bin->next = NULL;
118 s_bin->max_blocks = max_blocks;
119 s_bin->bin = (omBin) omAlloc(sizeof(omBin_t));
120 s_bin->bin->current_page = om_ZeroPage;
121 s_bin->bin->last_page = NULL;
122 s_bin->bin->next = NULL;
123 s_bin->bin->sizeW = sizeW;
124 s_bin->bin->max_blocks = max_blocks;
125 s_bin->bin->sticky = 0;
126#ifdef OM_HAVE_TRACK
127 if (track)
128 {
130 }
131 else
132#endif
134 return s_bin->bin;
135 }
136 else
137 {
138 return om_new_specBin;
139 }
140}
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition cf_ops.cc:600
ListNode * next
Definition janet.h:31
#define omAlloc(size)
#define SIZEOF_OM_BIN_PAGE
#define omSmallSize2Bin(size)
#define om_LargeBin
Definition omBin.c:25
#define omAssume(x)
Definition omError.h:85
#define NULL
Definition omList.c:12
#define omInsertInSortedGList(ptr, next, what, addr)
Definition omList.h:106
#define omFindInSortedGList(ptr, next, what, value)
Definition omList.h:108
omBin_t * omBin
Definition omStructs.h:12
omSpecBin_t * omSpecBin
Definition omStructs.h:30
#define OM_MAX_BLOCK_SIZE
Definition omTables.c:31
#define OM_SIZEOF_UNIQUE_MAX_BLOCK_THRESHOLD
Definition omTables.h:5
omBinPage_t om_ZeroPage[]
Definition om_Alloc.c:19
omSpecBin om_SpecBin
Definition om_Alloc.c:20
#define omSmallSize2AlignedBin

◆ _omUnGetSpecBin()

void _omUnGetSpecBin ( omBin bin,
int  force 
)

Definition at line 142 of file omBin.c.

143{
144 omBin bin = *bin_p;
145 if (! omIsStaticBin(bin))
146 {
147#ifdef OM_HAVE_TRACK
148 int track_bin = 0;
149#endif
151
152#ifdef OM_HAVE_TRACK
154 if (s_bin != NULL)
155 track_bin = 1;
156 else
157#endif
158 s_bin = omFindInSortedGList(om_SpecBin, next, max_blocks, bin->max_blocks);
159
160 omAssume(s_bin != NULL && bin == s_bin->bin);
161 if (s_bin != NULL)
162 {
163 (s_bin->ref)--;
164 if (s_bin->ref == 0 || force)
165 {
166#ifdef OM_HAVE_TRACK
167 if (! track_bin)
168#endif
170 if(s_bin->bin->last_page == NULL || force)
171 {
172#ifdef OM_HAVE_TRACK
173 if (track_bin)
175 else
176#endif
178 omFreeSize(s_bin->bin, sizeof(omBin_t));
179 omFreeSize(s_bin, sizeof(omSpecBin_t));
180 }
181 }
182 }
183 }
184 *bin_p = NULL;
185}
#define omFreeSize(addr, size)
#define omIsStaticBin(bin)
Definition omBin.h:59
void omFreeKeptAddrFromBin(omBin bin)
Definition omDebug.c:542
#define omFindInGList(ptr, next, what, value)
Definition omList.h:104
#define omRemoveFromSortedGList(ptr, next, what, addr)
Definition omList.h:110

◆ omDeleteStickyAllBinTag()

void omDeleteStickyAllBinTag ( unsigned long  sticky)

Definition at line 570 of file omBin.c.

571{
573 int i;
574 for (i=0; i<=OM_MAX_BIN_INDEX; i++)
575 {
577 }
578 while (s_bin != NULL)
579 {
580 omDeleteStickyBinTag(s_bin->bin, sticky);
581 s_bin = s_bin->next;
582 }
583}
int i
Definition cfEzgcd.cc:132
void omDeleteStickyBinTag(omBin bin, unsigned long sticky)
Definition omBin.c:339

◆ omDeleteStickyBinTag()

void omDeleteStickyBinTag ( omBin  bin,
unsigned long  sticky 
)

Definition at line 339 of file omBin.c.

340{
343
344 if (sticky == 0)
345 {
346 omAssume(0);
347 return;
348 }
349
350 sticky_bin = omGetStickyBin(bin, sticky);
351 if (sticky_bin != NULL)
352 {
355
357
358 if (bin == sticky_bin)
359 {
361 omSetStickyBinTag(bin, 0);
362 }
363 bin->next = omRemoveFromGList(bin->next, next, sticky_bin);
364 omFreeSize(sticky_bin, sizeof(omBin_t));
365 }
366}
void omSetStickyBinTag(omBin bin, unsigned long sticky_tag)
Definition omBin.c:237
static void omMergeStickyPages(omBin to_bin, omBin from_bin)
Definition omBin.c:267
#define omGetStickyBin(bin, sticky_tag)
Definition omBin.c:193
#define omRemoveFromGList(ptr, next, addr)
Definition omList.h:102

◆ omGetNewStickyAllBinTag()

unsigned long omGetNewStickyAllBinTag ( void  )

Definition at line 486 of file omBin.c.

487{
488 unsigned long sticky = 0, new_sticky;
489 int i;
491 // first, find new sticky tag
492 for (i=0; i<=OM_MAX_BIN_INDEX; i++)
493 {
495 if (new_sticky > sticky) sticky = new_sticky;
496 }
498 while (s_bin != NULL)
499 {
501 if (new_sticky > sticky) sticky = new_sticky;
502 s_bin = s_bin->next;
503 }
504 if (sticky < BIT_SIZEOF_LONG - 2)
505 {
506 sticky++;
507 for (i=0; i<=OM_MAX_BIN_INDEX; i++)
508 {
509 omCreateStickyBin(&(om_StaticBin[i]), sticky);
510 }
512 while (s_bin != NULL)
513 {
514 omCreateStickyBin(s_bin->bin, sticky);
515 s_bin = s_bin->next;
516 }
517 return sticky;
518 }
519 else
520 {
521 omBin bin;
522 omAssume(sticky == BIT_SIZEOF_LONG - 1);
523 for (i=0; i<=OM_MAX_BIN_INDEX; i++)
524 {
525 bin = &om_StaticBin[i];
526 if (omGetStickyBin(bin, BIT_SIZEOF_LONG -1) == NULL)
528 }
530 while (s_bin != NULL)
531 {
532 if (omGetStickyBin(s_bin->bin, BIT_SIZEOF_LONG -1) == NULL)
534 s_bin = s_bin->next;
535 }
536 return BIT_SIZEOF_LONG - 1;
537 }
538}
#define BIT_SIZEOF_LONG
Definition auxiliary.h:80
unsigned long omGetMaxStickyBinTag(omBin bin)
Definition omBin.c:209
static omBin omCreateStickyBin(omBin bin, unsigned long sticky)
Definition omBin.c:196

◆ omGetNewStickyBinTag()

unsigned long omGetNewStickyBinTag ( omBin  bin)

Definition at line 221 of file omBin.c.

222{
223 unsigned long sticky = omGetMaxStickyBinTag(bin);
224 if (sticky < BIT_SIZEOF_LONG - 2)
225 {
226 sticky++;
227 omCreateStickyBin(bin, sticky);
228 return sticky;
229 }
230 else
231 {
232 omAssume(sticky == BIT_SIZEOF_LONG - 1);
233 }
234 return sticky;
235}

◆ omGetStickyBinOfBin()

omBin omGetStickyBinOfBin ( omBin  bin)

Definition at line 375 of file omBin.c.

376{
377 omBin new_bin = omAlloc(sizeof(omBin_t));
378 omAssume(omIsKnownTopBin(bin, 1) && ! omIsStickyBin(bin));
379 new_bin->sticky = SIZEOF_VOIDP;
380 new_bin->max_blocks = bin->max_blocks;
381 new_bin->sizeW = bin->sizeW;
382 new_bin->next = om_StickyBins;
384 new_bin->last_page = NULL;
385 new_bin->current_page = om_ZeroPage;
386#if 0
387 if (omIsSpecBin(bin))
388 {
389 omSpecBin s_bin = omFindInSortedGList(om_SpecBin, next, max_blocks, bin->max_blocks);
390 omAssume(s_bin != NULL);
391 if (s_bin != NULL)
392 s_bin->ref++;
393 }
394#endif
395 return new_bin;
396}
omBin om_StickyBins
Definition omBin.c:374
#define omIsKnownTopBin(bin, normal_bin)
Definition omBin.h:55
#define omIsStickyBin(bin)
Definition omBin.h:33
#define omIsSpecBin(bin)
Definition omBin.h:47

◆ omGetUsedBinBytes()

long omGetUsedBinBytes ( void  )

Definition at line 763 of file omBin.c.

764{
765 int i = OM_MAX_BIN_INDEX;
767 long used = 0;
768 omBin sticky;
769
770 for (; i>=0; i--)
771 {
773 }
774 while (s_bin != NULL)
775 {
777 s_bin = s_bin->next;
778 }
779#ifdef OM_HAVE_TRACK
780 for (i=OM_MAX_BIN_INDEX; i>=0; i--)
781 {
783 }
785 while (s_bin != NULL)
786 {
788 s_bin = s_bin->next;
789 }
790#endif
791
792 sticky = om_StickyBins;
793 while (sticky != NULL)
794 {
795 used += omGetUsedBytesOfBin(sticky);
796 sticky = sticky->next;
797 }
798 return used;
799}
static long omGetUsedBytesOfBin(omBin bin)
Definition omBin.c:756

◆ omIsKnownTopBin()

int omIsKnownTopBin ( omBin  bin,
int  normal_bin 
)

Definition at line 442 of file omBin.c.

443{
446 int i;
447
448 omAssume(normal_bin == 1 || normal_bin == 0);
449
450#ifdef OM_HAVE_TRACK
451 if (! normal_bin)
452 {
455 }
456 else
457#endif
458 {
462 }
463
464 for (i=0; i<= OM_MAX_BIN_INDEX; i++)
465 {
466 if (bin == &(to_check[i]))
467 return 1;
468 }
469
470 while (s_bin != NULL)
471 {
472 if (bin == s_bin->bin) return 1;
473 s_bin = s_bin->next;
474 }
476
477 while (to_check != NULL)
478 {
479 if (bin == to_check) return 1;
480 to_check = to_check->next;
481 }
482 return 0;
483}

◆ omMergeStickyBinIntoBin()

void omMergeStickyBinIntoBin ( omBin  sticky_bin,
omBin  into_bin 
)

Definition at line 398 of file omBin.c.

399{
401 !sticky_bin->sticky ||
402 sticky_bin->max_blocks != into_bin->max_blocks ||
403 sticky_bin == into_bin ||
406 {
407#ifndef OM_NDEBUG
409 (! omIsOnGList(om_StickyBins, next, sticky_bin) ? "unknown sticky_bin" :
410 (!sticky_bin->sticky ? "sticky_bin is not sticky" :
411 (sticky_bin->max_blocks != into_bin->max_blocks ? "sticky_bin and into_bin have different block sizes" :
412 (sticky_bin == into_bin ? "sticky_bin == into_bin" :
413 (!omIsKnownTopBin(into_bin, 1) ? "unknown into_bin" :
414 (omIsStickyBin(into_bin) ? "into_bin is sticky" :
415 "unknown sticky_bin error")))))));
416#endif
417 return;
418 }
422
423#if 0
424 if (! omIsStaticBin(into_bin))
425 {
428 }
429#endif
430 omFreeSize(sticky_bin, sizeof(omBin_t));
431#if defined(OM_INTERNAL_DEBUG) && !defined(OM_NDEBUG)
433#endif
434}
omError_t omTestBin(omBin bin, int check_level)
Definition omDebug.c:90
#define omUnGetSpecBin(bin_ptr)
Definition omBin.h:14
omError_t omReportError(omError_t error, omError_t report_error, OM_FLR_DECL, const char *fmt,...)
Definition omError.c:80
@ omError_NoError
Definition omError.h:18
@ omError_StickyBin
Definition omError.h:41
#define omIsOnGList(ptr, next, addr)
Definition omList.h:100

◆ omPrintBinStats()

void omPrintBinStats ( FILE fd)

Definition at line 694 of file omBin.c.

695{
696 int i = OM_MAX_BIN_INDEX;
697 long pages=0, used_blocks=0, free_blocks=0;
700 omBin sticky;
701
702 fputs(" SizeW\tBlocks\tUPages\tFBlocks\tUBlocks\tSticky\n",fd);
703 fflush(fd);
704 while (s_bin != NULL || i >= 0)
705 {
706 if (s_bin == NULL || (i >= 0 && (unsigned long) om_StaticBin[i].max_blocks < (unsigned long) s_bin->bin->max_blocks))
707 {
709 pages += pages_p;
710 used_blocks += used_blocks_p;
712#ifdef OM_HAVE_TRACK
713 if (om_StaticTrackBin[i].current_page != om_ZeroPage)
714 {
716 pages += pages_p;
717 used_blocks += used_blocks_p;
719 }
720#endif
721 i--;
722 }
723 else
724 {
726 pages += pages_p;
727 used_blocks += used_blocks_p;
729 s_bin = s_bin->next;
730 }
731 }
732#ifdef OM_HAVE_TRACK
734 while (s_bin != NULL)
735 {
737 s_bin = s_bin->next;
738 pages += pages_p;
739 used_blocks += used_blocks_p;
741 }
742#endif
743 sticky = om_StickyBins;
744 while (sticky != NULL)
745 {
747 sticky = sticky->next;
748 pages += pages_p;
749 used_blocks += used_blocks_p;
751 }
752 fputs("----------------------------------------\n",fd);
753 fprintf(fd, " \t \t%ld\t%ld\t%ld\n", pages, free_blocks, used_blocks);
754}
static void omPrintBinStat(FILE *fd, omBin bin, int track, long *pages, long *used_blocks, long *free_blocks)
Definition omBin.c:663
int status int fd
Definition si_signals.h:59

◆ omSetStickyAllBinTag()

void omSetStickyAllBinTag ( unsigned long  sticky)

Definition at line 540 of file omBin.c.

541{
543 int i;
544 for (i=0; i<=OM_MAX_BIN_INDEX; i++)
545 {
546 omSetStickyBinTag(&(om_StaticBin[i]), sticky);
547 }
548 while (s_bin != NULL)
549 {
550 omSetStickyBinTag(s_bin->bin, sticky);
551 s_bin = s_bin->next;
552 }
553}

◆ omSetStickyBinTag()

void omSetStickyBinTag ( omBin  bin,
unsigned long  sticky 
)

Definition at line 237 of file omBin.c.

238{
239 omBin s_bin;
241
242 if (s_bin != bin)
243 {
244 omBinPage tc, tl;
245 unsigned long ts;
246
248 ts = bin->sticky;
249 tl = bin->last_page;
250 tc = bin->current_page;
251 bin->sticky = s_bin->sticky;
252 bin->current_page = s_bin->current_page;
253 bin->last_page = s_bin->last_page;
254 s_bin->sticky = ts;
255 s_bin->last_page = tl;
256 s_bin->current_page = tc;
257 }
258}
omBinPage_t * omBinPage
Definition omStructs.h:16

◆ omUnSetStickyAllBinTag()

void omUnSetStickyAllBinTag ( unsigned long  sticky)

Definition at line 555 of file omBin.c.

556{
558 int i;
559 for (i=0; i<=OM_MAX_BIN_INDEX; i++)
560 {
562 }
563 while (s_bin != NULL)
564 {
565 omUnSetStickyBinTag(s_bin->bin, sticky);
566 s_bin = s_bin->next;
567 }
568}
void omUnSetStickyBinTag(omBin bin, unsigned long sticky)
Definition omBin.c:260

◆ omUnSetStickyBinTag()

void omUnSetStickyBinTag ( omBin  bin,
unsigned long  sticky 
)

Definition at line 260 of file omBin.c.

261{
262 omAssume(omGetStickyBin(bin, 0) != NULL);
263 if (bin->sticky == sticky)
264 omSetStickyBinTag(bin, 0);
265}