My Project  debian-1:4.1.1-p2+ds-4build3
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 24 of file omBin.c.

◆ omGetStickyBin

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

Definition at line 192 of file omBin.c.

Function Documentation

◆ _omGetSpecBin()

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

Definition at line 24 of file omBin.c.

26 {
27  omBin om_new_specBin;
28  long max_blocks;
29  long sizeW;
30 
31 
32  size = OM_ALIGN_SIZE(size);
33 #ifdef OM_ALIGNMENT_NEEDS_WORK
35  {
36  align = 1;
37  size = OM_STRICT_ALIGN_SIZE(size);
38  }
39 #else
40  align = 0;
41 #endif
42 
44  {
45  /* need page header */
46  max_blocks = - (long)
47  ((size+(SIZEOF_SYSTEM_PAGE-SIZEOF_OM_BIN_PAGE))+SIZEOF_SYSTEM_PAGE-1)
48  / SIZEOF_SYSTEM_PAGE;
49  sizeW = ((-max_blocks*SIZEOF_SYSTEM_PAGE) -
50  (SIZEOF_SYSTEM_PAGE - SIZEOF_OM_BIN_PAGE)) / SIZEOF_LONG;
51  om_new_specBin = om_LargeBin;
52  }
53  else
54  {
55  /* SIZEOF_OM_BIN_PAGE == max_blocks*size + r1; r1 < size */
56  /* r1 = max_blocks*(size_padding) + r2; r2 < max_blocks */
57  max_blocks = SIZEOF_OM_BIN_PAGE / size;
58  sizeW = (SIZEOF_OM_BIN_PAGE % size) / max_blocks;
59 #ifdef OM_ALIGNMENT_NEEDS_WORK
60  if (align)
61  sizeW = ((size + sizeW) & ~ (SIZEOF_STRICT_ALIGNMENT - 1));
62  else
63 #endif
64  sizeW = ((size + sizeW) & ~ (SIZEOF_OM_ALIGNMENT - 1));
65 
66  omAssume(sizeW >= size);
67  omAssume(max_blocks*sizeW <= SIZEOF_OM_BIN_PAGE);
68  omAssume((max_blocks+1)*sizeW > SIZEOF_OM_BIN_PAGE ||
69  max_blocks*(sizeW + SIZEOF_STRICT_ALIGNMENT) > SIZEOF_OM_BIN_PAGE);
70 
71  sizeW = sizeW >> LOG_SIZEOF_LONG;
72  if (size > OM_MAX_BLOCK_SIZE)
73  {
74  om_new_specBin = om_LargeBin;
75  }
76 #ifdef OM_ALIGNMENT_NEEDS_WORK
77  else if (align)
78  {
79  om_new_specBin = omSmallSize2AlignedBin( size );
80  }
81 #endif
82 #ifdef OM_HAVE_TRACK
83  else if (track)
84  {
85  om_new_specBin = omSmallSize2TrackBin( size );
86  }
87 #endif
88  else
89  {
90  om_new_specBin = omSmallSize2Bin( size );
91  }
92  }
93 
94  if (om_new_specBin == om_LargeBin ||
95  om_new_specBin->max_blocks < max_blocks)
96  {
97  omSpecBin s_bin;
98 #ifdef OM_HAVE_TRACK
99  if (track)
100  s_bin = omFindInSortedGList(om_SpecTrackBin, next, max_blocks, max_blocks);
101  else
102 #endif
103  s_bin = omFindInSortedGList(om_SpecBin, next, max_blocks, max_blocks);
104 
105  if (s_bin != NULL)
106  {
107  (s_bin->ref)++;
108  omAssume(s_bin->bin != NULL &&
109  s_bin->bin->max_blocks == s_bin->max_blocks &&
110  s_bin->bin->sizeW == sizeW);
111  return s_bin->bin;
112  }
113  s_bin = (omSpecBin) omAlloc(sizeof(omSpecBin_t));
114  s_bin->ref = 1;
115  s_bin->next = NULL;
116  s_bin->max_blocks = max_blocks;
117  s_bin->bin = (omBin) omAlloc(sizeof(omBin_t));
118  s_bin->bin->current_page = om_ZeroPage;
119  s_bin->bin->last_page = NULL;
120  s_bin->bin->next = NULL;
121  s_bin->bin->sizeW = sizeW;
122  s_bin->bin->max_blocks = max_blocks;
123  s_bin->bin->sticky = 0;
124 #ifdef OM_HAVE_TRACK
125  if (track)
126  {
127  om_SpecTrackBin = omInsertInSortedGList(om_SpecTrackBin, next, max_blocks, s_bin);
128  }
129  else
130 #endif
131  om_SpecBin = omInsertInSortedGList(om_SpecBin, next, max_blocks, s_bin);
132  return s_bin->bin;
133  }
134  else
135  {
136  return om_new_specBin;
137  }
138 }

