// learner_env_box.h - Learning Layer ENV Box // Purpose: Decide whether CAP Learner thread should run, based on HAKMEM_MODE // and HAKMEM_LEARN, without touchingホットパス。 // // Priority: // 1. HAKMEM_LEARN is set → 0/1 で明示的に上書き // 2. 未設定の場合: // HAKMEM_MODE=learning/research → Learner 有効 // それ以外(minimal/fast/balanced) → Learner 無効 #pragma once #include "../hakmem_config.h" #include "../hakmem_build_flags.h" #include static inline int hak_learner_env_should_run(void) { #if HAKMEM_BENCH_MINIMAL || HAKMEM_FAST_PROFILE_FIXED || HAKMEM_FAST_PROFILE_PRUNE_BACKENDS // Phase 63/64: Disable learning layer in FAST profile-fixed/pruned builds return 0; #endif static int g_inited = 0; static int g_effective = 0; if (__builtin_expect(!g_inited, 0)) { const char* e = getenv("HAKMEM_LEARN"); if (e && *e) { int v = atoi(e); g_effective = (v != 0) ? 1 : 0; } else { HakemMode m = g_hakem_config.mode; g_effective = (m == HAKMEM_MODE_LEARNING || m == HAKMEM_MODE_RESEARCH) ? 1 : 0; } g_inited = 1; } return g_effective; }