Files
hakmem/core/box/tiny_cold_iface_v1.h
2025-12-09 21:50:15 +09:00

38 lines
1.4 KiB
C

// tiny_cold_iface_v1.h
// TinyHotHeap v2 など別 Hot Box が Superslab/Tier/Stats と話すための共通境界 (v1 wrapper)。
// 前提: tiny_heap_box.h で tiny_heap_page_t / tiny_heap_ctx_t が定義済みであること。
#pragma once
#include "tiny_heap_box.h"
typedef struct TinyColdIface {
tiny_heap_page_t* (*refill_page)(void* cold_ctx, uint32_t class_idx);
void (*retire_page)(void* cold_ctx, uint32_t class_idx, tiny_heap_page_t* page);
} TinyColdIface;
// Forward declarations for the v1 cold helpers (defined in tiny_heap_box.h)
tiny_heap_page_t* tiny_heap_prepare_page(tiny_heap_ctx_t* ctx, int class_idx);
void tiny_heap_page_becomes_empty(tiny_heap_ctx_t* ctx, int class_idx, tiny_heap_page_t* page);
static inline tiny_heap_page_t* tiny_cold_refill_page_v1(void* cold_ctx, uint32_t class_idx) {
if (!cold_ctx) {
return NULL;
}
return tiny_heap_prepare_page((tiny_heap_ctx_t*)cold_ctx, (int)class_idx);
}
static inline void tiny_cold_retire_page_v1(void* cold_ctx, uint32_t class_idx, tiny_heap_page_t* page) {
if (!cold_ctx || !page) {
return;
}
tiny_heap_page_becomes_empty((tiny_heap_ctx_t*)cold_ctx, (int)class_idx, page);
}
static inline TinyColdIface tiny_cold_iface_v1(void) {
TinyColdIface iface = {
.refill_page = tiny_cold_refill_page_v1,
.retire_page = tiny_cold_retire_page_v1,
};
return iface;
}