X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Futils_time.c;h=aac6135e28f8bf7d1be5966d5316a64c28200e93;hb=8b695cf6f4fe477a6d44bce39af371510cd90f14;hp=31e31090e58acd05b9f779f179f7175fc22ecfd8;hpb=17fcc3c1cd67ceb0b8305cabb9e7c1e66aba561f;p=collectd.git diff --git a/src/utils_time.c b/src/utils_time.c index 31e31090..aac6135e 100644 --- a/src/utils_time.c +++ b/src/utils_time.c @@ -24,6 +24,7 @@ #include "plugin.h" #include "common.h" +#if HAVE_CLOCK_GETTIME cdtime_t cdtime (void) /* {{{ */ { int status; @@ -38,7 +39,26 @@ cdtime_t cdtime (void) /* {{{ */ 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 : */