◆ _omUnGetSpecBin()

void _omUnGetSpecBin ( omBin bin_p,
int  force 
)

Definition at line 140 of file omBin.c.

141 {
142  omBin bin = *bin_p;
143  if (! omIsStaticBin(bin))
144  {
145 #ifdef OM_HAVE_TRACK
146  int track_bin = 0;
147 #endif
148  omSpecBin s_bin;
149 
150 #ifdef OM_HAVE_TRACK
151  s_bin = omFindInGList(om_SpecTrackBin, next, bin, bin);
152  if (s_bin != NULL)
153  track_bin = 1;
154  else
155 #endif
156  s_bin = omFindInSortedGList(om_SpecBin, next, max_blocks, bin->max_blocks);
157 
158  omAssume(s_bin != NULL && bin == s_bin->bin);
159  if (s_bin != NULL)
160  {
161  (s_bin->ref)--;
162  if (s_bin->ref == 0 || force)
163  {
164 #ifdef OM_HAVE_TRACK
165  if (! track_bin)
166 #endif
167  omFreeKeptAddrFromBin(s_bin->bin);
168  if(s_bin->bin->last_page == NULL || force)
169  {
170 #ifdef OM_HAVE_TRACK
171  if (track_bin)
172  om_SpecTrackBin = omRemoveFromSortedGList(om_SpecTrackBin, next, max_blocks, s_bin);
173  else
174 #endif
175  om_SpecBin = omRemoveFromSortedGList(om_SpecBin, next, max_blocks, s_bin);
176  omFreeSize(s_bin->bin, sizeof(omBin_t));
177  omFreeSize(s_bin, sizeof(omSpecBin_t));
178  }
179  }
180  }
181  }
182  *bin_p = NULL;
183 }

◆ omCreateStickyBin()

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

Definition at line 194 of file omBin.c.

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

◆ omDeleteStickyAllBinTag()

void omDeleteStickyAllBinTag ( unsigned long  sticky)

Definition at line 568 of file omBin.c.

569 {
570  omSpecBin s_bin = om_SpecBin;
571  int i;
572  for (i=0; i<=OM_MAX_BIN_INDEX; i++)
573  {
574  omDeleteStickyBinTag(&(om_StaticBin[i]), sticky);
575  }
576  while (s_bin != NULL)
577  {
578  omDeleteStickyBinTag(s_bin->bin, sticky);
579  s_bin = s_bin->next;
580  }
581 }

◆ omDeleteStickyBinTag()

void omDeleteStickyBinTag ( omBin  bin,
unsigned long  sticky 
)

Definition at line 337 of file omBin.c.

338 {
339  omBin no_sticky_bin = NULL;
340  omBin sticky_bin = NULL;
341 
342  if (sticky == 0)
343  {
344  omAssume(0);
345  return;
346  }
347 
348  sticky_bin = omGetStickyBin(bin, sticky);
349  if (sticky_bin != NULL)
350  {
351  no_sticky_bin = omGetStickyBin(bin, 0);
352  omAssume(no_sticky_bin != NULL && sticky_bin != no_sticky_bin);
353 
354  omMergeStickyPages(no_sticky_bin, sticky_bin);
355 
356  if (bin == sticky_bin)
357  {
358  sticky_bin = no_sticky_bin;
359  omSetStickyBinTag(bin, 0);
360  }
361  bin->next = omRemoveFromGList(bin->next, next, sticky_bin);
362  omFreeSize(sticky_bin, sizeof(omBin_t));
363  }
364 }

◆ omGetBinStat()

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

Definition at line 609 of file omBin.c.

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

◆ omGetMaxStickyBinTag()

unsigned long omGetMaxStickyBinTag ( omBin  bin)

Definition at line 207 of file omBin.c.

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

◆ omGetNewStickyAllBinTag()

unsigned long omGetNewStickyAllBinTag ( )

Definition at line 484 of file omBin.c.

