// smallobject_v5_env_box.h - SmallObject v5 環境ゲート(Phase v5-0) // // ENV ベース: HAKMEM_SMALL_HEAP_V5_ENABLED, HAKMEM_SMALL_HEAP_V5_CLASSES #ifndef HAKMEM_SMALLOBJECT_V5_ENV_BOX_H #define HAKMEM_SMALLOBJECT_V5_ENV_BOX_H #include #include // small_heap_v5_enabled() - グローバル v5 enable check static inline int small_heap_v5_enabled(void) { static int g_enabled = -1; if (g_enabled == -1) { const char* e = getenv("HAKMEM_SMALL_HEAP_V5_ENABLED"); g_enabled = (e && *e && *e != '0') ? 1 : 0; } return g_enabled; } // small_heap_v5_class_mask() - v5 対象クラスのビットマスク static inline uint32_t small_heap_v5_class_mask(void) { static uint32_t g_mask = (uint32_t)-1; // sentinel if (g_mask == (uint32_t)-1) { const char* e = getenv("HAKMEM_SMALL_HEAP_V5_CLASSES"); if (e && *e) { g_mask = (uint32_t)strtoul(e, NULL, 0); } else { g_mask = 0x0; // default: OFF } } return g_mask; } // small_heap_v5_class_enabled() - 指定クラスが v5 有効か static inline int small_heap_v5_class_enabled(uint32_t class_idx) { if (class_idx >= 8) return 0; if (!small_heap_v5_enabled()) return 0; uint32_t mask = small_heap_v5_class_mask(); return (mask & (1u << class_idx)) ? 1 : 0; } // 便利関数 static inline int small_heap_v5_c6_enabled(void) { return small_heap_v5_class_enabled(6); } static inline int small_heap_v5_c5_enabled(void) { return small_heap_v5_class_enabled(5); } static inline int small_heap_v5_c7_enabled(void) { return small_heap_v5_class_enabled(7); } #endif // HAKMEM_SMALLOBJECT_V5_ENV_BOX_H