Skip to content

Commit 2eaa7d3

Browse files
committed
Base approximate time on a monotonic clock, like absolute time
1 parent 3b06f54 commit 2eaa7d3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ AC_CHECK_FUNCS([mach_port_construct])
399399
#
400400
# Find functions and declarations we care about.
401401
#
402-
AC_CHECK_DECLS([CLOCK_UPTIME, CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_UPTIME_FAST], [], [],
402+
AC_CHECK_DECLS([CLOCK_UPTIME, CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_UPTIME_FAST, CLOCK_MONOTONIC_COARSE], [], [],
403403
[[#include <time.h>]])
404404
AC_CHECK_DECLS([NOTE_NONE, NOTE_REAP, NOTE_REVOKE, NOTE_SIGNAL, NOTE_LOWAT], [], [],
405405
[[#include <sys/event.h>]])

src/shims/time.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ _dispatch_approximate_time(void)
152152
struct timespec ts;
153153
dispatch_assume_zero(clock_gettime(CLOCK_UPTIME_FAST, &ts));
154154
return _dispatch_timespec_to_nano(ts);
155-
#elif defined(__linux__)
155+
#elif HAVE_DECL_CLOCK_MONOTONIC_COARSE
156156
struct timespec ts;
157-
dispatch_assume_zero(clock_gettime(CLOCK_REALTIME_COARSE, &ts));
157+
dispatch_assume_zero(clock_gettime(CLOCK_MONOTONIC_COARSE, &ts));
158158
return _dispatch_timespec_to_nano(ts);
159159
#else
160160
return _dispatch_absolute_time();

0 commit comments

Comments
 (0)