diff --git a/src/collectd-tg.c b/src/collectd-tg.c
index 80473e0ef79816fe53becb2ab41f4f86c5c86715..05cf9a76a3200e7ffddb42e02111acd3f0f2a562 100644 (file)
--- a/src/collectd-tg.c
+++ b/src/collectd-tg.c
loop = 0;
} /* }}} void signal_handler */
loop = 0;
} /* }}} void signal_handler */
+#if HAVE_CLOCK_GETTIME
static double dtime (void) /* {{{ */
{
struct timespec ts = { 0 };
static double dtime (void) /* {{{ */
{
struct timespec ts = { 0 };
return ((double) ts.tv_sec) + (((double) ts.tv_nsec) / 1e9);
} /* }}} double dtime */
return ((double) ts.tv_sec) + (((double) ts.tv_nsec) / 1e9);
} /* }}} double dtime */
+#else
+/* Work around for Mac OS X which doesn't have clock_gettime(2). *sigh* */
+static double dtime (void) /* {{{ */
+{
+ struct timeval tv = { 0 };
+
+ if (gettimeofday (&tv, /* timezone = */ NULL) != 0)
+ perror ("gettimeofday");
+
+ return ((double) tv.tv_sec) + (((double) tv.tv_usec) / 1e6);
+} /* }}} double dtime */
+#endif
static int compare_time (const void *v0, const void *v1) /* {{{ */
{
static int compare_time (const void *v0, const void *v1) /* {{{ */
{