My Project
Loading...
Searching...
No Matches
Macros | Functions | Variables
omBin.c File Reference
#include "omalloc.h"

Go to the source code of this file.

Macros

#define om_LargeBin   ((omBin) 1)
 
#define omGetStickyBin(bin, sticky_tag)    omFindInGList(bin, next, sticky, sticky_tag)
 

Functions

omBin _omGetSpecBin (size_t size, int align, int track)
 
void _omUnGetSpecBin (omBin *bin_p, int force)
 
static omBin omCreateStickyBin (omBin bin, unsigned long sticky)
 
unsigned long omGetMaxStickyBinTag (omBin bin)
 
unsigned long omGetNewStickyBinTag (omBin bin)
 
void omSetStickyBinTag (omBin bin, unsigned long sticky_tag)
 
void omUnSetStickyBinTag (omBin bin, unsigned long sticky)
 
static void omMergeStickyPages (omBin to_bin, omBin from_bin)
 
void omDeleteStickyBinTag (omBin bin, unsigned long sticky)
 
omBin omGetStickyBinOfBin (omBin bin)
 
void omMergeStickyBinIntoBin (omBin sticky_bin, omBin into_bin)
 
int omIsKnownTopBin (omBin bin, int normal_bin)
 
unsigned long omGetNewStickyAllBinTag ()
 
void omSetStickyAllBinTag (unsigned long sticky)
 
void omUnSetStickyAllBinTag (unsigned long sticky)
 
void omDeleteStickyAllBinTag (unsigned long sticky)
 
static void omGetBinStat (omBin bin, long *pages_p, long *used_blocks_p, long *free_blocks_p)
 
static void omGetTotalBinStat (omBin bin, long *pages_p, long *used_blocks_p, long *free_blocks_p)
 
static void omPrintBinStat (FILE *fd, omBin bin, int track, long *pages, long *used_blocks, long *free_blocks)
 
void omPrintBinStats (FILE *fd)
 
static long omGetUsedBytesOfBin (omBin bin)
 
long omGetUsedBinBytes ()
 

Variables

omBin om_StickyBins = NULL
 

Macro Definition Documentation

◆ om_LargeBin

#define om_LargeBin   ((omBin) 1)

Definition at line 25 of file omBin.c.

◆ omGetStickyBin

#define omGetStickyBin (   bin,
  sticky_tag 
)     omFindInGList(bin, next, sticky, sticky_tag)

Definition at line 193 of file omBin.c.

Function Documentation

◆ _omGetSpecBin()

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

Definition at line 26 of file omBin.c.

