1
Fork 0

Fix VxWorks available parallelism: Move nonzero::uncheked into unsafe block

This commit is contained in:
B I Mohammed Abbas 2024-08-08 12:59:04 +05:30
parent 9337f7afa6
commit fb1dac21ff

View file

@ -489,9 +489,11 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
fn vxCpuEnabledGet() -> libc::cpuset_t;
}
// always fetches a valid bitmask
let set = unsafe { vxCpuEnabledGet() };
Ok(NonZero::new_unchecked(set.count_ones() as usize))
unsafe{
// always fetches a valid bitmask
let set = vxCpuEnabledGet();
Ok(NonZero::new_unchecked(set.count_ones() as usize))
}
} else {
// FIXME: implement on Redox, l4re
Err(io::const_io_error!(io::ErrorKind::Unsupported, "Getting the number of hardware threads is not supported on the target platform"))