Skip to main content

align_trim

Function align_trim 

Source
fn align_trim(
    addr: usize,
    map_len: usize,
    len: usize,
    align: usize,
) -> Option<(usize, usize)>
Available on Unix and crate feature pool only.
Expand description

Splits an over-mapped range of map_len bytes at addr into (head, tail) trim amounts such that discarding head bytes from the front and tail from the back leaves an align-aligned range of exactly len bytes. None on address-space overflow or when the range cannot fit an aligned len bytes.

When addr and len are page-aligned and align is a page-multiple power of two, head and tail are page-aligned (so both trims are unmappable) — proved by the Kani harnesses.