// hakmem_features.h - Feature Flags & Capability Enumeration // Purpose: Centralize all feature toggles for mode-based configuration #ifndef HAKMEM_FEATURES_H #define HAKMEM_FEATURES_H #include // =========================================================================== // Feature Categories (Bitflags) // =========================================================================== // Category 1: Allocation Strategies typedef enum { HAKMEM_FEATURE_MALLOC = 1 << 0, // Basic malloc/free HAKMEM_FEATURE_MMAP = 1 << 1, // mmap for large allocations HAKMEM_FEATURE_POOL = 1 << 2, // Per-thread pools (future) } HakemAllocFeatures; // Category 2: Caching typedef enum { HAKMEM_FEATURE_BIGCACHE = 1 << 0, // Tier-2 large block cache HAKMEM_FEATURE_TINYPOOL = 1 << 1, // Tier-1 small block pool (future) } HakemCacheFeatures; // Category 3: Learning & Adaptation typedef enum { HAKMEM_FEATURE_ELO = 1 << 0, // ELO strategy selection HAKMEM_FEATURE_EVOLUTION = 1 << 1, // Learning lifecycle (LEARN/FROZEN/CANARY) HAKMEM_FEATURE_PROFILING = 1 << 2, // Call-site profiling } HakemLearningFeatures; // Category 4: Memory Management Policies typedef enum { HAKMEM_FEATURE_BATCH_MADVISE = 1 << 0, // Batch madvise for TLB optimization HAKMEM_FEATURE_THP = 1 << 1, // Transparent Huge Pages HAKMEM_FEATURE_FREE_POLICY = 1 << 2, // Hot/Warm/Cold free policy } HakemMemoryFeatures; // Category 5: Debug & Instrumentation typedef enum { HAKMEM_FEATURE_DEBUG_LOG = 1 << 0, // Verbose debug logging HAKMEM_FEATURE_STATISTICS = 1 << 1, // Detailed statistics collection HAKMEM_FEATURE_TRACE = 1 << 2, // Allocation tracing } HakemDebugFeatures; // =========================================================================== // Feature Set (Combined) // =========================================================================== typedef struct { uint32_t alloc; // HakemAllocFeatures uint32_t cache; // HakemCacheFeatures uint32_t learning; // HakemLearningFeatures uint32_t memory; // HakemMemoryFeatures uint32_t debug; // HakemDebugFeatures } HakemFeatureSet; // =========================================================================== // Feature Queries (Inline helpers) // =========================================================================== static inline int hak_has_feature_alloc(HakemFeatureSet* fs, HakemAllocFeatures f) { return (fs->alloc & f) != 0; } static inline int hak_has_feature_cache(HakemFeatureSet* fs, HakemCacheFeatures f) { return (fs->cache & f) != 0; } static inline int hak_has_feature_learning(HakemFeatureSet* fs, HakemLearningFeatures f) { return (fs->learning & f) != 0; } static inline int hak_has_feature_memory(HakemFeatureSet* fs, HakemMemoryFeatures f) { return (fs->memory & f) != 0; } static inline int hak_has_feature_debug(HakemFeatureSet* fs, HakemDebugFeatures f) { return (fs->debug & f) != 0; } // =========================================================================== // Mode Presets (Defined in hakmem_config.c) // =========================================================================== // Get feature set for a mode HakemFeatureSet hak_features_for_mode(const char* mode); // Print feature set (debug) void hak_features_print(HakemFeatureSet* fs); #endif // HAKMEM_FEATURES_H