Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CLOCK_BOOTTIME for Instant in Fuchsia/Android #132331

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
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.
  • Loading branch information
Anirudh Mathukumilli committed Oct 29, 2024
commit 88eafa478550ae55f3f471bed723deac96d5a594
6 changes: 5 additions & 1 deletion library/std/src/sys/pal/unix/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ impl Instant {
// we preserve this value domain out of an abundance of caution.
#[cfg(target_vendor = "apple")]
const clock_id: libc::clockid_t = libc::CLOCK_UPTIME_RAW;
#[cfg(not(target_vendor = "apple"))]
// Instant is intended to progress forward during periods of suspension
// in both Android and Fuchsia, and therefore uses CLOCK_BOOTTIME.
#[cfg(any(target_os = "android", target_os = "fuchsia"))]
const clock_id: libc::clockid_t = libc::CLOCK_BOOTTIME;
#[cfg(not(any(target_vendor = "apple", target_os = "fuchsia", target_os = "android")))]
const clock_id: libc::clockid_t = libc::CLOCK_MONOTONIC;
Instant { t: Timespec::now(clock_id) }
}
Expand Down
Loading