2#ifdef UMM_INTEGRITY_CHECK
29bool umm_integrity_check(
void) {
30 UMM_CRITICAL_DECL(id_integrity);
35 UMM_CHECK_INITIALIZED();
39 UMM_CRITICAL_ENTRY(id_integrity);
41 cur = UMM_NFREE(prev);
44 if (cur >= UMM_NUMBLOCKS) {
45 DBGLOG_CRITICAL(
"Heap integrity broken: too large next free num: %d "
46 "(in block %d, addr 0x%08x)\n",
47 cur, prev, DBGLOG_32_BIT_PTR(&UMM_NBLOCK(prev)));
57 if (UMM_PFREE(cur) != prev) {
58 DBGLOG_CRITICAL(
"Heap integrity broken: free links don't match: "
59 "%d -> %d, but %d -> %d\n",
60 prev, cur, cur, UMM_PFREE(cur));
65 UMM_PBLOCK(cur) |= UMM_FREELIST_MASK;
73 cur = UMM_NBLOCK(prev) & UMM_BLOCKNO_MASK;
76 if (cur >= UMM_NUMBLOCKS) {
77 DBGLOG_CRITICAL(
"Heap integrity broken: too large next block num: %d "
78 "(in block %d, addr 0x%08x)\n",
79 cur, prev, DBGLOG_32_BIT_PTR(&UMM_NBLOCK(prev)));
89 if ((UMM_NBLOCK(cur) & UMM_FREELIST_MASK)
90 != (UMM_PBLOCK(cur) & UMM_FREELIST_MASK)) {
91 DBGLOG_CRITICAL(
"Heap integrity broken: mask wrong at addr 0x%08x: n=0x%x, p=0x%x\n",
92 DBGLOG_32_BIT_PTR(&UMM_NBLOCK(cur)),
93 (UMM_NBLOCK(cur) & UMM_FREELIST_MASK),
94 (UMM_PBLOCK(cur) & UMM_FREELIST_MASK));
101 DBGLOG_CRITICAL(
"Heap integrity broken: next block %d is before prev this one "
102 "(in block %d, addr 0x%08x)\n",
103 cur, prev, DBGLOG_32_BIT_PTR(&UMM_NBLOCK(prev)));
109 UMM_PBLOCK(cur) &= UMM_BLOCKNO_MASK;
112 if (UMM_PBLOCK(cur) != prev) {
113 DBGLOG_CRITICAL(
"Heap integrity broken: block links don't match: "
114 "%d -> %d, but %d -> %d\n",
115 prev, cur, cur, UMM_PBLOCK(cur));
124 UMM_CRITICAL_EXIT(id_integrity);
126 UMM_HEAP_CORRUPTION_CB();