485 {
486  unsigned long sticky = 0, new_sticky;
487  int i;
488  omSpecBin s_bin;
489  // first, find new sticky tag
490  for (i=0; i<=OM_MAX_BIN_INDEX; i++)
491  {
492  new_sticky = omGetMaxStickyBinTag(&(om_StaticBin[i]));
493  if (new_sticky > sticky) sticky = new_sticky;
494  }
495  s_bin = om_SpecBin;
496  while (s_bin != NULL)
497  {
498  new_sticky = omGetMaxStickyBinTag(s_bin->bin);
499  if (new_sticky > sticky) sticky = new_sticky;
500  s_bin = s_bin->next;
501  }
502  if (sticky < BIT_SIZEOF_LONG - 2)
503  {
504  sticky++;
505  for (i=0; i<=OM_MAX_BIN_INDEX; i++)
506  {
507  omCreateStickyBin(&(om_StaticBin[i]), sticky);
508  }
509  s_bin = om_SpecBin;
510  while (s_bin != NULL)
511  {
512  omCreateStickyBin(s_bin->bin, sticky);
513  s_bin = s_bin->next;
514  }
515  return sticky;
516  }
517  else
518  {
519  omBin bin;
520  omAssume(sticky == BIT_SIZEOF_LONG - 1);
521  for (i=0; i<=OM_MAX_BIN_INDEX; i++)
522  {
523  bin = &om_StaticBin[i];
524  if (omGetStickyBin(bin, BIT_SIZEOF_LONG -1) == NULL)
526  }
527  s_bin = om_SpecBin;
528  while (s_bin != NULL)
529  {
530  if (omGetStickyBin(s_bin->bin, BIT_SIZEOF_LONG -1) == NULL)
531  omCreateStickyBin(s_bin->bin, BIT_SIZEOF_LONG -1);
532  s_bin = s_bin->next;
533  }
534  return BIT_SIZEOF_LONG - 1;
535  }
536 }

◆ omGetNewStickyBinTag()

unsigned long omGetNewStickyBinTag ( omBin  bin)

Definition at line 219 of file omBin.c.

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

◆ omGetStickyBinOfBin()

omBin omGetStickyBinOfBin ( omBin  bin)

Definition at line 373 of file omBin.c.

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

◆ omGetTotalBinStat()

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

Definition at line 639 of file omBin.c.

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

◆ omGetUsedBinBytes()

long omGetUsedBinBytes ( )

Definition at line 761 of file omBin.c.

762 {
763  int i = OM_MAX_BIN_INDEX;
764  omSpecBin s_bin = om_SpecBin;
765  long used = 0;
766  omBin sticky;
767 
768  for (; i>=0; i--)
769  {
771  }
772  while (s_bin != NULL)
773  {
774  used += omGetUsedBytesOfBin(s_bin->bin);
775  s_bin = s_bin->next;
776  }
777 #ifdef OM_HAVE_TRACK
778  for (i=OM_MAX_BIN_INDEX; i>=0; i--)
779  {
780  used += omGetUsedBytesOfBin(&om_StaticTrackBin[i]);
781  }
782  s_bin = om_SpecTrackBin;
783  while (s_bin != NULL)
784  {
785  used += omGetUsedBytesOfBin(s_bin->bin);
786  s_bin = s_bin->next;
787  }
788 #endif
789 
790  sticky = om_StickyBins;
791  while (sticky != NULL)
792  {
793  used += omGetUsedBytesOfBin(sticky);
794  sticky = sticky->next;
795  }
796  return used;
797 }

◆ omGetUsedBytesOfBin()

static long omGetUsedBytesOfBin ( omBin  bin)
static

Definition at line 754 of file omBin.c.

755 {
756  long pages = 0, used_blocks = 0, free_blocks = 0;
757  omGetTotalBinStat(bin, &pages, &used_blocks, &free_blocks);
758  return (used_blocks)*((long)bin->sizeW)*SIZEOF_LONG;
759 }

◆ omIsKnownTopBin()

int omIsKnownTopBin ( omBin  bin,
int  normal_bin 
)

Definition at line 440 of file omBin.c.

