Revision
47
Author
robert@fledge.watson.org
Date
2009-10-03 06:14:28 -0700 (Sat, 03 Oct 2009)

Log Message

Check for declarations of CLOCK_UPTIME and CLOCK_MONOTONIC, and when using
clock_gettime() instead of mach_absolute_time() prefer uptime if available.
This is required on Linux, which does not implement CLOCK_UPTIME.

Modified Paths

Diff

Modified: trunk/configure.ac (46 => 47)


--- trunk/configure.ac	2009-09-26 19:29:18 UTC (rev 46)
+++ trunk/configure.ac	2009-10-03 13:14:28 UTC (rev 47)
@@ -172,6 +172,8 @@
 #
 # Find functions and declarations we care about.
 #
+AC_CHECK_DECLS([CLOCK_UPTIME, CLOCK_MONOTONIC], [], [],
+  [[#include <sys/time.h>]])
 AC_CHECK_DECLS([EVFILT_SESSION, NOTE_NONE, NOTE_REAP, NOTE_SIGNAL], [], [],
   [[#include <sys/event.h>]])
 AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include <sys/mount.h>]])

Modified: trunk/src/os_shims.h (46 => 47)


--- trunk/src/os_shims.h	2009-09-26 19:29:18 UTC (rev 46)
+++ trunk/src/os_shims.h	2009-10-03 13:14:28 UTC (rev 47)
@@ -200,7 +200,13 @@
 	struct timespec ts;
 	int ret;
 
+#if HAVE_DECL_CLOCK_UPTIME
 	ret = clock_gettime(CLOCK_UPTIME, &ts);
+#elif HAVE_DECL_CLOCK_MONOTONIC
+	ret = clock_gettime(CLOCK_MONOTONIC, &ts);
+#else
+#error "clock_gettime: no supported absolute time clock"
+#endif
 	dispatch_assume_zero(ret);
 
 	/* XXXRW: Some kind of overflow detection needed? */