29 lines
705 B
C
29 lines
705 B
C
|
|
#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);
|
||
|
|
|
||
|
|
// 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);
|
||
|
|
|
||
|
|
// 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
|
||
|
|
|
||
|
|
#endif // POOL_TLS_H
|