441 {
442  omBin to_check;
443  omSpecBin s_bin;
444  int i;
445 
446  omAssume(normal_bin == 1 || normal_bin == 0);
447 
448 #ifdef OM_HAVE_TRACK
449  if (! normal_bin)
450  {
451  to_check = om_StaticTrackBin;
452  s_bin = om_SpecTrackBin;
453  }
454  else
455 #endif
456  {
457  omAssume(normal_bin);
458  to_check = om_StaticBin;
459  s_bin = om_SpecBin;
460  }
461 
462  for (i=0; i<= OM_MAX_BIN_INDEX; i++)
463  {
464  if (bin == &(to_check[i]))
465  return 1;
466  }
467 
468  while (s_bin != NULL)
469  {
470  if (bin == s_bin->bin) return 1;
471  s_bin = s_bin->next;
472  }
473  to_check = om_StickyBins;
474 
475  while (to_check != NULL)
476  {
477  if (bin == to_check) return 1;
478  to_check = to_check->next;
479  }
480  return 0;
481 }

◆ omMergeStickyBinIntoBin()

void omMergeStickyBinIntoBin ( omBin  sticky_bin,
omBin  into_bin 
)

Definition at line 396 of file omBin.c.

397 {
398  if (! omIsOnGList(om_StickyBins, next, sticky_bin) ||
399  !sticky_bin->sticky ||
400  sticky_bin->max_blocks != into_bin->max_blocks ||
401  sticky_bin == into_bin ||
402  !omIsKnownTopBin(into_bin, 1) ||
403  omIsStickyBin(into_bin))
404  {
405 #ifndef OM_NDEBUG
407  (! omIsOnGList(om_StickyBins, next, sticky_bin) ? "unknown sticky_bin" :
408  (!sticky_bin->sticky ? "sticky_bin is not sticky" :
409  (sticky_bin->max_blocks != into_bin->max_blocks ? "sticky_bin and into_bin have different block sizes" :
410  (sticky_bin == into_bin ? "sticky_bin == into_bin" :
411  (!omIsKnownTopBin(into_bin, 1) ? "unknown into_bin" :
412  (omIsStickyBin(into_bin) ? "into_bin is sticky" :
413  "unknown sticky_bin error")))))));
414 #endif
415  return;
416  }
417  omFreeKeptAddrFromBin(sticky_bin);
419  omMergeStickyPages(into_bin, sticky_bin);
420 
421 #if 0
422  if (! omIsStaticBin(into_bin))
423  {
424  omBin _ibin = into_bin;
425  omUnGetSpecBin(&_ibin);
426  }
427 #endif
428  omFreeSize(sticky_bin, sizeof(omBin_t));
429 #if defined(OM_INTERNAL_DEBUG) && !defined(OM_NDEBUG)
430  omTestBin(into_bin, 2);
431 #endif
432 }

◆ omMergeStickyPages()

static void omMergeStickyPages ( omBin  to_bin,
omBin  from_bin 
)
static

Definition at line 265 of file omBin.c.

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

◆ omPrintBinStat()

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

Definition at line 661 of file omBin.c.

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

◆ omPrintBinStats()

void omPrintBinStats ( FILE *  fd)

Definition at line 692 of file omBin.c.

693 {
694  int i = OM_MAX_BIN_INDEX;
695  long pages=0, used_blocks=0, free_blocks=0;
696  long pages_p, used_blocks_p, free_blocks_p;
697  omSpecBin s_bin = om_SpecBin;
698  omBin sticky;
699 
700  fputs(" SizeW\tBlocks\tUPages\tFBlocks\tUBlocks\tSticky\n",fd);
701  fflush(fd);
702  while (s_bin != NULL || i >= 0)
703  {
704  if (s_bin == NULL || (i >= 0 && (unsigned long) om_StaticBin[i].max_blocks < (unsigned long) s_bin->bin->max_blocks))
705  {
706  omPrintBinStat(fd, &om_StaticBin[i], 0, &pages_p, &used_blocks_p, &free_blocks_p);
707  pages += pages_p;
708  used_blocks += used_blocks_p;
709  free_blocks += free_blocks_p;
710 #ifdef OM_HAVE_TRACK
711  if (om_StaticTrackBin[i].current_page != om_ZeroPage)
712  {
713  omPrintBinStat(fd, &om_StaticTrackBin[i], 1, &pages_p, &used_blocks_p, &free_blocks_p);
714  pages += pages_p;
715  used_blocks += used_blocks_p;
716  free_blocks += free_blocks_p;
717  }
718 #endif
719  i--;
720  }
721  else
722  {
723  omPrintBinStat(fd, s_bin->bin,0, &pages_p, &used_blocks_p, &free_blocks_p);
724  pages += pages_p;
725  used_blocks += used_blocks_p;
726  free_blocks += free_blocks_p;
727  s_bin = s_bin->next;
728  }
729  }
730 #ifdef OM_HAVE_TRACK
731  s_bin = om_SpecTrackBin;
732  while (s_bin != NULL)
733  {
734  omPrintBinStat(fd, s_bin->bin, 0, &pages_p, &used_blocks_p, &free_blocks_p);
735  s_bin = s_bin->next;
736  pages += pages_p;
737  used_blocks += used_blocks_p;
738  free_blocks += free_blocks_p;
739  }
740 #endif
741  sticky = om_StickyBins;
742  while (sticky != NULL)
743  {
744  omPrintBinStat(fd, sticky, 0, &pages_p, &used_blocks_p, &free_blocks_p);
745  sticky = sticky->next;
746  pages += pages_p;
747  used_blocks += used_blocks_p;
748  free_blocks += free_blocks_p;
749  }
750  fputs("----------------------------------------\n",fd);
751  fprintf(fd, " \t \t%ld\t%ld\t%ld\n", pages, free_blocks, used_blocks);
752 }

