64 lines
2.2 KiB
C
64 lines
2.2 KiB
C
// tiny_hotheap_v2_box.h - TinyHotHeap v2 skeleton (Step1: types & stubs only)
|
||
// 役割:
|
||
// - TinyHotHeap v2 の型と API を先行定義するが、現行経路には配線しない。
|
||
// - HAKMEM_TINY_HOTHEAP_V2 / HAKMEM_TINY_HOTHEAP_CLASSES で将来の A/B に備える。
|
||
#pragma once
|
||
|
||
#include <stdint.h>
|
||
#include <string.h>
|
||
|
||
#ifndef TINY_HOTHEAP_MAX_CLASSES
|
||
#define TINY_HOTHEAP_MAX_CLASSES 8 // とりあえず全クラス分確保(後で mask で限定)
|
||
#endif
|
||
|
||
struct TinySlabMeta;
|
||
struct SuperSlab;
|
||
struct tiny_heap_page_t; // from tiny_heap_box.h (v1 page型)
|
||
|
||
typedef struct tiny_hotheap_page_v2 {
|
||
void* freelist;
|
||
uint16_t used;
|
||
uint16_t capacity;
|
||
uint16_t slab_idx;
|
||
uint8_t _pad;
|
||
void* base;
|
||
struct TinySlabMeta* meta; // Superslab slab meta
|
||
struct SuperSlab* ss; // Owning Superslab (meta/ss_active の整合は v1 が保持)
|
||
struct tiny_heap_page_t* lease_page; // v1 側の page 構造体(freelist/used の正は常に lease_page)
|
||
struct tiny_hotheap_page_v2* next;
|
||
} tiny_hotheap_page_v2;
|
||
|
||
typedef struct tiny_hotheap_class_v2 {
|
||
tiny_hotheap_page_v2* current_page;
|
||
tiny_hotheap_page_v2* partial_pages;
|
||
tiny_hotheap_page_v2* full_pages;
|
||
uint16_t stride;
|
||
uint16_t _pad;
|
||
tiny_hotheap_page_v2 storage_page; // C7 専用の 1 枚だけをまず保持
|
||
} tiny_hotheap_class_v2;
|
||
|
||
typedef struct tiny_hotheap_ctx_v2 {
|
||
tiny_hotheap_class_v2 cls[TINY_HOTHEAP_MAX_CLASSES];
|
||
} tiny_hotheap_ctx_v2;
|
||
|
||
// TLS state (定義は core/hakmem_tiny.c)
|
||
extern __thread tiny_hotheap_ctx_v2* g_tiny_hotheap_ctx_v2;
|
||
|
||
// API (Step1: まだ中身はダミー)
|
||
tiny_hotheap_ctx_v2* tiny_hotheap_v2_tls_get(void);
|
||
void* tiny_hotheap_v2_alloc(uint8_t class_idx);
|
||
void tiny_hotheap_v2_free(uint8_t class_idx, void* p, void* meta);
|
||
|
||
static inline void tiny_hotheap_v2_page_reset(tiny_hotheap_page_v2* page) {
|
||
if (!page) return;
|
||
page->freelist = NULL;
|
||
page->used = 0;
|
||
page->capacity = 0;
|
||
page->slab_idx = 0;
|
||
page->base = NULL;
|
||
page->meta = NULL;
|
||
page->ss = NULL;
|
||
page->lease_page = NULL;
|
||
page->next = NULL;
|
||
}
|