diff options
| author | Joy <51241057+maniwani@users.noreply.github.com> | 2022-10-26 11:43:18 -0700 |
|---|---|---|
| committer | Cameron <51241057+maniwani@users.noreply.github.com> | 2022-11-13 12:01:42 -0800 |
| commit | 5008a317ce8e508c390ed12bff281f307313376e (patch) | |
| tree | d243bfcdec1e6808b8055be1e281e66245e33d66 /library/std/src/sys | |
| parent | e4d6307c633c954971f3ca7876d4f29f3fe83614 (diff) | |
| download | rust-5008a317ce8e508c390ed12bff281f307313376e.tar.gz rust-5008a317ce8e508c390ed12bff281f307313376e.zip | |
Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targets
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/unix/time.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/library/std/src/sys/unix/time.rs b/library/std/src/sys/unix/time.rs index cca9c676701..b65566740b5 100644 --- a/library/std/src/sys/unix/time.rs +++ b/library/std/src/sys/unix/time.rs @@ -149,7 +149,11 @@ impl From<libc::timespec> for Timespec { } } -#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))] +#[cfg(any( + all(target_os = "macos", not(target_arch = "aarch64")), + target_os = "ios", + target_os = "watchos" +))] mod inner { use crate::sync::atomic::{AtomicU64, Ordering}; use crate::sys::cvt; @@ -265,7 +269,11 @@ mod inner { } } -#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "watchos")))] +#[cfg(not(any( + all(target_os = "macos", not(target_arch = "aarch64")), + target_os = "ios", + target_os = "watchos" +)))] mod inner { use crate::fmt; use crate::mem::MaybeUninit; @@ -281,7 +289,11 @@ mod inner { impl Instant { pub fn now() -> Instant { - Instant { t: Timespec::now(libc::CLOCK_MONOTONIC) } + #[cfg(target_os = "macos")] + const clock_id: clock_t = libc::CLOCK_UPTIME_RAW; + #[cfg(not(target_os = "macos"))] + const clock_id: clock_t = libc::CLOCK_MONOTONIC; + Instant { t: Timespec::now(clock_id) } } pub fn checked_sub_instant(&self, other: &Instant) -> Option<Duration> { |