◆ omSetStickyAllBinTag()

void omSetStickyAllBinTag ( unsigned long  sticky)

Definition at line 538 of file omBin.c.

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

◆ omSetStickyBinTag()

void omSetStickyBinTag ( omBin  bin,
unsigned long  sticky_tag 
)

Definition at line 235 of file omBin.c.

236 {
237  omBin s_bin;
238  s_bin = omGetStickyBin(bin, sticky_tag);
239 
240  if (s_bin != bin)
241  {
242  omBinPage tc, tl;
243  unsigned long ts;
244 
245  if (s_bin == NULL) s_bin = omCreateStickyBin(bin, sticky_tag);
246  ts = bin->sticky;
247  tl = bin->last_page;
248  tc = bin->current_page;
249  bin->sticky = s_bin->sticky;
250  bin->current_page = s_bin->current_page;
251  bin->last_page = s_bin->last_page;
252  s_bin->sticky = ts;
253  s_bin->last_page = tl;
254  s_bin->current_page = tc;
255  }
256 }

◆ omUnSetStickyAllBinTag()

void omUnSetStickyAllBinTag ( unsigned long  sticky)

Definition at line 553 of file omBin.c.

554 {
555  omSpecBin s_bin = om_SpecBin;
556  int i;
557  for (i=0; i<=OM_MAX_BIN_INDEX; i++)
558  {
559  omUnSetStickyBinTag(&(om_StaticBin[i]), sticky);
560  }
561  while (s_bin != NULL)
562  {
563  omUnSetStickyBinTag(s_bin->bin, sticky);
564  s_bin = s_bin->next;
565  }
566 }

◆ omUnSetStickyBinTag()

void omUnSetStickyBinTag ( omBin  bin,
unsigned long  sticky 
)

Definition at line 258 of file omBin.c.

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

Variable Documentation

◆ om_StickyBins

omBin om_StickyBins = NULL

Definition at line 372 of file omBin.c.

