From 0ce7de3ef52f1cf04e46b97f8979c604b618ea70 Mon Sep 17 00:00:00 2001 From: Damjan Georgievski Date: Sun, 22 Mar 2020 20:44:06 +0100 Subject: [PATCH] arch: provide mechanism to get page size This is a copy of the same code in vm-allocator, until a better place is found for general use. Signed-off-by: Damjan Georgievski --- arch/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/src/lib.rs b/arch/src/lib.rs index 1410b1dae..5a4056cb3 100644 --- a/arch/src/lib.rs +++ b/arch/src/lib.rs @@ -79,3 +79,10 @@ pub use x86_64::{ arch_memory_regions, configure_system, layout, layout::CMDLINE_MAX_SIZE, layout::CMDLINE_START, BootProtocol, EntryPoint, }; + +/// Safe wrapper for `sysconf(_SC_PAGESIZE)`. +#[inline(always)] +fn pagesize() -> usize { + // Trivially safe + unsafe { libc::sysconf(libc::_SC_PAGESIZE) as usize } +}