Skip to main content

aligned_subrange

Function aligned_subrange 

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

The largest page-aligned subrange of [addr, addr + len), as a (byte offset from addr, subrange length) pair, or None when the range covers no whole page (including on address-space overflow). page must be a power of two.

Guarantees, relied on by sys::advise for pointer arithmetic and proved by the Kani harnesses: offset <= len, offset + sub_len <= len, and both addr + offset and sub_len are page-aligned.