summaryrefslogtreecommitdiffstats
path: root/runtime/debug.c
diff options
context:
space:
mode:
authortrey <trey.dempsey@gmail.com>2010-02-03 14:55:35 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-02-03 14:55:35 +0100
commit1fc8e4372bf0c7ccc7f54abe387933dc8a2de670 (patch)
tree51a1985a019f48abbb3283e164701b7f9206c85e /runtime/debug.c
parent38cb3926727c0ad29f3950db43ba12248e867b89 (diff)
downloadrsyslog-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/debug.c')
-rw-r--r--runtime/debug.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/runtime/debug.c b/runtime/debug.c
index a517b1ba..6d82397f 100644
--- a/runtime/debug.c
+++ b/runtime/debug.c
@@ -47,6 +47,9 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
+#if _POSIX_TIMERS <= 0
+#include <sys/time.h>
+#endif
#include "rsyslog.h"
#include "debug.h"
@@ -844,6 +847,9 @@ do_dbgprint(uchar *pszObjName, char *pszMsg, size_t lenMsg)
char pszWriteBuf[32*1024];
size_t lenWriteBuf;
struct timespec t;
+# if _POSIX_TIMERS <= 0
+ struct timeval tv;
+# endif
/* The bWasNL handler does not really work. It works if no thread
* switching occurs during non-NL messages. Else, things are messed
@@ -869,7 +875,14 @@ do_dbgprint(uchar *pszObjName, char *pszMsg, size_t lenMsg)
if(bWasNL) {
if(bPrintTime) {
+# 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
lenWriteBuf = snprintf(pszWriteBuf, sizeof(pszWriteBuf),
"%4.4ld.%9.9ld:", (long) (t.tv_sec % 10000), t.tv_nsec);
if(stddbg != -1) write(stddbg, pszWriteBuf, lenWriteBuf);