diff options
| author | Florian Bartels <Florian.Bartels@elektrobit.com> | 2023-01-10 10:44:05 +0100 |
|---|---|---|
| committer | Florian Bartels <Florian.Bartels@elektrobit.com> | 2023-02-28 15:59:47 +0100 |
| commit | 3ce2cd059f8f7c69d9e1fe26b95cec2bfd3c98a7 (patch) | |
| tree | d5944496239e8b36be6d55fac7c285a6a12a3e48 /library/std/src/sys/unix/thread.rs | |
| parent | 8f41570e91fcbad2f55800f2edcdea67c3389dc7 (diff) | |
| download | rust-3ce2cd059f8f7c69d9e1fe26b95cec2bfd3c98a7.tar.gz rust-3ce2cd059f8f7c69d9e1fe26b95cec2bfd3c98a7.zip | |
Add QNX Neutrino support to libstd
Co-authored-by: gh-tr <troach@qnx.com>
Diffstat (limited to 'library/std/src/sys/unix/thread.rs')
| -rw-r--r-- | library/std/src/sys/unix/thread.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index cc0e5929569..15070b1f6a7 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -9,7 +9,7 @@ use crate::time::Duration; #[cfg(all(target_os = "linux", target_env = "gnu"))] use crate::sys::weak::dlsym; -#[cfg(any(target_os = "solaris", target_os = "illumos"))] +#[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto"))] use crate::sys::weak::weak; #[cfg(not(any(target_os = "l4re", target_os = "vxworks", target_os = "espidf")))] pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024; @@ -173,7 +173,7 @@ impl Thread { } } - #[cfg(any(target_os = "solaris", target_os = "illumos"))] + #[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto"))] pub fn set_name(name: &CStr) { weak! { fn pthread_setname_np( @@ -381,6 +381,17 @@ pub fn available_parallelism() -> io::Result<NonZeroUsize> { } Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) }) + } else if #[cfg(target_os = "nto")] { + unsafe { + use libc::_syspage_ptr; + if _syspage_ptr.is_null() { + Err(io::const_io_error!(io::ErrorKind::NotFound, "No syspage available")) + } else { + let cpus = (*_syspage_ptr).num_cpu; + NonZeroUsize::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` |
