Files
hakmem/core/hakmem_tiny_magazine.h

46 lines
1.2 KiB
C
Raw Normal View History

#ifndef HAKMEM_TINY_MAGAZINE_H
#define HAKMEM_TINY_MAGAZINE_H
#include "hakmem_tiny.h" // For TINY_NUM_CLASSES
// This forward declaration is needed because TinyMagItem references it.
struct TinySlab;
#define TINY_TLS_MAG_CAP 2048
// Optional: store owner slab pointer alongside pointer in Magazine items
#ifndef HAKMEM_TINY_MAG_OWNER
#define HAKMEM_TINY_MAG_OWNER 1
#endif
typedef struct {
void* ptr;
#if HAKMEM_TINY_MAG_OWNER
struct TinySlab* owner;
#endif
} TinyMagItem;
// Legacy magazines retained for slow path / compatibility (will gradually shrink)
typedef struct {
TinyMagItem items[TINY_TLS_MAG_CAP];
int top; // number of stored items
int cap; // adaptive capacity (<= TINY_TLS_MAG_CAP)
} TinyTLSMag;
// Defined in hakmem_tiny_magazine.c
extern __thread TinyTLSMag g_tls_mags[TINY_NUM_CLASSES];
extern int g_mag_cap_limit;
// Magazine capacity helpers
extern int g_mag_cap_override[TINY_NUM_CLASSES];
int tiny_effective_cap(int class_idx);
int tiny_default_cap(int class_idx);
int tiny_cap_max_for_class(int class_idx);
// Magazine initialization helpers
extern __thread int g_tls_small_mags_inited;
void tiny_mag_init_if_needed(int class_idx);
void tiny_small_mags_init_once(void);
#endif // HAKMEM_TINY_MAGAZINE_H