Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libstd/sys/cloudabi/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Instant {
}
}

pub fn actually_monotonic() -> bool {
pub const fn actually_monotonic() -> bool {
true
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/hermit/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl Instant {
Instant { t: Timespec::zero() }
}

pub fn actually_monotonic() -> bool {
pub const fn actually_monotonic() -> bool {
true
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/sgx/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Instant {
Some(Instant(self.0.checked_sub(*other)?))
}

pub fn actually_monotonic() -> bool {
pub const fn actually_monotonic() -> bool {
false
}

Expand Down
22 changes: 16 additions & 6 deletions src/libstd/sys/unix/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ mod inner {
Instant { t: 0 }
}

pub fn actually_monotonic() -> bool {
pub const fn actually_monotonic() -> bool {
true
}

Expand Down Expand Up @@ -308,11 +308,21 @@ mod inner {
}
}

pub fn actually_monotonic() -> bool {
(cfg!(target_os = "linux") && cfg!(target_arch = "x86_64")) ||
(cfg!(target_os = "linux") && cfg!(target_arch = "x86")) ||
cfg!(target_os = "fuchsia") ||
false // last clause, used so `||` is always trailing above
pub const fn actually_monotonic() -> bool {
// note: duplicate attributes may be optimized when
// conditional expressions in constant functions hits stable.
#[cfg(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "x86"),
all(target_os = "fuchsia"),
))]
{ true }
#[cfg(not(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "x86"),
all(target_os = "fuchsia"),
)))]
{ false }
}

pub fn checked_sub_instant(&self, other: &Instant) -> Option<Duration> {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/vxworks/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ mod inner {
}
}

pub fn actually_monotonic() -> bool {
pub const fn actually_monotonic() -> bool {
true
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/wasi/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Instant {
Instant(Duration::from_secs(0))
}

pub fn actually_monotonic() -> bool {
pub const fn actually_monotonic() -> bool {
true
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/wasm/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl Instant {
Instant(Duration::from_secs(0))
}

pub fn actually_monotonic() -> bool {
pub const fn actually_monotonic() -> bool {
false
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/windows/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Instant {
perf_counter::PerformanceCounterInstant::now().into()
}

pub fn actually_monotonic() -> bool {
pub const fn actually_monotonic() -> bool {
false
}

Expand Down