1b8a62b91Sopenharmony_ciuse super::super::c; 2b8a62b91Sopenharmony_ci#[cfg(any( 3b8a62b91Sopenharmony_ci all(target_os = "android", target_pointer_width = "64"), 4b8a62b91Sopenharmony_ci target_os = "linux", 5b8a62b91Sopenharmony_ci))] 6b8a62b91Sopenharmony_ciuse crate::ffi::CStr; 7b8a62b91Sopenharmony_ci 8b8a62b91Sopenharmony_ci// `getauxval` wasn't supported in glibc until 2.16. 9b8a62b91Sopenharmony_ci#[cfg(any( 10b8a62b91Sopenharmony_ci all(target_os = "android", target_pointer_width = "64"), 11b8a62b91Sopenharmony_ci target_os = "linux", 12b8a62b91Sopenharmony_ci))] 13b8a62b91Sopenharmony_ciweak!(fn getauxval(c::c_ulong) -> *mut c::c_void); 14b8a62b91Sopenharmony_ci 15b8a62b91Sopenharmony_ci#[inline] 16b8a62b91Sopenharmony_cipub(crate) fn page_size() -> usize { 17b8a62b91Sopenharmony_ci unsafe { c::sysconf(c::_SC_PAGESIZE) as usize } 18b8a62b91Sopenharmony_ci} 19b8a62b91Sopenharmony_ci 20b8a62b91Sopenharmony_ci#[cfg(not(target_os = "wasi"))] 21b8a62b91Sopenharmony_ci#[inline] 22b8a62b91Sopenharmony_cipub(crate) fn clock_ticks_per_second() -> u64 { 23b8a62b91Sopenharmony_ci unsafe { c::sysconf(c::_SC_CLK_TCK) as u64 } 24b8a62b91Sopenharmony_ci} 25b8a62b91Sopenharmony_ci 26b8a62b91Sopenharmony_ci#[cfg(any( 27b8a62b91Sopenharmony_ci all(target_os = "android", target_pointer_width = "64"), 28b8a62b91Sopenharmony_ci target_os = "linux", 29b8a62b91Sopenharmony_ci))] 30b8a62b91Sopenharmony_ci#[inline] 31b8a62b91Sopenharmony_cipub(crate) fn linux_hwcap() -> (usize, usize) { 32b8a62b91Sopenharmony_ci if let Some(libc_getauxval) = getauxval.get() { 33b8a62b91Sopenharmony_ci unsafe { 34b8a62b91Sopenharmony_ci let hwcap = libc_getauxval(c::AT_HWCAP) as usize; 35b8a62b91Sopenharmony_ci let hwcap2 = libc_getauxval(c::AT_HWCAP2) as usize; 36b8a62b91Sopenharmony_ci (hwcap, hwcap2) 37b8a62b91Sopenharmony_ci } 38b8a62b91Sopenharmony_ci } else { 39b8a62b91Sopenharmony_ci (0, 0) 40b8a62b91Sopenharmony_ci } 41b8a62b91Sopenharmony_ci} 42b8a62b91Sopenharmony_ci 43b8a62b91Sopenharmony_ci#[cfg(any( 44b8a62b91Sopenharmony_ci all(target_os = "android", target_pointer_width = "64"), 45b8a62b91Sopenharmony_ci target_os = "linux", 46b8a62b91Sopenharmony_ci))] 47b8a62b91Sopenharmony_ci#[inline] 48b8a62b91Sopenharmony_cipub(crate) fn linux_execfn() -> &'static CStr { 49b8a62b91Sopenharmony_ci if let Some(libc_getauxval) = getauxval.get() { 50b8a62b91Sopenharmony_ci unsafe { CStr::from_ptr(libc_getauxval(c::AT_EXECFN).cast()) } 51b8a62b91Sopenharmony_ci } else { 52b8a62b91Sopenharmony_ci cstr!("") 53b8a62b91Sopenharmony_ci } 54b8a62b91Sopenharmony_ci} 55