mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
std:🧵 refine available_parallelism for solaris/illumos.
Rather than the system-wide available cpus fallback solution, we fetch the cpus bound to the current process.
This commit is contained in:
parent
548e14b439
commit
4b84df9ea3
@ -483,6 +483,12 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
|
||||
.ok_or(io::const_io_error!(io::ErrorKind::NotFound, "The number of hardware threads is not known for the target platform"))
|
||||
}
|
||||
}
|
||||
} else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] {
|
||||
let mut cpus = 0u32;
|
||||
if unsafe { libc::pset_info(libc::PS_MYID, core::ptr::null_mut(), &mut cpus, core::ptr::null_mut()) } == 0 {
|
||||
NonZero::new(cpus as usize)
|
||||
.ok_or(io::const_io_error!(io::ErrorKind::NotFound, "The number of hardware threads is not known for the target platform"))
|
||||
}
|
||||
} else if #[cfg(target_os = "haiku")] {
|
||||
// system_info cpu_count field gets the static data set at boot time with `smp_set_num_cpus`
|
||||
// `get_system_info` calls then `smp_get_num_cpus`
|
||||
|
Loading…
Reference in New Issue
Block a user