X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_time.c;h=aac6135e28f8bf7d1be5966d5316a64c28200e93;hb=59c7ee1cafaf53814838794908dd84f8101334c7;hp=420b425c0bd1a2739fa398f292062867f57f3144;hpb=a04ffbda508739433df0975328100e33e7986c87;p=collectd.git diff --git a/src/utils_time.c b/src/utils_time.c index 420b425c..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; @@ -40,5 +41,24 @@ cdtime_t cdtime (void) /* {{{ */ 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 : */