diff options
author | trey <trey.dempsey@gmail.com> | 2010-02-03 14:55:35 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2010-02-03 14:55:35 +0100 |
commit | 1fc8e4372bf0c7ccc7f54abe387933dc8a2de670 (patch) | |
tree | 51a1985a019f48abbb3283e164701b7f9206c85e /runtime/srutils.c | |
parent | 38cb3926727c0ad29f3950db43ba12248e867b89 (diff) | |
download | rsyslog-1fc8e4372bf0c7ccc7f54abe387933dc8a2de670.tar.gz rsyslog-1fc8e4372bf0c7ccc7f54abe387933dc8a2de670.tar.xz rsyslog-1fc8e4372bf0c7ccc7f54abe387933dc8a2de670.zip |
patch to make rsyslog compile under Apple OS X
Signed-off-by: Rainer Gerhards <rgerhards@adiscon.com>
Diffstat (limited to 'runtime/srutils.c')
-rw-r--r-- | runtime/srutils.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/runtime/srutils.c b/runtime/srutils.c index 7ddc3ba2..2bed624e 100644 --- a/runtime/srutils.c +++ b/runtime/srutils.c @@ -46,6 +46,9 @@ #include "srUtils.h" #include "obj.h" +#if _POSIX_TIMERS <= 0 +#include <sys/time.h> +#endif /* here we host some syslog specific names. There currently is no better place * to do it, but over here is also not ideal... -- rgerhards, 2008-02-14 @@ -372,10 +375,22 @@ int getNumberDigits(long lNum) rsRetVal timeoutComp(struct timespec *pt, long iTimeout) { +# if _POSIX_TIMERS <= 0 + struct timeval tv; +# endif + BEGINfunc assert(pt != NULL); /* compute timeout */ + +# if _POSIX_TIMERS > 0 + /* this is the "regular" code */ clock_gettime(CLOCK_REALTIME, pt); +# else + gettimeofday(&tv, NULL); + pt->tv_sec = tv.tv_sec; + pt->tv_nsec = tv.tv_usec * 1000; +# endif pt->tv_sec += iTimeout / 1000; pt->tv_nsec += (iTimeout % 1000) * 1000000; /* think INTEGER arithmetic! */ if(pt->tv_nsec > 999999999) { /* overrun? */ @@ -397,11 +412,21 @@ timeoutVal(struct timespec *pt) { struct timespec t; long iTimeout; - BEGINfunc +# if _POSIX_TIMERS <= 0 + struct timeval tv; +# endif + BEGINfunc assert(pt != NULL); /* compute timeout */ +# if _POSIX_TIMERS > 0 + /* this is the "regular" code */ clock_gettime(CLOCK_REALTIME, &t); +# else + gettimeofday(&tv, NULL); + t.tv_sec = tv.tv_sec; + t.tv_nsec = tv.tv_usec * 1000; +# endif iTimeout = (pt->tv_nsec - t.tv_nsec) / 1000000; iTimeout += (pt->tv_sec - t.tv_sec) * 1000; |