Files
hakmem/core/box/tiny_c7_hotbox.h
2025-12-07 22:49:28 +09:00

57 lines
2.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// tiny_c7_hotbox.h - C7 専用 TinyHeapTinyHeapBox 上の薄ラッパ)
// Box 方針:
// - C7 (≈1KiB) だけを担当するホットパス入口をここで閉じ込める。
// - 実体の管理は core/box/tiny_heap_box.h の汎用 TinyHeapBox に委譲し、下層 Box との
// 接続Superslab/Warm/Tierは TinyHeapBox の slow 境界に集約する。
#pragma once
#include "tiny_heap_box.h" // 共通 TinyHeap コンテキスト
#include "c7_hotpath_env_box.h" // HAKMEM_TINY_C7_HOT gate
// 旧 C7HotBox の型名互換TinyHeapBox の型をエイリアス)
typedef tiny_heap_page_t tiny_c7_page_t;
typedef tiny_heap_ctx_t tiny_c7_heap_t;
// 旧 MAX 設定の互換マクロ
#ifndef TINY_C7_HOTBOX_MAX_PAGES
#define TINY_C7_HOTBOX_MAX_PAGES TINY_HEAP_MAX_PAGES_PER_CLASS
#endif
static inline tiny_c7_heap_t* tiny_c7_heap_for_thread(void) {
return tiny_heap_ctx_for_thread();
}
static inline tiny_c7_page_t* tiny_c7_page_of(void* base_ptr) {
return tiny_heap_page_of(tiny_c7_heap_for_thread(), 7, base_ptr);
}
static inline tiny_c7_page_t* tiny_c7_heap_attach_page(tiny_c7_heap_t* heap,
SuperSlab* ss,
int slab_idx) {
return tiny_heap_attach_page(heap, 7, ss, slab_idx);
}
static inline void tiny_c7_page_becomes_empty(tiny_c7_heap_t* heap, tiny_c7_page_t* page) {
tiny_heap_page_becomes_empty(heap ? heap : tiny_c7_heap_for_thread(), 7, page);
}
static inline void* tiny_c7_alloc_slow_from_heap(tiny_c7_heap_t* heap) {
return tiny_heap_alloc_slow_from_class(heap ? heap : tiny_c7_heap_for_thread(), 7);
}
// C7 alloc ホットパスsize は Gate で 1024 確定済み)
__attribute__((always_inline)) static inline void* tiny_c7_alloc_fast(size_t size) {
(void)size;
return tiny_heap_alloc_class_fast(tiny_c7_heap_for_thread(), 7, size);
}
// Superslab/Slab メタが既に分かっている場合の freeGate から渡されるホットパス用)
static inline void tiny_c7_free_fast_with_meta(SuperSlab* ss, int slab_idx, void* base) {
tiny_heap_free_class_fast_with_meta(tiny_c7_heap_for_thread(), 7, ss, slab_idx, base);
}
// C7 free ホットパスptr は USER ポインタ)
static inline void tiny_c7_free_fast(void* ptr) {
tiny_heap_free_class_fast(tiny_c7_heap_for_thread(), 7, ptr);
}