tiny: fix TLS list next_off scope; default TLS_LIST=1; add sentinel guards; header-aware TLS ops; release quiet for benches
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
#include "../hakmem_tiny_superslab.h"
|
||||
#include "../superslab/superslab_inline.h" // For ss_slabs_capacity
|
||||
#include "../hakmem_build_flags.h"
|
||||
#include "../hakmem_internal.h" // AllocHeader, HAKMEM_MAGIC, HEADER_SIZE, hak_is_memory_readable
|
||||
#include "../hakmem_tiny_config.h" // For TINY_NUM_CLASSES, SLAB_SIZE
|
||||
#include "../hakmem_super_registry.h" // For hak_super_lookup (Box REG)
|
||||
|
||||
@ -209,8 +210,27 @@ ptr_classification_t classify_ptr(void* ptr) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Step 3: Not Tiny or Pool - return UNKNOWN
|
||||
// Caller should check AllocHeader (16-byte) or delegate to system free
|
||||
// Step 3: Try AllocHeader (HAKMEM header) for Mid/Large/Mmap
|
||||
do {
|
||||
if (!ptr) break;
|
||||
// Quick page-safety check: avoid crossing page for header read
|
||||
uintptr_t off = (uintptr_t)ptr & 0xFFFu;
|
||||
int safe_same_page = (off >= HEADER_SIZE);
|
||||
void* raw = (char*)ptr - HEADER_SIZE;
|
||||
if (!safe_same_page) {
|
||||
if (!hak_is_memory_readable(raw)) break;
|
||||
}
|
||||
AllocHeader* hdr = (AllocHeader*)raw;
|
||||
if (hdr->magic == HAKMEM_MAGIC) {
|
||||
result.kind = PTR_KIND_MID_LARGE; // HAKMEM-owned (non-Tiny)
|
||||
#if !HAKMEM_BUILD_RELEASE
|
||||
g_classify_unknown_hit++; // reuse for stats without adding a new counter
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
} while (0);
|
||||
|
||||
// Step 4: Not recognized → UNKNOWN (route to libc or slow path)
|
||||
result.kind = PTR_KIND_UNKNOWN;
|
||||
|
||||
#if !HAKMEM_BUILD_RELEASE
|
||||
|
||||
Reference in New Issue
Block a user