BIT_SIZEOF_LONG
#define BIT_SIZEOF_LONG
Definition: auxiliary.h:78
omFreeKeptAddrFromBin
void omFreeKeptAddrFromBin(omBin bin)
Definition: omDebug.c:542
om_StickyBins
omBin om_StickyBins
Definition: omBin.c:372
omDeleteStickyBinTag
void omDeleteStickyBinTag(omBin bin, unsigned long sticky)
Definition: omBin.c:337
omSetTopBinAndStickyOfPage
#define omSetTopBinAndStickyOfPage(page, bin, sticky)
Definition: omAllocPrivate.h:74
omPrintBinStat
static void omPrintBinStat(FILE *fd, omBin bin, int track, long *pages, long *used_blocks, long *free_blocks)
Definition: omBin.c:661
omIsOnGList
#define omIsOnGList(ptr, next, addr)
Definition: omList.h:100
omIsStaticBin
#define omIsStaticBin(bin)
Definition: omBin.h:59
omReportError
omError_t omReportError(omError_t error, omError_t report_error, OM_FLR_DECL, const char *fmt,...)
Definition: omError.c:78
length
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:267
omRemoveFromGList
#define omRemoveFromGList(ptr, next, addr)
Definition: omList.h:102
omIsSpecBin
#define omIsSpecBin(bin)
Definition: omBin.h:47
omSmallSize2AlignedBin
#define omSmallSize2AlignedBin
Definition: omtTestAlloc.c:29
omGetUsedBlocksOfPage
#define omGetUsedBlocksOfPage(page)
Definition: omDebug.h:88
omMergeStickyPages
static void omMergeStickyPages(omBin to_bin, omBin from_bin)
Definition: omBin.c:265
omInsertInSortedGList
#define omInsertInSortedGList(ptr, next, what, addr)
Definition: omList.h:106
next
ListNode * next
Definition: janet.h:31
omAssume
#define omAssume(x)
Definition: omError.h:85
i
int i
Definition: cfEzgcd.cc:125
omGetStickyBin
#define omGetStickyBin(bin, sticky_tag)
Definition: omBin.c:191
OM_MAX_BLOCK_SIZE
#define OM_MAX_BLOCK_SIZE
Definition: omTables.c:31
omSpecBin
omSpecBin_t * omSpecBin
Definition: omStructs.h:30
omFindInSortedGList
#define omFindInSortedGList(ptr, next, what, value)
Definition: omList.h:108
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
omGetUsedBytesOfBin
static long omGetUsedBytesOfBin(omBin bin)
Definition: omBin.c:754
omGetBinStat
static void omGetBinStat(omBin bin, long *pages_p, long *used_blocks_p, long *free_blocks_p)
Definition: omBin.c:609
omGListLength
#define omGListLength(ptr, next)
Definition: omList.h:94
size
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
omError_NoError
@ omError_NoError
Definition: omError.h:27
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
omSmallSize2Bin
#define omSmallSize2Bin(size)
Definition: omAllocPrivate.h:211
OM_SIZEOF_UNIQUE_MAX_BLOCK_THRESHOLD
#define OM_SIZEOF_UNIQUE_MAX_BLOCK_THRESHOLD
Definition: omTables.h:5
omGetMaxStickyBinTag
unsigned long omGetMaxStickyBinTag(omBin bin)
Definition: omBin.c:207
om_LargeBin
#define om_LargeBin
Definition: omBin.c:23
omBin
omBin_t * omBin
Definition: omStructs.h:12
om_SpecBin
omSpecBin om_SpecBin
Definition: om_Alloc.c:18
om_ZeroPage
omBinPage_t om_ZeroPage[]
Definition: om_Alloc.c:17
omUnGetSpecBin
#define omUnGetSpecBin(bin_ptr)
Definition: omBin.h:14
OM_MAX_BIN_INDEX
#define OM_MAX_BIN_INDEX
Definition: omTables.h:4
NULL
#define NULL
Definition: omList.c:10
omIsStaticNormalBin
#define omIsStaticNormalBin(bin)
Definition: omBin.h:43
omError_StickyBin
@ omError_StickyBin
Definition: omError.h:50
SIZEOF_OM_BIN_PAGE
#define SIZEOF_OM_BIN_PAGE
Definition: omAllocPrivate.h:32
omTestBin
omError_t omTestBin(omBin bin, int check_level)
Definition: omDebug.c:90
omRemoveFromSortedGList
#define omRemoveFromSortedGList(ptr, next, what, addr)
Definition: omList.h:110
omIsTrackBin
#define omIsTrackBin(bin)
Definition: omBin.h:57
omFindInGList
#define omFindInGList(ptr, next, what, value)
Definition: omList.h:104
omSetStickyBinTag
void omSetStickyBinTag(omBin bin, unsigned long sticky_tag)
Definition: omBin.c:235
fd
int status int fd
Definition: si_signals.h:59
omCreateStickyBin
static omBin omCreateStickyBin(omBin bin, unsigned long sticky)
Definition: omBin.c:194
om_StaticBin
omBin_t om_StaticBin[]
omIsKnownTopBin
int omIsKnownTopBin(omBin bin, int normal_bin)
Definition: omBin.c:440
omGetTotalBinStat
static void omGetTotalBinStat(omBin bin, long *pages_p, long *used_blocks_p, long *free_blocks_p)
Definition: omBin.c:639
omUnSetStickyBinTag
void omUnSetStickyBinTag(omBin bin, unsigned long sticky)
Definition: omBin.c:258
omBinPage
omBinPage_t * omBinPage
Definition: omStructs.h:16
omIsStickyBin
#define omIsStickyBin(bin)
Definition: omBin.h:33