From e95612b126307e33d9889e0ba028a1f031101690 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Mon, 9 Aug 2021 19:01:45 -0700 Subject: [PATCH] Switch Instant to use CLOCK_BOOTTIME For Linux-like platforms, use CLOCK_BOOTTIME which continues ticking during suspend. Without this change, `Duration` between two `Instant`s can bear little relation to reality if a suspend took place in between. Fixes rust-lang#87906 --- library/std/src/sys/unix/time.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/sys/unix/time.rs b/library/std/src/sys/unix/time.rs index 23a5c81c0053b..153cd0159beab 100644 --- a/library/std/src/sys/unix/time.rs +++ b/library/std/src/sys/unix/time.rs @@ -293,7 +293,7 @@ mod inner { impl Instant { pub fn now() -> Instant { - Instant { t: now(libc::CLOCK_MONOTONIC) } + Instant { t: now(libc::CLOCK_BOOTTIME) } } pub const fn zero() -> Instant {