]> granicus.if.org Git - libevent/commitdiff
use CLOCK_REALTIME when CLOCK_MONOTONIC is not available; from Phil Oleson
authorNiels Provos <provos@gmail.com>
Sat, 2 Dec 2006 21:25:21 +0000 (21:25 +0000)
committerNiels Provos <provos@gmail.com>
Sat, 2 Dec 2006 21:25:21 +0000 (21:25 +0000)
svn:r290

evdns.c
event.c

diff --git a/evdns.c b/evdns.c
index 085ffa62e6718cd7ed134dc097abfa43463fbb54..b61d0f2f0dec52a1ae46f6ee73571b01fda55e7d 100644 (file)
--- a/evdns.c
+++ b/evdns.c
@@ -799,7 +799,11 @@ transaction_id_pick(void) {
 #ifdef DNS_USE_CPU_CLOCK_FOR_ID
                struct timespec ts;
                u16 trans_id;
-               if (clock_gettime(CLOCK_MONOTONIC, &ts))
+#ifdef CLOCK_MONOTONIC
+               if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
+#else
+               if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
+#endif
                        event_err(1, "clock_gettime");
                 trans_id = ts.tv_nsec & 0xffff;
 #endif
diff --git a/event.c b/event.c
index b5bda5c40e69b765fdebc060bd5cd7da055fe6a4..864d4d267e63c63b4d96caf8278391ec67e76236 100644 (file)
--- a/event.c
+++ b/event.c
@@ -149,8 +149,12 @@ gettime(struct timeval *tp)
 {
 #ifdef HAVE_CLOCK_GETTIME
        struct timespec ts;
-       
+
+#ifdef HAVE_CLOCK_MONOTONIC      
        if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
+#else
+       if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
+#endif
                return (-1);
        tp->tv_sec = ts.tv_sec;
        tp->tv_usec = ts.tv_nsec / 1000;