Skip to content
Open
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
7 changes: 6 additions & 1 deletion library/std/src/sys/pal/unix/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ pub struct Instant {
impl Instant {
#[cfg(target_vendor = "apple")]
pub(crate) const CLOCK_ID: libc::clockid_t = libc::CLOCK_UPTIME_RAW;
#[cfg(not(target_vendor = "apple"))]
#[cfg(target_os = "android")]
pub(crate) const CLOCK_ID: libc::clockid_t = libc::CLOCK_BOOTTIME;
#[cfg(not(any(target_vendor = "apple", target_os = "android")))]
pub(crate) const CLOCK_ID: libc::clockid_t = libc::CLOCK_MONOTONIC;
pub fn now() -> Instant {
// https://www.manpagez.com/man/3/clock_gettime/
Expand All @@ -289,6 +291,9 @@ impl Instant {
//
// Instant on macos was historically implemented using mach_absolute_time;
// we preserve this value domain out of an abundance of caution.
//
// On Android, we use CLOCK_BOOTTIME because we want the duration between
// Instants to not be affected by suspends.
Instant { t: Timespec::now(Self::CLOCK_ID) }
}

Expand Down
Loading