diff options
| author | bors <bors@rust-lang.org> | 2021-10-05 06:56:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-10-05 06:56:57 +0000 |
| commit | 074f63648bd2368d5ca19aed02b5763a144e5d05 (patch) | |
| tree | a39ab48aab1c9740253a22c9ac29b32953e97a45 /library/std/src | |
| parent | a804c4b1123ae665a8d4f726524109c49efac5b6 (diff) | |
| parent | 068683baf12f61d5ffbf8a7e4858c4e0c3320f3b (diff) | |
| download | rust-074f63648bd2368d5ca19aed02b5763a144e5d05.tar.gz rust-074f63648bd2368d5ca19aed02b5763a144e5d05.zip | |
Auto merge of #89549 - Manishearth:rollup-mhkyc16, r=Manishearth
Rollup of 12 pull requests Successful merges: - #87631 (os current_exe using same approach as linux to get always the full ab…) - #88234 (rustdoc-json: Don't ignore impls for primitive types) - #88651 (Use the 64b inner:monotonize() implementation not the 128b one for aarch64) - #88816 (Rustdoc migrate to table so the gui can handle >2k constants) - #89244 (refactor: VecDeques PairSlices fields to private) - #89364 (rustdoc-json: Encode json files with UTF-8) - #89423 (Fix ICE caused by non_exaustive_omitted_patterns struct lint) - #89426 (bootstrap: add config option for nix patching) - #89462 (haiku thread affinity build fix) - #89482 (Follow the diagnostic output style guide) - #89504 (Don't suggest replacing region with 'static in NLL) - #89535 (fix busted JavaScript in error index generator) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/unix/os.rs | 30 | ||||
| -rw-r--r-- | library/std/src/sys/unix/thread.rs | 16 | ||||
| -rw-r--r-- | library/std/src/time/monotonic.rs | 4 |
3 files changed, 29 insertions, 21 deletions
diff --git a/library/std/src/sys/unix/os.rs b/library/std/src/sys/unix/os.rs index 1d5ffb07321..87893d26912 100644 --- a/library/std/src/sys/unix/os.rs +++ b/library/std/src/sys/unix/os.rs @@ -380,20 +380,24 @@ pub fn current_exe() -> io::Result<PathBuf> { #[cfg(any(target_os = "solaris", target_os = "illumos"))] pub fn current_exe() -> io::Result<PathBuf> { - extern "C" { - fn getexecname() -> *const c_char; - } - unsafe { - let path = getexecname(); - if path.is_null() { - Err(io::Error::last_os_error()) - } else { - let filename = CStr::from_ptr(path).to_bytes(); - let path = PathBuf::from(<OsStr as OsStrExt>::from_bytes(filename)); + if let Ok(path) = crate::fs::read_link("/proc/self/path/a.out") { + Ok(path) + } else { + extern "C" { + fn getexecname() -> *const c_char; + } + unsafe { + let path = getexecname(); + if path.is_null() { + Err(io::Error::last_os_error()) + } else { + let filename = CStr::from_ptr(path).to_bytes(); + let path = PathBuf::from(<OsStr as OsStrExt>::from_bytes(filename)); - // Prepend a current working directory to the path if - // it doesn't contain an absolute pathname. - if filename[0] == b'/' { Ok(path) } else { getcwd().map(|cwd| cwd.join(path)) } + // Prepend a current working directory to the path if + // it doesn't contain an absolute pathname. + if filename[0] == b'/' { Ok(path) } else { getcwd().map(|cwd| cwd.join(path)) } + } } } } diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index 05f51a46168..5631834eca6 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -339,14 +339,18 @@ pub fn available_concurrency() -> io::Result<NonZeroUsize> { Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) }) } else if #[cfg(target_os = "haiku")] { - let mut sinfo: libc::system_info = crate::mem::zeroed(); - let res = libc::get_system_info(&mut sinfo); + // 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` + unsafe { + let mut sinfo: libc::system_info = crate::mem::zeroed(); + let res = libc::get_system_info(&mut sinfo); - if res != libc::B_OK { - return Err(io::Error::last_os_error()); - } + if res != libc::B_OK { + return Err(io::Error::new_const(io::ErrorKind::NotFound, &"The number of hardware threads is not known for the target platform")); + } - Ok(unsafe { NonZeroUsize::new_unchecked(sinfo.cpu_count as usize) }) + Ok(NonZeroUsize::new_unchecked(sinfo.cpu_count as usize)) + } } else { // FIXME: implement on vxWorks, Redox, l4re Err(io::Error::new_const(io::ErrorKind::Unsupported, &"Getting the number of hardware threads is not supported on the target platform")) diff --git a/library/std/src/time/monotonic.rs b/library/std/src/time/monotonic.rs index 198ae739b55..64f16245c2b 100644 --- a/library/std/src/time/monotonic.rs +++ b/library/std/src/time/monotonic.rs @@ -5,7 +5,7 @@ pub(super) fn monotonize(raw: time::Instant) -> time::Instant { inner::monotonize(raw) } -#[cfg(all(target_has_atomic = "64", not(target_has_atomic = "128")))] +#[cfg(any(all(target_has_atomic = "64", not(target_has_atomic = "128")), target_arch = "aarch64"))] pub mod inner { use crate::sync::atomic::AtomicU64; use crate::sync::atomic::Ordering::*; @@ -71,7 +71,7 @@ pub mod inner { } } -#[cfg(target_has_atomic = "128")] +#[cfg(all(target_has_atomic = "128", not(target_arch = "aarch64")))] pub mod inner { use crate::sync::atomic::AtomicU128; use crate::sync::atomic::Ordering::*; |
