diff --git a/src/utils_time.c b/src/utils_time.c
index 31e31090e58acd05b9f779f179f7175fc22ecfd8..aac6135e28f8bf7d1be5966d5316a64c28200e93 100644 (file)
--- a/src/utils_time.c
+++ b/src/utils_time.c
#include "plugin.h"
#include "common.h"
+#if HAVE_CLOCK_GETTIME
cdtime_t cdtime (void) /* {{{ */
{
int status;
return (0);
}
- return (TIMESPEC_TO_CDTIME_T (ts));
+ return (TIMESPEC_TO_CDTIME_T (&ts));
} /* }}} cdtime_t cdtime */
+#else
+/* Work around for Mac OS X which doesn't have clock_gettime(2). *sigh* */
+cdtime_t cdtime (void) /* {{{ */
+{
+ int status;
+ struct timeval tv = { 0, 0 };
+
+ status = gettimeofday (&tv, /* struct timezone = */ NULL);
+ if (status != 0)
+ {
+ char errbuf[1024];
+ ERROR ("cdtime: gettimeofday failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (0);
+ }
+
+ return (TIMEVAL_TO_CDTIME_T (&tv));
+} /* }}} cdtime_t cdtime */
+#endif
/* vim: set sw=2 sts=2 et fdm=marker : */