Expand description
The OS boundary: anonymous mapping, unmapping, and returning pages.
Three hand-declared extern "C" symbols, no libc crate — the house
rule for OS boundaries. Linux and macOS only; elsewhere every entry
point reports failure and the allocator is simply unavailable.
§Why not kevy-madvise
That crate already binds mmap/munmap/madvise, so reusing it was
the first choice. It does not fit: it is Linux-only by construction
and its contract is huge-page advice — every mapping it hands out
has MADV_HUGEPAGE applied. An allocator needs mappings on macOS too
(that is where this is developed), and it must be able to return
pages, which is the property the whole experiment rests on. Widening
a crate whose name is its contract costs more than three extern
declarations, so the boundary lives here — which is also why
kevy-alloc is in the recorded unsafe set (allocgate M8).
Constants§
- PAGE
- The system page size this module assumes for rounding.
Functions§
- available
- Whether this target can map memory at all. Used by tests and by the heap’s construction path to fail fast rather than mysteriously.
- discard⚠
- Return the physical pages backing
lenbytes atptrto the OS while keeping the range mapped and addressable. - map_
aligned - Map
lenbytes anonymously with the returned address aligned toalignbytes. - round_
up - Round
nup to a multiple ofalign, which must be a power of two. - unmap⚠
- Unmap
lenbytes atptr.