INNER CODE UNIT · Rust
sysrand
mratsim/constantine · constantine-rust/constantine-core/src/lib.rs:18
pub fn sysrand(buffer: &mut [u8]) {
unsafe {
ctt_csprng_sysrand(buffer.as_mut_ptr() as *mut c_void, buffer.len());
}
}
}
// Hardware detection
// ------------------------------------------------------------
pub mod hardware {
use constantine_sys::ctt_cpu_get_num_threads_os;
#[inline(always)]
#[doc = " Query the number of threads available at the OS-level\n to run computations.\n\n This takes into account cores disabled at the OS-level, for example in a VM.\n However this doesn't detect restrictions based on time quotas often used for Docker\n or taskset / cpuset restrictions from cgroups.\n\n For Simultaneous-Multithreading (SMT often call HyperThreading),\n this returns the number of available logical cores."]
pub fn get_num_threads_os() -> usize {
unsafe { ctt_cpu_get_num_threads_os() }.try_into().unwrap()
}
}