32 lines
894 B
C
32 lines
894 B
C
|
|
#ifndef HAKMEM_POOL_TLS_ARENA_H
|
||
|
|
#define HAKMEM_POOL_TLS_ARENA_H
|
||
|
|
|
||
|
|
#include <stddef.h>
|
||
|
|
|
||
|
|
// Configuration
|
||
|
|
#define POOL_SIZE_CLASSES 7
|
||
|
|
extern int g_arena_max_growth_level; // 0..N (3 => 8MB cap)
|
||
|
|
extern size_t g_arena_initial_chunk_size; // bytes (default 1MB)
|
||
|
|
|
||
|
|
// TLS Arena Chunk
|
||
|
|
typedef struct {
|
||
|
|
void* chunk_base; // mmap base address (page-aligned)
|
||
|
|
size_t chunk_size; // Current chunk size (1/2/4/8 MB)
|
||
|
|
size_t offset; // Next carve offset
|
||
|
|
int growth_level; // 0=1MB, 1=2MB, 2=4MB, 3=8MB
|
||
|
|
} PoolChunk;
|
||
|
|
|
||
|
|
// API
|
||
|
|
// Carve 'count' blocks from TLS Arena for 'class_idx'
|
||
|
|
// Returns number of blocks carved (0 on OOM)
|
||
|
|
int arena_batch_carve(int class_idx, void** out_blocks, int count);
|
||
|
|
|
||
|
|
// Thread cleanup (munmap all chunks)
|
||
|
|
void arena_cleanup_thread(void);
|
||
|
|
|
||
|
|
#ifdef POOL_TLS_ARENA_DEBUG
|
||
|
|
void arena_print_stats(void);
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#endif // HAKMEM_POOL_TLS_ARENA_H
|