2025-12-10 23:23:07 +09:00
|
|
|
// smallsegment_v4_box.h - Small-object専用 Segment Box の型定義と API 宣言
|
|
|
|
|
// Phase v4-mid-0: SmallSegment の型と API だけを先行定義。実装は後フェーズ。
|
2025-12-10 19:14:38 +09:00
|
|
|
#pragma once
|
|
|
|
|
|
2025-12-10 23:23:07 +09:00
|
|
|
#include <stdint.h>
|
2025-12-10 19:14:38 +09:00
|
|
|
|
2025-12-10 23:30:32 +09:00
|
|
|
// Forward declaration
|
|
|
|
|
struct SmallPageMeta;
|
2025-12-10 23:23:07 +09:00
|
|
|
|
2025-12-10 23:30:32 +09:00
|
|
|
// ============================================================================
|
2025-12-10 23:23:07 +09:00
|
|
|
// SmallSegment: class_idx ごとに小さな segment を管理
|
2025-12-10 23:30:32 +09:00
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
|
|
typedef struct SmallSegment {
|
2025-12-10 23:23:07 +09:00
|
|
|
uintptr_t base; // Segment base address
|
|
|
|
|
uint32_t num_pages; // Number of pages in segment
|
|
|
|
|
uint32_t owner_tid; // Thread ID that owns this segment
|
|
|
|
|
uint32_t magic; // Magic number for validation
|
|
|
|
|
// Page metadata array (flexible, actual size depends on SMALL_PAGE_SIZE / SMALL_SEGMENT_SIZE)
|
2025-12-10 23:30:32 +09:00
|
|
|
// struct SmallPageMeta* page_meta[];
|
|
|
|
|
} SmallSegment;
|
|
|
|
|
|
|
|
|
|
// Backward compatibility alias
|
|
|
|
|
typedef SmallSegment small_segment_v4;
|
2025-12-10 23:23:07 +09:00
|
|
|
|
2025-12-10 23:30:32 +09:00
|
|
|
// ============================================================================
|
|
|
|
|
// API: Segment Management
|
|
|
|
|
// ============================================================================
|
2025-12-10 23:23:07 +09:00
|
|
|
|
2025-12-10 23:30:32 +09:00
|
|
|
SmallSegment* smallsegment_v4_acquire(int class_idx);
|
|
|
|
|
void smallsegment_v4_release_if_empty(SmallSegment* seg, void* page, int class_idx);
|
|
|
|
|
struct SmallPageMeta* smallsegment_v4_page_meta_of(SmallSegment* seg, void* ptr);
|