about summary refs log tree commit homepage
path: root/ext/clogger_ext/broken_system_compat.h
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-14 09:07:57 +0000
committerEric Wong <normalperson@yhbt.net>2011-01-14 09:07:57 +0000
commitcc43cfbb418ab7b4b2786123d33ede23b3cb5ea3 (patch)
treef13ea8da377c8a95e2c860f7ca9307807dcab6de /ext/clogger_ext/broken_system_compat.h
parent6cc7e96f972d9a648bef9d49ca245282250a5502 (diff)
downloadclogger-cc43cfbb418ab7b4b2786123d33ede23b3cb5ea3.tar.gz
This should also detect cases where CLOCK_MONOTONIC is
available at build but not at runtime.
Diffstat (limited to 'ext/clogger_ext/broken_system_compat.h')
-rw-r--r--ext/clogger_ext/broken_system_compat.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/ext/clogger_ext/broken_system_compat.h b/ext/clogger_ext/broken_system_compat.h
index f58307e..ec635b1 100644
--- a/ext/clogger_ext/broken_system_compat.h
+++ b/ext/clogger_ext/broken_system_compat.h
@@ -3,11 +3,15 @@
  * without clock_gettime() or CLOCK_MONOTONIC
  */
 
+#ifndef HAVE_TYPE_CLOCKID_T
+typedef clockid_t int;
+#endif
+
 #ifndef HAVE_CLOCK_GETTIME
 #  ifndef CLOCK_REALTIME
 #    define CLOCK_REALTIME 0 /* whatever */
 #  endif
-static int fake_clock_gettime(int clk_id, struct timespec *res)
+static int fake_clock_gettime(clockid_t clk_id, struct timespec *res)
 {
         struct timeval tv;
         int r = gettimeofday(&tv, NULL);
@@ -21,7 +25,12 @@ static int fake_clock_gettime(int clk_id, struct timespec *res)
 #  define clock_gettime fake_clock_gettime
 #endif /* broken systems w/o clock_gettime() */
 
-/* UGH */
-#ifndef _POSIX_MONOTONIC_CLOCK
-#  define CLOCK_MONOTONIC CLOCK_REALTIME
+/*
+ * UGH
+ * CLOCK_MONOTONIC is not guaranteed to be a macro, either
+ */
+#ifndef CLOCK_MONOTONIC
+#  if (!defined(_POSIX_MONOTONIC_CLOCK) || !defined(HAVE_CLOCK_MONOTONIC))
+#    define CLOCK_MONOTONIC CLOCK_REALTIME
+#  endif
 #endif