Skip to content

Commit 88eafa4

Browse files
author
Anirudh Mathukumilli
committed
Use CLOCK_BOOTTIME for Instant in Fuchsia/Android
Fuchsia and Android both want Instants to progress during periods of suspension, and thus must use CLOCK_BOOTTIME as the backing reference clock.
1 parent e473783 commit 88eafa4

File tree

1 file changed

+5
-1
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+5
-1
lines changed

library/std/src/sys/pal/unix/time.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,11 @@ impl Instant {
271271
// we preserve this value domain out of an abundance of caution.
272272
#[cfg(target_vendor = "apple")]
273273
const clock_id: libc::clockid_t = libc::CLOCK_UPTIME_RAW;
274-
#[cfg(not(target_vendor = "apple"))]
274+
// Instant is intended to progress forward during periods of suspension
275+
// in both Android and Fuchsia, and therefore uses CLOCK_BOOTTIME.
276+
#[cfg(any(target_os = "android", target_os = "fuchsia"))]
277+
const clock_id: libc::clockid_t = libc::CLOCK_BOOTTIME;
278+
#[cfg(not(any(target_vendor = "apple", target_os = "fuchsia", target_os = "android")))]
275279
const clock_id: libc::clockid_t = libc::CLOCK_MONOTONIC;
276280
Instant { t: Timespec::now(clock_id) }
277281
}

0 commit comments

Comments
 (0)