Skip to content
Open
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
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
4 changes: 4 additions & 0 deletions library/std/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,17 @@ use crate::sys_common::{FromInner, IntoInner};
/// | SOLID | `get_tim` |
/// | WASI | [__wasi_clock_time_get (Monotonic Clock)] |
/// | Windows | [QueryPerformanceCounter] |
/// | Android | [clock_gettime (Boottime Clock)] |
/// | Fuchsia | [zx_clock_get_boot] |
///
/// [currently]: crate::io#platform-specific-behavior
/// [QueryPerformanceCounter]: https://docs.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter
/// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time
/// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode
/// [__wasi_clock_time_get (Monotonic Clock)]: https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#clock_time_get
/// [clock_gettime (Monotonic Clock)]: https://linux.die.net/man/3/clock_gettime
/// [clock_gettime (Boottime Clock)]: https://linux.die.net/man/2/clock_gettime
/// [zx_clock_get_boot]: https://fuchsia.dev/reference/syscalls/clock_get_boot
///
/// **Disclaimer:** These system calls might change over time.
///
Expand Down
Loading