#![allow(deprecated)]
pub mod kinfo;
pub mod parse;
pub mod scan;
pub mod system;
pub mod units {
pub fn mach_ticks_to_nanos(ticks: u64) -> u64 {
use std::sync::OnceLock;
static SCALE: OnceLock<(u64, u64)> = OnceLock::new();
let (numer, denom) = *SCALE.get_or_init(|| {
let mut info = libc::mach_timebase_info { numer: 0, denom: 0 };
let rc = unsafe { libc::mach_timebase_info(&mut info) };
if rc == 0 && info.numer != 0 && info.denom != 0 {
(u64::from(info.numer), u64::from(info.denom))
} else {
(1, 1)
}
});
if denom == 0 {
return ticks;
}
ticks / denom * numer + (ticks % denom) * numer / denom
}
}
pub struct DarwinPlatform;
impl DarwinPlatform {
pub fn clk_tck() -> u64 {
100
}
pub fn cpu_count() -> usize {
crate::darwin::scan::cpu_count()
}
pub fn page_size() -> u64 {
let v = unsafe { libc::vm_page_size };
if v > 0 {
v as u64
} else {
16_384
}
}
}