2025-11-08 23:53:25 +09:00
|
|
|
#ifndef POOL_TLS_H
|
|
|
|
|
#define POOL_TLS_H
|
|
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
// Pool size classes (8KB - 52KB)
|
|
|
|
|
#define POOL_SIZE_CLASSES 7
|
|
|
|
|
extern const size_t POOL_CLASS_SIZES[POOL_SIZE_CLASSES];
|
|
|
|
|
|
|
|
|
|
// Public API (Box 1)
|
|
|
|
|
void* pool_alloc(size_t size);
|
|
|
|
|
void pool_free(void* ptr);
|
|
|
|
|
void pool_thread_init(void);
|
|
|
|
|
void pool_thread_cleanup(void);
|
|
|
|
|
|
2025-11-09 18:55:50 +09:00
|
|
|
// Pre-warm TLS cache (Phase 1.5b - call once at thread init)
|
|
|
|
|
void pool_tls_prewarm(void);
|
|
|
|
|
|
2025-11-08 23:53:25 +09:00
|
|
|
// Internal API (for Box 2 only)
|
|
|
|
|
void pool_install_chain(int class_idx, void* chain, int count);
|
|
|
|
|
int pool_get_refill_count(int class_idx);
|
|
|
|
|
|
2025-11-09 18:55:50 +09:00
|
|
|
// Remote queue (cross-thread free) API — Phase 1.5c
|
|
|
|
|
int pool_remote_push(int class_idx, void* ptr, int owner_tid);
|
|
|
|
|
int pool_remote_drain_light(int class_idx);
|
|
|
|
|
|
2025-11-08 23:53:25 +09:00
|
|
|
// Feature flags
|
|
|
|
|
#define POOL_USE_HEADERS 1 // 1-byte headers for O(1) free
|
|
|
|
|
|
|
|
|
|
#if POOL_USE_HEADERS
|
|
|
|
|
#define POOL_MAGIC 0xb0 // Different from Tiny (0xa0) for safety
|
|
|
|
|
#define POOL_HEADER_SIZE 1
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-11-09 18:55:50 +09:00
|
|
|
#endif // POOL_TLS_H
|