Skip to content

Expose MAP_HUGE_SHIFT #2124

Closed
Closed
@newpavlov

Description

@newpavlov

Right now it's not possible to construct MapFlags for huge page mapping with huge page size variable at runtime without constructing a big intermediate enum or by using from_bits and libc::MAP_HUGE_SHIFT.

It would be nice to have something like this:

impl MapFlags {
    fn map_hugetlb_with_shift(shift: u8) -> Option<Self> {
        if shift >= 16 && shift <= 63 {
            Some(Self(libc::MAP_HUGETLB | (shift as i32) << libc::MAP_HUGE_SHIFT))
        } else {
            None
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions