// hakmem_build_flags.h - Centralized compile-time feature switches // Purpose: Define all build-time toggles in one place with safe defaults. // Usage: Include from common public headers (e.g., hakmem.h / hakmem_tiny.h). #ifndef HAKMEM_BUILD_FLAGS_H #define HAKMEM_BUILD_FLAGS_H // ------------------------------------------------------------ // Release/debug detection // ------------------------------------------------------------ // HAKMEM_BUILD_RELEASE: 1 in release-like builds, 0 otherwise #ifndef HAKMEM_BUILD_RELEASE # if defined(NDEBUG) # define HAKMEM_BUILD_RELEASE 1 # else # define HAKMEM_BUILD_RELEASE 0 # endif #endif // ------------------------------------------------------------ // Instrumentation & counters (compile-time) // ------------------------------------------------------------ // Enable lightweight path/debug counters (compiled out when 0) #ifndef HAKMEM_DEBUG_COUNTERS # define HAKMEM_DEBUG_COUNTERS 1 #endif // Enable extended memory profiling (compiled out when 0) #ifndef HAKMEM_DEBUG_MEMORY # define HAKMEM_DEBUG_MEMORY 0 #endif // Tiny refill optimization helpers (header-only) #ifndef HAKMEM_TINY_REFILL_OPT # define HAKMEM_TINY_REFILL_OPT 1 #endif // Batch refill P0 (can be toggled for A/B) #ifndef HAKMEM_TINY_P0_BATCH_REFILL # define HAKMEM_TINY_P0_BATCH_REFILL 1 #endif // Box refactor (Phase 6-1.7) — usually injected from build system #ifndef HAKMEM_TINY_PHASE6_BOX_REFACTOR # define HAKMEM_TINY_PHASE6_BOX_REFACTOR 1 #endif // ------------------------------------------------------------ // Tiny front architecture toggles (compile-time defaults) // ------------------------------------------------------------ // New 3-layer Tiny front (A/B via build flag) #ifndef HAKMEM_TINY_USE_NEW_3LAYER # define HAKMEM_TINY_USE_NEW_3LAYER 0 #endif // Minimal/strict front variants (bench/debug only) #ifndef HAKMEM_TINY_MINIMAL_FRONT # define HAKMEM_TINY_MINIMAL_FRONT 0 #endif #ifndef HAKMEM_TINY_STRICT_FRONT # define HAKMEM_TINY_STRICT_FRONT 0 #endif // Route fingerprint (compile-time gate; runtime ENV still required) #ifndef HAKMEM_ROUTE # define HAKMEM_ROUTE 0 #endif // Bench-only knobs (default values; can be overridden via build flags) #ifndef HAKMEM_TINY_BENCH_REFILL # define HAKMEM_TINY_BENCH_REFILL 8 #endif #ifndef HAKMEM_TINY_BENCH_REFILL8 # define HAKMEM_TINY_BENCH_REFILL8 HAKMEM_TINY_BENCH_REFILL #endif #ifndef HAKMEM_TINY_BENCH_REFILL16 # define HAKMEM_TINY_BENCH_REFILL16 HAKMEM_TINY_BENCH_REFILL #endif #ifndef HAKMEM_TINY_BENCH_REFILL32 # define HAKMEM_TINY_BENCH_REFILL32 HAKMEM_TINY_BENCH_REFILL #endif #ifndef HAKMEM_TINY_BENCH_REFILL64 # define HAKMEM_TINY_BENCH_REFILL64 HAKMEM_TINY_BENCH_REFILL #endif #ifndef HAKMEM_TINY_BENCH_WARMUP8 # define HAKMEM_TINY_BENCH_WARMUP8 64 #endif #ifndef HAKMEM_TINY_BENCH_WARMUP16 # define HAKMEM_TINY_BENCH_WARMUP16 96 #endif #ifndef HAKMEM_TINY_BENCH_WARMUP32 # define HAKMEM_TINY_BENCH_WARMUP32 160 #endif #ifndef HAKMEM_TINY_BENCH_WARMUP64 # define HAKMEM_TINY_BENCH_WARMUP64 192 #endif // ------------------------------------------------------------ // Helper enum (for documentation / logging) // ------------------------------------------------------------ typedef enum { HAK_FLAG_BUILD_RELEASE = HAKMEM_BUILD_RELEASE, HAK_FLAG_DEBUG_COUNTERS = HAKMEM_DEBUG_COUNTERS, HAK_FLAG_DEBUG_MEMORY = HAKMEM_DEBUG_MEMORY, HAK_FLAG_REFILL_OPT = HAKMEM_TINY_REFILL_OPT, HAK_FLAG_P0_BATCH = HAKMEM_TINY_P0_BATCH_REFILL, HAK_FLAG_BOX_REFACTOR = HAKMEM_TINY_PHASE6_BOX_REFACTOR, HAK_FLAG_NEW_3LAYER = HAKMEM_TINY_USE_NEW_3LAYER, } hak_build_flags_t; #endif // HAKMEM_BUILD_FLAGS_H