11 #ifdef OM_INTERNAL_DEBUG
23 #define om_LargeBin ((omBin) 1)
33 #ifdef OM_ALIGNMENT_NEEDS_WORK
49 sizeW = ((-max_blocks*SIZEOF_SYSTEM_PAGE) -
59 #ifdef OM_ALIGNMENT_NEEDS_WORK
61 sizeW = ((
size + sizeW) & ~ (SIZEOF_STRICT_ALIGNMENT - 1));
64 sizeW = ((
size + sizeW) & ~ (SIZEOF_OM_ALIGNMENT - 1));
71 sizeW = sizeW >> LOG_SIZEOF_LONG;
76 #ifdef OM_ALIGNMENT_NEEDS_WORK
85 om_new_specBin = omSmallSize2TrackBin(
size );
95 om_new_specBin->max_blocks < max_blocks)
109 s_bin->bin->max_blocks == s_bin->max_blocks &&
110 s_bin->bin->sizeW == sizeW);
116 s_bin->max_blocks = max_blocks;
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;
136 return om_new_specBin;
162 if (s_bin->ref == 0 || force)
168 if(s_bin->bin->last_page ==
NULL || force)
191 #define omGetStickyBin(bin, sticky_tag) \
192 omFindInGList(bin, next, sticky, sticky_tag)
197 s_bin->sticky = sticky;
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;
209 unsigned long sticky = 0;
212 if (bin->sticky > sticky) sticky = bin->sticky;
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;
253 s_bin->last_page = tl;
254 s_bin->current_page = tc;
261 if (bin->sticky == sticky)
267 #ifdef HAVE_OM_ASSUME
273 omAssume(to_bin->sizeW == from_bin->sizeW);
276 if (page ==
NULL)
return;
280 if (page->prev ==
NULL)
break;
285 if (to_bin->last_page ==
NULL)
288 to_bin->last_page = from_bin->last_page;
289 to_bin->current_page = from_bin->current_page;
294 to_bin->current_page !=
NULL);
296 if (to_bin->current_page->current !=
NULL)
298 if (to_bin->current_page->prev ==
NULL)
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;
305 to_bin->current_page = to_bin->current_page->prev;
312 to_bin->current_page->used_blocks = 0;
317 to_bin->current_page->current ==
NULL &&
318 to_bin->current_page->used_blocks == 0);
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;
325 omAssume(to_bin->current_page == to_bin->last_page);
326 to_bin->last_page = from_bin->last_page;
328 to_bin->current_page->next = page;
329 page->prev = to_bin->current_page;
330 to_bin->current_page = from_bin->current_page;
332 #ifdef HAVE_OM_ASSUME
349 if (sticky_bin !=
NULL)
352 omAssume(no_sticky_bin !=
NULL && sticky_bin != no_sticky_bin);
356 if (bin == sticky_bin)
358 sticky_bin = no_sticky_bin;
377 new_bin->sticky = SIZEOF_VOIDP;
378 new_bin->max_blocks = bin->max_blocks;
379 new_bin->sizeW = bin->sizeW;
382 new_bin->last_page =
NULL;
399 !sticky_bin->sticky ||
400 sticky_bin->max_blocks != into_bin->max_blocks ||
401 sticky_bin == into_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" :
413 "unknown sticky_bin error")))))));
424 omBin _ibin = into_bin;
429 #if defined(OM_INTERNAL_DEBUG) && !defined(OM_NDEBUG)
446 omAssume(normal_bin == 1 || normal_bin == 0);
451 to_check = om_StaticTrackBin;
452 s_bin = om_SpecTrackBin;
464 if (bin == &(to_check[
i]))
468 while (s_bin !=
NULL)
470 if (bin == s_bin->bin)
return 1;
475 while (to_check !=
NULL)
477 if (bin == to_check)
return 1;
478 to_check = to_check->next;
486 unsigned long sticky = 0, new_sticky;
493 if (new_sticky > sticky) sticky = new_sticky;
496 while (s_bin !=
NULL)
499 if (new_sticky > sticky) sticky = new_sticky;
510 while (s_bin !=
NULL)
528 while (s_bin !=
NULL)
546 while (s_bin !=
NULL)
561 while (s_bin !=
NULL)
576 while (s_bin !=
NULL)
584 void omPrintMissing(
omBin bin)
593 for (
i=0;
i<bin->max_blocks;
i++)
596 printf(
"%d:%p\n",
i, addr);
597 addr += bin->sizeW*SIZEOF_LONG;
612 long pages = 0, used_blocks = 0, free_blocks = 0;
618 pages++;
if (where == 1)
621 if (bin->max_blocks > 0)
626 if (bin->max_blocks > 1)
627 used_blocks += bin->max_blocks;
631 if (page == bin->current_page) where = -1;
635 *used_blocks_p = used_blocks;
636 *free_blocks_p = free_blocks;
642 long t_pages = 0, t_used_blocks = 0, t_free_blocks = 0;
643 long pages = 0, used_blocks = 0, free_blocks = 0;
649 t_used_blocks += used_blocks;
650 t_free_blocks += free_blocks;
657 *used_blocks_p = t_used_blocks;
658 *free_blocks_p = t_free_blocks;
661 static void omPrintBinStat(FILE *
fd,
omBin bin,
int track,
long* pages,
long* used_blocks,
long* free_blocks)
672 (
long)bin->sizeW, bin->max_blocks);
675 fprintf(
fd,
"%ld\t%ld\t%ld\n", *pages, *free_blocks, *used_blocks);
678 long s_pages, s_free_blocks, s_used_blocks;
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,
686 *used_blocks += s_used_blocks;
687 *free_blocks += s_free_blocks;
695 long pages=0, used_blocks=0, free_blocks=0;
696 long pages_p, used_blocks_p, free_blocks_p;
700 fputs(
" SizeW\tBlocks\tUPages\tFBlocks\tUBlocks\tSticky\n",
fd);
702 while (s_bin !=
NULL ||
i >= 0)
704 if (s_bin ==
NULL || (
i >= 0 && (
unsigned long)
om_StaticBin[
i].max_blocks < (
unsigned long) s_bin->bin->max_blocks))
708 used_blocks += used_blocks_p;
709 free_blocks += free_blocks_p;
713 omPrintBinStat(
fd, &om_StaticTrackBin[
i], 1, &pages_p, &used_blocks_p, &free_blocks_p);
715 used_blocks += used_blocks_p;
716 free_blocks += free_blocks_p;
725 used_blocks += used_blocks_p;
726 free_blocks += free_blocks_p;
731 s_bin = om_SpecTrackBin;
732 while (s_bin !=
NULL)
734 omPrintBinStat(
fd, s_bin->bin, 0, &pages_p, &used_blocks_p, &free_blocks_p);
737 used_blocks += used_blocks_p;
738 free_blocks += free_blocks_p;
742 while (sticky !=
NULL)
745 sticky = sticky->next;
747 used_blocks += used_blocks_p;
748 free_blocks += free_blocks_p;
750 fputs(
"----------------------------------------\n",
fd);
751 fprintf(
fd,
" \t \t%ld\t%ld\t%ld\n", pages, free_blocks, used_blocks);
756 long pages = 0, used_blocks = 0, free_blocks = 0;
758 return (used_blocks)*((long)bin->sizeW)*SIZEOF_LONG;
772 while (s_bin !=
NULL)
782 s_bin = om_SpecTrackBin;
783 while (s_bin !=
NULL)
791 while (sticky !=
NULL)
794 sticky = sticky->next;