13#ifdef OM_INTERNAL_DEBUG
25#define om_LargeBin ((omBin) 1)
35#ifdef OM_ALIGNMENT_NEEDS_WORK
36 if (align ||
size >= OM_SIZEOF_UNIQUE_MAX_BLOCK_THRESHOLD)
51 sizeW = ((-max_blocks*SIZEOF_SYSTEM_PAGE) -
61#ifdef OM_ALIGNMENT_NEEDS_WORK
63 sizeW = ((
size + sizeW) & ~ (SIZEOF_STRICT_ALIGNMENT - 1));
66 sizeW = ((
size + sizeW) & ~ (SIZEOF_OM_ALIGNMENT - 1));
73 sizeW = sizeW >> LOG_SIZEOF_LONG;
78#ifdef OM_ALIGNMENT_NEEDS_WORK
87 om_new_specBin = omSmallSize2TrackBin(
size );
97 om_new_specBin->max_blocks < max_blocks)
111 s_bin->bin->max_blocks == s_bin->max_blocks &&
112 s_bin->bin->sizeW == sizeW);
118 s_bin->max_blocks = max_blocks;
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;
138 return om_new_specBin;
164 if (s_bin->ref == 0 || force)
170 if(s_bin->bin->last_page ==
NULL || force)
193#define omGetStickyBin(bin, sticky_tag) \
194 omFindInGList(bin, next, sticky, sticky_tag)
199 s_bin->sticky = sticky;
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;
211 unsigned long sticky = 0;
214 if (bin->sticky > sticky) sticky = bin->sticky;
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;
255 s_bin->last_page = tl;
256 s_bin->current_page = tc;
263 if (bin->sticky == sticky)
275 omAssume(to_bin->sizeW == from_bin->sizeW);
278 if (page ==
NULL)
return;
282 if (page->prev ==
NULL)
break;
287 if (to_bin->last_page ==
NULL)
290 to_bin->last_page = from_bin->last_page;
291 to_bin->current_page = from_bin->current_page;
296 to_bin->current_page !=
NULL);
298 if (to_bin->current_page->current !=
NULL)
300 if (to_bin->current_page->prev ==
NULL)
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;
307 to_bin->current_page = to_bin->current_page->prev;
314 to_bin->current_page->used_blocks = 0;
319 to_bin->current_page->current ==
NULL &&
320 to_bin->current_page->used_blocks == 0);
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;
327 omAssume(to_bin->current_page == to_bin->last_page);
328 to_bin->last_page = from_bin->last_page;
330 to_bin->current_page->next = page;
331 page->prev = to_bin->current_page;
332 to_bin->current_page = from_bin->current_page;
351 if (sticky_bin !=
NULL)
354 omAssume(no_sticky_bin !=
NULL && sticky_bin != no_sticky_bin);
358 if (bin == sticky_bin)
360 sticky_bin = no_sticky_bin;
379 new_bin->sticky = SIZEOF_VOIDP;
380 new_bin->max_blocks = bin->max_blocks;
381 new_bin->sizeW = bin->sizeW;
384 new_bin->last_page =
NULL;
401 !sticky_bin->sticky ||
402 sticky_bin->max_blocks != into_bin->max_blocks ||
403 sticky_bin == into_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" :
415 "unknown sticky_bin error")))))));
426 omBin _ibin = into_bin;
431#if defined(OM_INTERNAL_DEBUG) && !defined(OM_NDEBUG)
448 omAssume(normal_bin == 1 || normal_bin == 0);
453 to_check = om_StaticTrackBin;
454 s_bin = om_SpecTrackBin;
464 for (
i=0;
i<= OM_MAX_BIN_INDEX;
i++)
466 if (bin == &(to_check[
i]))
470 while (s_bin !=
NULL)
472 if (bin == s_bin->bin)
return 1;
477 while (to_check !=
NULL)
479 if (bin == to_check)
return 1;
480 to_check = to_check->next;
488 unsigned long sticky = 0, new_sticky;
492 for (
i=0;
i<=OM_MAX_BIN_INDEX;
i++)
495 if (new_sticky > sticky) sticky = new_sticky;
498 while (s_bin !=
NULL)
501 if (new_sticky > sticky) sticky = new_sticky;
507 for (
i=0;
i<=OM_MAX_BIN_INDEX;
i++)
512 while (s_bin !=
NULL)
523 for (
i=0;
i<=OM_MAX_BIN_INDEX;
i++)
530 while (s_bin !=
NULL)
544 for (
i=0;
i<=OM_MAX_BIN_INDEX;
i++)
548 while (s_bin !=
NULL)
559 for (
i=0;
i<=OM_MAX_BIN_INDEX;
i++)
563 while (s_bin !=
NULL)
574 for (
i=0;
i<=OM_MAX_BIN_INDEX;
i++)
578 while (s_bin !=
NULL)
586void omPrintMissing(
omBin bin)
595 for (
i=0;
i<bin->max_blocks;
i++)
598 printf(
"%d:%p\n",
i, addr);
599 addr += bin->sizeW*SIZEOF_LONG;
614 long pages = 0, used_blocks = 0, free_blocks = 0;
620 pages++;
if (where == 1)
623 if (bin->max_blocks > 0)
628 if (bin->max_blocks > 1)
629 used_blocks += bin->max_blocks;
633 if (page == bin->current_page) where = -1;
637 *used_blocks_p = used_blocks;
638 *free_blocks_p = free_blocks;
644 long t_pages = 0, t_used_blocks = 0, t_free_blocks = 0;
645 long pages = 0, used_blocks = 0, free_blocks = 0;
651 t_used_blocks += used_blocks;
652 t_free_blocks += free_blocks;
659 *used_blocks_p = t_used_blocks;
660 *free_blocks_p = t_free_blocks;
674 (
long)bin->sizeW, bin->max_blocks);
677 fprintf(
fd,
"%ld\t%ld\t%ld\n", *pages, *free_blocks, *used_blocks);
680 long s_pages, s_free_blocks, s_used_blocks;
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,
688 *used_blocks += s_used_blocks;
689 *free_blocks += s_free_blocks;
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;
702 fputs(
" SizeW\tBlocks\tUPages\tFBlocks\tUBlocks\tSticky\n",
fd);
704 while (s_bin !=
NULL ||
i >= 0)
706 if (s_bin ==
NULL || (
i >= 0 && (
unsigned long)
om_StaticBin[
i].max_blocks < (
unsigned long) s_bin->bin->max_blocks))
710 used_blocks += used_blocks_p;
711 free_blocks += free_blocks_p;
715 omPrintBinStat(
fd, &om_StaticTrackBin[
i], 1, &pages_p, &used_blocks_p, &free_blocks_p);
717 used_blocks += used_blocks_p;
718 free_blocks += free_blocks_p;
727 used_blocks += used_blocks_p;
728 free_blocks += free_blocks_p;
733 s_bin = om_SpecTrackBin;
734 while (s_bin !=
NULL)
736 omPrintBinStat(
fd, s_bin->bin, 0, &pages_p, &used_blocks_p, &free_blocks_p);
739 used_blocks += used_blocks_p;
740 free_blocks += free_blocks_p;
744 while (sticky !=
NULL)
747 sticky = sticky->next;
749 used_blocks += used_blocks_p;
750 free_blocks += free_blocks_p;
752 fputs(
"----------------------------------------\n",
fd);
753 fprintf(
fd,
" \t \t%ld\t%ld\t%ld\n", pages, free_blocks, used_blocks);
758 long pages = 0, used_blocks = 0, free_blocks = 0;
760 return (used_blocks)*((long)bin->sizeW)*SIZEOF_LONG;
765 int i = OM_MAX_BIN_INDEX;
774 while (s_bin !=
NULL)
780 for (
i=OM_MAX_BIN_INDEX;
i>=0;
i--)
784 s_bin = om_SpecTrackBin;
785 while (s_bin !=
NULL)
793 while (sticky !=
NULL)
796 sticky = sticky->next;
static BOOLEAN length(leftv result, leftv arg)
omError_t omTestBin(omBin bin, int check_level)
#define omFreeSize(addr, size)
#define omSetTopBinAndStickyOfPage(page, bin, sticky)
#define SIZEOF_OM_BIN_PAGE_HEADER
#define SIZEOF_OM_BIN_PAGE
#define _omSizeOfBinAddr(addr)
#define omSizeOfBinAddr(addr)
#define omSmallSize2Bin(size)
void omSetStickyBinTag(omBin bin, unsigned long sticky_tag)
static void omPrintBinStat(FILE *fd, omBin bin, int track, long *pages, long *used_blocks, long *free_blocks)
void omDeleteStickyBinTag(omBin bin, unsigned long sticky)
void omSetStickyAllBinTag(unsigned long sticky)
unsigned long omGetMaxStickyBinTag(omBin bin)
static void omMergeStickyPages(omBin to_bin, omBin from_bin)
void _omUnGetSpecBin(omBin *bin_p, int force)
omBin _omGetSpecBin(size_t size, int align, int track)
#define omGetStickyBin(bin, sticky_tag)
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)
unsigned long omGetNewStickyBinTag(omBin bin)
static omBin omCreateStickyBin(omBin bin, unsigned long sticky)
void omDeleteStickyAllBinTag(unsigned long sticky)
void omUnSetStickyBinTag(omBin bin, unsigned long sticky)
void omUnSetStickyAllBinTag(unsigned long sticky)
unsigned long omGetNewStickyAllBinTag()
static long omGetUsedBytesOfBin(omBin bin)
#define omIsKnownTopBin(bin, normal_bin)
#define omIsStickyBin(bin)
#define omIsStaticBin(bin)
#define omIsStaticNormalBin(bin)
#define omUnGetSpecBin(bin_ptr)
#define omIsTrackBin(bin)
void omFreeKeptAddrFromBin(omBin bin)
#define omGetUsedBlocksOfPage(page)
omError_t omReportError(omError_t error, omError_t report_error, OM_FLR_DECL, const char *fmt,...)
#define omIsOnList(ptr, addr)
#define omFindInGList(ptr, next, what, value)
#define omRemoveFromSortedGList(ptr, next, what, addr)
#define omRemoveFromGList(ptr, next, addr)
#define omGListLength(ptr, next)
#define omIsOnGList(ptr, next, addr)
#define omInsertInSortedGList(ptr, next, what, addr)
#define omFindInSortedGList(ptr, next, what, value)
#define OM_MAX_BLOCK_SIZE
omBinPage_t om_ZeroPage[]
#define omSmallSize2AlignedBin
#define omGetStickyBinOfBin(B)
#define omMergeStickyBinIntoBin(A, B)
#define omPrintBinStats(F)