File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
library/std/src/sys/pal/unix Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -275,7 +275,9 @@ pub struct Instant {
275275impl Instant {
276276 #[ cfg( target_vendor = "apple" ) ]
277277 pub ( crate ) const CLOCK_ID : libc:: clockid_t = libc:: CLOCK_UPTIME_RAW ;
278- #[ cfg( not( target_vendor = "apple" ) ) ]
278+ #[ cfg( target_os = "android" ) ]
279+ pub ( crate ) const CLOCK_ID : libc:: clockid_t = libc:: CLOCK_BOOTTIME ;
280+ #[ cfg( not( any( target_vendor = "apple" , target_os = "android" ) ) ) ]
279281 pub ( crate ) const CLOCK_ID : libc:: clockid_t = libc:: CLOCK_MONOTONIC ;
280282 pub fn now ( ) -> Instant {
281283 // https://www.manpagez.com/man/3/clock_gettime/
@@ -289,6 +291,9 @@ impl Instant {
289291 //
290292 // Instant on macos was historically implemented using mach_absolute_time;
291293 // we preserve this value domain out of an abundance of caution.
294+ //
295+ // On Android, we use CLOCK_BOOTTIME because we want the duration between
296+ // Instants to not be affected by suspends.
292297 Instant { t : Timespec :: now ( Self :: CLOCK_ID ) }
293298 }
294299
You can’t perform that action at this time.
0 commit comments