about summary refs log tree commit diff
path: root/library/std/src/sys/pal/unix
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-03-25 17:17:57 +0100
committerRalf Jung <post@ralfj.de>2024-03-25 17:17:57 +0100
commitd8be714fee3fee35ede441e78f29773f2632b10f (patch)
tree1885870e6aa3f50b718be59e6b5cb64834e511d6 /library/std/src/sys/pal/unix
parent5b1319c754775460dd479d76826da1ed4d8552ae (diff)
parentcb7c63606e53715f94f3ba04d38e50772e4cd23d (diff)
downloadrust-d8be714fee3fee35ede441e78f29773f2632b10f.tar.gz
rust-d8be714fee3fee35ede441e78f29773f2632b10f.zip
Merge from rustc
Diffstat (limited to 'library/std/src/sys/pal/unix')
-rw-r--r--library/std/src/sys/pal/unix/net.rs2
-rw-r--r--library/std/src/sys/pal/unix/thread.rs8
2 files changed, 7 insertions, 3 deletions
diff --git a/library/std/src/sys/pal/unix/net.rs b/library/std/src/sys/pal/unix/net.rs
index 1f140f7844f..9a0a1b18aee 100644
--- a/library/std/src/sys/pal/unix/net.rs
+++ b/library/std/src/sys/pal/unix/net.rs
@@ -459,7 +459,7 @@ impl Socket {
             const AF_NAME_MAX: usize = 16;
             let mut buf = [0; AF_NAME_MAX];
             for (src, dst) in name.to_bytes().iter().zip(&mut buf[..AF_NAME_MAX - 1]) {
-                *dst = *src as i8;
+                *dst = *src as libc::c_char;
             }
             let mut arg: libc::accept_filter_arg = unsafe { mem::zeroed() };
             arg.af_name = buf;
diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs
index 6520ca9fc48..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)]
@@ -483,6 +481,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 {
+                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`