diff options
| author | David Carlier <devnexen@gmail.com> | 2024-03-24 16:02:02 +0000 |
|---|---|---|
| committer | David Carlier <devnexen@gmail.com> | 2024-03-24 16:02:02 +0000 |
| commit | 1871ea5710cdead66b1dfa3621f3727026185fa4 (patch) | |
| tree | fe5341d858bfdc19c58b6f4d2bd8bfc769aea46d | |
| parent | 4b84df9ea398fd3b3da55968d021906fc2346ce8 (diff) | |
| download | rust-1871ea5710cdead66b1dfa3621f3727026185fa4.tar.gz rust-1871ea5710cdead66b1dfa3621f3727026185fa4.zip | |
fix build.
| -rw-r--r-- | library/std/src/sys/pal/unix/thread.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 9befcb0e3e6..a3e1b6782e8 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -355,8 +355,6 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> { target_os = "tvos", target_os = "linux", target_os = "macos", - target_os = "solaris", - target_os = "illumos", target_os = "aix", ))] { #[allow(unused_assignments)] @@ -485,10 +483,10 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> { } } 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")) + if unsafe { libc::pset_info(libc::PS_MYID, core::ptr::null_mut(), &mut cpus, core::ptr::null_mut()) } != 0 { + return Err(io::const_io_error!(io::ErrorKind::NotFound, "The number of hardware threads is not known for the target platform")); } + Ok(unsafe { NonZero::new_unchecked(cpus as usize) }) } 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` |