28{
29 omBin om_new_specBin;
30 long max_blocks;
31 long sizeW;
32
33
34 size = OM_ALIGN_SIZE(size);
35#ifdef OM_ALIGNMENT_NEEDS_WORK
36 if (align || size >= OM_SIZEOF_UNIQUE_MAX_BLOCK_THRESHOLD)
37 {
38 align = 1;
39 size = OM_STRICT_ALIGN_SIZE(size);
40 }
41#else
42 align = 0;
43#endif
44
46 {
47 /* need page header */
48 max_blocks = - (long)
49 ((size+(SIZEOF_SYSTEM_PAGE-SIZEOF_OM_BIN_PAGE))+SIZEOF_SYSTEM_PAGE-1)
50 / SIZEOF_SYSTEM_PAGE;
51 sizeW = ((-max_blocks*SIZEOF_SYSTEM_PAGE) -
52 (SIZEOF_SYSTEM_PAGE - SIZEOF_OM_BIN_PAGE)) / SIZEOF_LONG;
53 om_new_specBin = om_LargeBin;
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 {
76 om_new_specBin = om_LargeBin;
77 }
78#ifdef OM_ALIGNMENT_NEEDS_WORK
79 else if (align)
80 {
81 om_new_specBin = omSmallSize2AlignedBin( size );
82 }
83#endif
84#ifdef OM_HAVE_TRACK
85 else if (track)
86 {
87 om_new_specBin = omSmallSize2TrackBin( size );
88 }
89#endif
90 else
91 {
92 om_new_specBin = omSmallSize2Bin( size );
93 }
94 }
95
96 if (om_new_specBin == om_LargeBin ||
97 om_new_specBin->max_blocks < max_blocks)
98 {
99 omSpecBin s_bin;
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 {
129 om_SpecTrackBin = omInsertInSortedGList(om_SpecTrackBin, next, max_blocks, s_bin);
130 }
131 else
132#endif
133 om_SpecBin = omInsertInSortedGList(om_SpecBin, next, max_blocks, s_bin);
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)
Definition: omAllocDecl.h:210
#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
omBinPage_t om_ZeroPage[]
Definition: om_Alloc.c:19
omSpecBin om_SpecBin
Definition: om_Alloc.c:20
#define omSmallSize2AlignedBin
Definition: omtTestAlloc.c:29

◆ _omUnGetSpecBin()

void _omUnGetSpecBin ( omBin bin_p,
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
150 omSpecBin s_bin;
151
152#ifdef OM_HAVE_TRACK
153 s_bin = omFindInGList(om_SpecTrackBin, next, bin, bin);
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
169 omFreeKeptAddrFromBin(s_bin->bin);
170 if(s_bin->bin->last_page == NULL || force)
171 {
172#ifdef OM_HAVE_TRACK
173 if (track_bin)
174 om_SpecTrackBin = omRemoveFromSortedGList(om_SpecTrackBin, next, max_blocks, s_bin);
175 else
176#endif
177 om_SpecBin = omRemoveFromSortedGList(om_SpecBin, next, max_blocks, s_bin);
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)
Definition: omAllocDecl.h:260
#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

◆ omCreateStickyBin()

static omBin omCreateStickyBin ( omBin  bin,
unsigned long  sticky 
)
static

Definition at line 196 of file omBin.c.

197{
198 omBin s_bin = (omBin) omAlloc(sizeof(omBin_t));
199 s_bin->sticky = sticky;
200 s_bin->current_page = om_ZeroPage;
201 s_bin->last_page = NULL;
202 s_bin->max_blocks = bin->max_blocks;
203 s_bin->sizeW = bin->sizeW;
204 s_bin->next = bin->next;
205 bin->next = s_bin;
206 return s_bin;
207}

◆ omDeleteStickyAllBinTag()

void omDeleteStickyAllBinTag ( unsigned long  sticky)

Definition at line 570 of file omBin.c.

571{
572 omSpecBin s_bin = om_SpecBin;
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
omBin_t om_StaticBin[]
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{
341 omBin no_sticky_bin = NULL;
342 omBin sticky_bin = NULL;
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 {
353 no_sticky_bin = omGetStickyBin(bin, 0);
354 omAssume(no_sticky_bin != NULL && sticky_bin != no_sticky_bin);
355
356 omMergeStickyPages(no_sticky_bin, sticky_bin);
357
358 if (bin == sticky_bin)
359 {
360 sticky_bin = no_sticky_bin;
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

◆ omGetBinStat()

static void omGetBinStat ( omBin  bin,
long *  pages_p,
long *  used_blocks_p,
long *  free_blocks_p 
)
static

Definition at line 611 of file omBin.c.

613{
614 long pages = 0, used_blocks = 0, free_blocks = 0;
615 int where = 1;
616
617 omBinPage page = bin->last_page;
618 while (page != NULL)
619 {
620 pages++; if (where == 1)
621 {
622 used_blocks += omGetUsedBlocksOfPage(page) + 1;
623 if (bin->max_blocks > 0)
624 free_blocks += bin->max_blocks - omGetUsedBlocksOfPage(page) -1;
625 }
626 else
627 {
628 if (bin->max_blocks > 1)
629 used_blocks += bin->max_blocks;
630 else
631 used_blocks++;
632 }
633 if (page == bin->current_page) where = -1;
634 page = page->prev;
635 }
636 *pages_p = pages;
637 *used_blocks_p = used_blocks;
638 *free_blocks_p = free_blocks;
639}
#define omGetUsedBlocksOfPage(page)
Definition: omDebug.h:88
omBinPage_t * omBinPage
Definition: omStructs.h:16

◆ omGetMaxStickyBinTag()

unsigned long omGetMaxStickyBinTag ( omBin  bin)

Definition at line 209 of file omBin.c.

210{
211 unsigned long sticky = 0;
212 do
213 {
214 if (bin->sticky > sticky) sticky = bin->sticky;
215 bin = bin->next;
216 }
217 while (bin != NULL);
218 return sticky;
219}

◆ omGetNewStickyAllBinTag()

unsigned long omGetNewStickyAllBinTag ( void  )

Definition at line 486 of file omBin.c.

487{
488 unsigned long sticky = 0, new_sticky;
489 int i;
490 omSpecBin s_bin;
491 // first, find new sticky tag
492 for (i=0; i<=OM_MAX_BIN_INDEX; i++)
493 {
494 new_sticky = omGetMaxStickyBinTag(&(om_StaticBin[i]));
495 if (new_sticky > sticky) sticky = new_sticky;
496 }
497 s_bin = om_SpecBin;
498 while (s_bin != NULL)
499 {
500 new_sticky = omGetMaxStickyBinTag(s_bin->bin);
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 }
511 s_bin = om_SpecBin;
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 }
529 s_bin = om_SpecBin;
530 while (s_bin != NULL)
531 {
532 if (omGetStickyBin(s_bin->bin, BIT_SIZEOF_LONG -1) == NULL)
533 omCreateStickyBin(s_bin->bin, BIT_SIZEOF_LONG -1);
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;
383 om_StickyBins = new_bin;
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

◆ omGetTotalBinStat()

static void omGetTotalBinStat ( omBin  bin,
long *  pages_p,
long *  used_blocks_p,
long *  free_blocks_p 
)
static

Definition at line 641 of file omBin.c.

643{
644 long t_pages = 0, t_used_blocks = 0, t_free_blocks = 0;
645 long pages = 0, used_blocks = 0, free_blocks = 0;
646
647 while (bin != NULL)
648 {
649 omGetBinStat(bin, &pages, &used_blocks, &free_blocks);
650 t_pages += pages;
651 t_used_blocks += used_blocks;
652 t_free_blocks += free_blocks;
653 if (!omIsStickyBin(bin))
654 bin = bin->next;
655 else
656 bin = NULL;
657 }
658 *pages_p = t_pages;
659 *used_blocks_p = t_used_blocks;
660 *free_blocks_p = t_free_blocks;
661}
static void omGetBinStat(omBin bin, long *pages_p, long *used_blocks_p, long *free_blocks_p)
Definition: omBin.c:611

◆ omGetUsedBinBytes()

long omGetUsedBinBytes ( void  )

Definition at line 763 of file omBin.c.

764{
765 int i = OM_MAX_BIN_INDEX;
766 omSpecBin s_bin = om_SpecBin;
767 long used = 0;
768 omBin sticky;
769
770 for (; i>=0; i--)
771 {
773 }
774 while (s_bin != NULL)
775 {
776 used += omGetUsedBytesOfBin(s_bin->bin);
777 s_bin = s_bin->next;
778 }
779#ifdef OM_HAVE_TRACK
780 for (i=OM_MAX_BIN_INDEX; i>=0; i--)
781 {
782 used += omGetUsedBytesOfBin(&om_StaticTrackBin[i]);
783 }
784 s_bin = om_SpecTrackBin;
785 while (s_bin != NULL)
786 {
787 used += omGetUsedBytesOfBin(s_bin->bin);
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

◆ omGetUsedBytesOfBin()

static long omGetUsedBytesOfBin ( omBin  bin)
static

Definition at line 756 of file omBin.c.

757{
758 long pages = 0, used_blocks = 0, free_blocks = 0;
759 omGetTotalBinStat(bin, &pages, &used_blocks, &free_blocks);
760 return (used_blocks)*((long)bin->sizeW)*SIZEOF_LONG;
761}
static void omGetTotalBinStat(omBin bin, long *pages_p, long *used_blocks_p, long *free_blocks_p)
Definition: omBin.c:641

◆ omIsKnownTopBin()

int omIsKnownTopBin ( omBin  bin,
int  normal_bin 
)

Definition at line 442 of file omBin.c.

443{
444 omBin to_check;
445 omSpecBin s_bin;
446 int i;
447
448 omAssume(normal_bin == 1 || normal_bin == 0);
449
450#ifdef OM_HAVE_TRACK
451 if (! normal_bin)
452 {
453 to_check = om_StaticTrackBin;
454 s_bin = om_SpecTrackBin;
455 }
456 else
457#endif
458 {
459 omAssume(normal_bin);
460 to_check = om_StaticBin;
461 s_bin = om_SpecBin;
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 }
475 to_check = om_StickyBins;
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{
400 if (! omIsOnGList(om_StickyBins, next, sticky_bin) ||
401 !sticky_bin->sticky ||
402 sticky_bin->max_blocks != into_bin->max_blocks ||
403 sticky_bin == into_bin ||
404 !omIsKnownTopBin(into_bin, 1) ||
405 omIsStickyBin(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 }
419 omFreeKeptAddrFromBin(sticky_bin);
421 omMergeStickyPages(into_bin, sticky_bin);
422
423#if 0
424 if (! omIsStaticBin(into_bin))
425 {
426 omBin _ibin = into_bin;
427 omUnGetSpecBin(&_ibin);
428 }
429#endif
430 omFreeSize(sticky_bin, sizeof(omBin_t));
431#if defined(OM_INTERNAL_DEBUG) && !defined(OM_NDEBUG)
432 omTestBin(into_bin, 2);
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

◆ omMergeStickyPages()

static void omMergeStickyPages ( omBin  to_bin,
omBin  from_bin 
)
static

Definition at line 267 of file omBin.c.

268{
269#ifdef HAVE_OM_ASSUME
270 int length = omGListLength(to_bin->last_page, prev) +
271 omGListLength(from_bin->last_page, prev);
272#endif
273
274 omBinPage page = from_bin->last_page;
275 omAssume(to_bin->sizeW == from_bin->sizeW);
276 omAssume(to_bin != from_bin);
277
278 if (page == NULL) return;
279 do
280 {
281 omSetTopBinAndStickyOfPage(page, to_bin, to_bin->sticky);
282 if (page->prev == NULL) break;
283 page = page->prev;
284 }
285 while(1);
286
287 if (to_bin->last_page == NULL)
288 {
289 omAssume(to_bin->current_page == om_ZeroPage);
290 to_bin->last_page = from_bin->last_page;
291 to_bin->current_page = from_bin->current_page;
292 return;
293 }
294
295 omAssume(to_bin->current_page != om_ZeroPage &&
296 to_bin->current_page != NULL);
297
298 if (to_bin->current_page->current != NULL)
299 {
300 if (to_bin->current_page->prev == NULL)
301 {
302 from_bin->last_page->next = to_bin->current_page;
303 to_bin->current_page->prev = from_bin->last_page;
304 to_bin->current_page = from_bin->current_page;
305 return;
306 }
307 to_bin->current_page = to_bin->current_page->prev;
308 }
309 else
310 {
311 /* need to reset this here, since new current_page is going to be
312 from_bin->current_page, and only for current_page may we have
313 used_blocks != 0 && current == NULL */
314 to_bin->current_page->used_blocks = 0;
315 }
316
317
318 omAssume(to_bin->current_page != NULL &&
319 to_bin->current_page->current == NULL &&
320 to_bin->current_page->used_blocks == 0);
321
322 from_bin->last_page->next = to_bin->current_page->next;
323 if (to_bin->current_page->next != NULL)
324 to_bin->current_page->next->prev = from_bin->last_page;
325 else
326 {
327 omAssume(to_bin->current_page == to_bin->last_page);
328 to_bin->last_page = from_bin->last_page;
329 }
330 to_bin->current_page->next = page;
331 page->prev = to_bin->current_page;
332 to_bin->current_page = from_bin->current_page;
333
334#ifdef HAVE_OM_ASSUME
335 omAssume(omGListLength(to_bin->last_page, prev) == length);
336#endif
337}
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
#define omSetTopBinAndStickyOfPage(page, bin, sticky)
#define omGListLength(ptr, next)
Definition: omList.h:94

◆ omPrintBinStat()

static void omPrintBinStat ( FILE *  fd,
omBin  bin,
int  track,
long *  pages,
long *  used_blocks,
long *  free_blocks 
)
static

Definition at line 663 of file omBin.c.

664{
665 if (track)
666 {
667 fputs("T \t \t",fd);
668 }
669 else
670 {
671 fprintf(fd, "%s%ld\t%ld\t", (omIsStaticNormalBin(bin) ? " " :
672 (omIsStickyBin(bin) ? "S" :
673 (omIsTrackBin(bin) ? "T" : "*"))),
674 (long)bin->sizeW, bin->max_blocks);
675 }
676 omGetTotalBinStat(bin, pages, used_blocks, free_blocks);
677 fprintf(fd, "%ld\t%ld\t%ld\n", *pages, *free_blocks, *used_blocks);
678 if (bin->next != NULL && !omIsStickyBin(bin))
679 {
680 long s_pages, s_free_blocks, s_used_blocks;
681 while (bin != NULL)
682 {
683 omGetBinStat(bin, &s_pages, &s_used_blocks, &s_free_blocks);
684 fprintf(fd, " \t \t%ld\t%ld\t%ld\t%d\n", s_pages, s_free_blocks, s_used_blocks,
685 (int) bin->sticky);
686 bin = bin->next;
687 *pages += s_pages;
688 *used_blocks += s_used_blocks;
689 *free_blocks += s_free_blocks;
690 }
691 }
692}
#define omIsStaticNormalBin(bin)
Definition: omBin.h:43
#define omIsTrackBin(bin)
Definition: omBin.h:57
int status int fd
Definition: si_signals.h:59

◆ 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;
698 long pages_p, used_blocks_p, free_blocks_p;
699 omSpecBin s_bin = om_SpecBin;
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 {
708 omPrintBinStat(fd, &om_StaticBin[i], 0, &pages_p, &used_blocks_p, &free_blocks_p);
709 pages += pages_p;
710 used_blocks += used_blocks_p;
711 free_blocks += free_blocks_p;
712#ifdef OM_HAVE_TRACK
713 if (om_StaticTrackBin[i].current_page != om_ZeroPage)
714 {
715 omPrintBinStat(fd, &om_StaticTrackBin[i], 1, &pages_p, &used_blocks_p, &free_blocks_p);
716 pages += pages_p;
717 used_blocks += used_blocks_p;
718 free_blocks += free_blocks_p;
719 }
720#endif
721 i--;
722 }
723 else
724 {
725 omPrintBinStat(fd, s_bin->bin,0, &pages_p, &used_blocks_p, &free_blocks_p);
726 pages += pages_p;
727 used_blocks += used_blocks_p;
728 free_blocks += free_blocks_p;
729 s_bin = s_bin->next;
730 }
731 }
732#ifdef OM_HAVE_TRACK
733 s_bin = om_SpecTrackBin;
734 while (s_bin != NULL)
735 {
736 omPrintBinStat(fd, s_bin->bin, 0, &pages_p, &used_blocks_p, &free_blocks_p);
737 s_bin = s_bin->next;
738 pages += pages_p;
739 used_blocks += used_blocks_p;
740 free_blocks += free_blocks_p;
741 }
742#endif
743 sticky = om_StickyBins;
744 while (sticky != NULL)
745 {
746 omPrintBinStat(fd, sticky, 0, &pages_p, &used_blocks_p, &free_blocks_p);
747 sticky = sticky->next;
748 pages += pages_p;
749 used_blocks += used_blocks_p;
750 free_blocks += free_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

◆ omSetStickyAllBinTag()

void omSetStickyAllBinTag ( unsigned long  sticky)

Definition at line 540 of file omBin.c.

541{
542 omSpecBin s_bin = om_SpecBin;
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_tag 
)

Definition at line 237 of file omBin.c.

238{
239 omBin s_bin;
240 s_bin = omGetStickyBin(bin, sticky_tag);
241
242 if (s_bin != bin)
243 {
244 omBinPage tc, tl;
245 unsigned long ts;
246
247 if (s_bin == NULL) s_bin = omCreateStickyBin(bin, sticky_tag);
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}

◆ omUnSetStickyAllBinTag()

void omUnSetStickyAllBinTag ( unsigned long  sticky)

Definition at line 555 of file omBin.c.

556{
557 omSpecBin s_bin = om_SpecBin;
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}

Variable Documentation

◆ om_StickyBins

omBin om_StickyBins = NULL

Definition at line 374 of file omBin.c.