twizzler_abi/syscall/
info.rsuse core::num::NonZeroUsize;
use super::Syscall;
use crate::arch::syscall::raw_syscall;
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Ord, Eq)]
#[repr(C)]
pub struct SysInfo {
pub version: u32,
pub flags: u32,
pub cpu_count: usize,
pub page_size: usize,
}
impl SysInfo {
pub fn cpu_count(&self) -> NonZeroUsize {
NonZeroUsize::new(self.cpu_count).expect("CPU count from sysinfo should always be non-zero")
}
pub fn page_size(&self) -> usize {
self.page_size
}
}
pub fn sys_info() -> SysInfo {
let mut sysinfo = core::mem::MaybeUninit::<SysInfo>::zeroed();
unsafe {
raw_syscall(
Syscall::SysInfo,
&[&mut sysinfo as *mut core::mem::MaybeUninit<SysInfo> as u64],
);
sysinfo.assume_init()
}
}