From 2ef28ee5abdd487c35e0cff74046da23bdd41e36 Mon Sep 17 00:00:00 2001 From: "Moe Charm (CI)" Date: Fri, 14 Nov 2025 07:10:46 +0900 Subject: [PATCH] Fix drain box compilation: Use pthread_self() directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: - tiny_self_u32() is static inline, cannot be linked from drain box - Link error: undefined reference to 'tiny_self_u32' Fix: - Use pthread_self() directly like hakmem_tiny_superslab.c:917 - Added include - Changed extern declaration from size_t to const size_t 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- core/box/tls_sll_drain_box.h | 7 ++++--- hakmem.d | 9 +++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/box/tls_sll_drain_box.h b/core/box/tls_sll_drain_box.h index 70461930..f0544023 100644 --- a/core/box/tls_sll_drain_box.h +++ b/core/box/tls_sll_drain_box.h @@ -24,6 +24,7 @@ #include #include #include +#include #include "tls_sll_box.h" // TLS SLL operations (tls_sll_pop) #include "../hakmem_tiny_config.h" // TINY_NUM_CLASSES #include "../hakmem_super_registry.h" // SuperSlab lookup @@ -128,11 +129,11 @@ static inline uint32_t tiny_tls_sll_drain(int class_idx, uint32_t batch_size) { // External functions needed for drain extern SuperSlab* hak_super_lookup(void* ptr); // SuperSlab registry lookup - extern uint32_t tiny_self_u32(void); // Thread ID (from tiny_superslab_free.inc.h:127) - extern size_t g_tiny_class_sizes[TINY_NUM_CLASSES]; // Block sizes + extern const size_t g_tiny_class_sizes[TINY_NUM_CLASSES]; // Block sizes (const) // Get thread ID once (used for all blocks) - uint32_t my_tid = tiny_self_u32(); + // Note: Use pthread_self() directly since tiny_self_u32() is static inline + uint32_t my_tid = (uint32_t)(uintptr_t)pthread_self(); // Drain loop: Pop blocks from TLS SLL and push to slab freelist for (uint32_t i = 0; i < to_drain; i++) { diff --git a/hakmem.d b/hakmem.d index 07f507c9..4a8ada70 100644 --- a/hakmem.d +++ b/hakmem.d @@ -28,8 +28,10 @@ hakmem.o: core/hakmem.c core/hakmem.h core/hakmem_build_flags.h \ core/box/../box/../tiny_region_id.h \ core/box/../box/../hakmem_tiny_integrity.h \ core/box/../box/../hakmem_tiny.h core/box/../box/../ptr_track.h \ - core/box/../box/../tiny_debug_ring.h core/box/../hakmem_tiny_integrity.h \ - core/box/front_gate_classifier.h core/box/hak_wrappers.inc.h + core/box/../box/../tiny_debug_ring.h core/box/../box/tls_sll_drain_box.h \ + core/box/../box/tls_sll_box.h core/box/../box/free_local_box.h \ + core/box/../hakmem_tiny_integrity.h core/box/front_gate_classifier.h \ + core/box/hak_wrappers.inc.h core/hakmem.h: core/hakmem_build_flags.h: core/hakmem_config.h: @@ -96,6 +98,9 @@ core/box/../box/../hakmem_tiny_integrity.h: core/box/../box/../hakmem_tiny.h: core/box/../box/../ptr_track.h: core/box/../box/../tiny_debug_ring.h: +core/box/../box/tls_sll_drain_box.h: +core/box/../box/tls_sll_box.h: +core/box/../box/free_local_box.h: core/box/../hakmem_tiny_integrity.h: core/box/front_gate_classifier.h: core/box/hak_wrappers.inc.h: