pub const SEGMENT_SIZE: usize = 2 * 1024 * 1024;
pub const SEGMENT_ALIGN: usize = SEGMENT_SIZE;
pub const PAGE_SIZE: usize = 64 * 1024;
pub const PAGE_SHIFT: usize = PAGE_SIZE.trailing_zeros() as usize;
pub const PAGE_ALIGN: usize = PAGE_SIZE;
pub const PAGES_PER_SEGMENT: usize = SEGMENT_SIZE / PAGE_SIZE;
pub const MAX_SMALL_ALLOC_SIZE: usize = 8 * 1024;
pub const MIN_BLOCK_SIZE: usize = 16;
pub const MAX_ALLOC_SIZE: usize = isize::MAX as usize;
pub const NUM_SIZE_CLASSES: usize = 44;
pub const MAX_RETAINED_SEGMENTS_LIMIT: usize = 1024;
const _: () = assert!(
SEGMENT_SIZE.is_power_of_two(),
"SEGMENT_SIZE must be a power of two for bitmask address rounding"
);
const _: () = assert!(
PAGE_SIZE.is_power_of_two(),
"PAGE_SIZE must be a power of two for bitmask address rounding"
);
const _: () = assert!(
SEGMENT_ALIGN == SEGMENT_SIZE,
"SEGMENT_ALIGN must equal SEGMENT_SIZE so the small-free classifier can recover the segment header by rounding"
);
const _: () = assert!(
PAGE_ALIGN == PAGE_SIZE,
"PAGE_ALIGN must equal PAGE_SIZE so page-base derivation matches the page array stride"
);
const _: () = assert!(
PAGES_PER_SEGMENT * PAGE_SIZE == SEGMENT_SIZE,
"PAGES_PER_SEGMENT must tile SEGMENT_SIZE exactly with PAGE_SIZE strides"
);
const _: () = assert!(
PAGES_PER_SEGMENT <= (u8::MAX as usize) + 1,
"Page::page_index stores segment-local page indices in u8"
);
const _: () = assert!(
PAGES_PER_SEGMENT >= 2,
"PAGES_PER_SEGMENT must reserve Page 0 for metadata and leave at least one slicing page"
);
const _: () = assert!(
MAX_SMALL_ALLOC_SIZE <= PAGE_SIZE,
"MAX_SMALL_ALLOC_SIZE must fit inside one PAGE_SIZE"
);
const _: () = assert!(
MAX_ALLOC_SIZE >= SEGMENT_SIZE,
"MAX_ALLOC_SIZE must accept at least one segment-sized payload"
);
const _: () = assert!(
NUM_SIZE_CLASSES > 0,
"NUM_SIZE_CLASSES must be non-zero so per-class allocator arrays hold at least one entry"
);
const _: () = assert!(
NUM_SIZE_CLASSES <= (u8::MAX as usize) + 1,
"Page::size_class stores size-class indices in u8"
);
const _: () = assert!(
PAGE_SIZE.is_multiple_of(MIN_BLOCK_SIZE),
"MIN_BLOCK_SIZE must divide PAGE_SIZE exactly"
);