#[repr(usize)]pub enum PageSize {
K4 = 4_096,
K16 = 16_384,
K64 = 65_536,
}Expand description
Strongly-typed virtual memory page size representing hardware MMU translation granules
Across supported operating systems and CPU architectures, base virtual memory page sizes form a strictly bounded set corresponding to hardware translation granules:
- 4 KiB (
4,096bytes): Standard on x86/x86_64, Windows, and default Linux AArch64 - 16 KiB (
16,384bytes): Apple Silicon macOS and 16k Linux kernels - 64 KiB (
65,536bytes): Enterprise Linux AArch64 (RHEL, CentOS Stream, Amazon Linux)
§Example
use frozen_core::memmap::PageSize;
let ps = PageSize::try_from(4096).unwrap();
assert_eq!(ps, PageSize::K4);
assert_eq!(ps.as_usize(), 4096);
assert_eq!(ps.as_u32(), 4096);
assert!(ps.is_power_of_two());Variants§
K4 = 4_096
4 KiB (4,096 bytes) - Standard x86_64, Windows, and default Linux AArch64
K16 = 16_384
16 KiB (16,384 bytes) - Native Apple Silicon macOS and 16k Linux kernels
K64 = 65_536
64 KiB (65,536 bytes) - Enterprise Linux AArch64 (RHEL, CentOS, Amazon Linux)
Implementations§
Source§impl PageSize
impl PageSize
Sourcepub const fn is_power_of_two(self) -> bool
pub const fn is_power_of_two(self) -> bool
Returns true since all valid hardware page sizes are powers of two
Sourcepub fn validate_platform(self) -> FrozenResult<Self>
pub fn validate_platform(self) -> FrozenResult<Self>
Validates whether this page size is supported on the active host operating system and architecture
§Platform rules
- Windows: Only
PageSize::K4(4096 bytes) is valid - macOS:
PageSize::K16orPageSize::K4onaarch64;PageSize::K4onx86_64 - Linux:
PageSize::K4onx86/x86_64;PageSize::K4,PageSize::K16,PageSize::K64
Trait Implementations§
impl Copy for PageSize
impl Eq for PageSize
Source§impl Ord for PageSize
impl Ord for PageSize
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for PageSize
impl PartialOrd for PageSize
impl StructuralPartialEq for PageSize
Auto Trait Implementations§
impl Freeze for PageSize
impl RefUnwindSafe for PageSize
impl Send for PageSize
impl Sync for PageSize
impl Unpin for PageSize
impl UnsafeUnpin for PageSize
impl UnwindSafe for PageSize
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more