summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAJ Lewis <aj.lewis@quantum.com>2012-02-16 10:02:15 +0900
committerMartin Sustrik <sustrik@250bpm.com>2012-02-16 10:02:15 +0900
commitada1db899a7a611ee074dc0c3ee9f293131b06ee (patch)
treee63760e2e003e5d515289d61179cffb652ff55b1 /src
parent1c763b5eeabe0ac3a4464fcf04c1be24df30876c (diff)
Patch from Mikko Koppanen for #LIBZMQ-301
Add the '-Ae' flag and check for gethrtime() on HPUX Check if CLOCK_MONOTONIC defined before using it - if not, use gethrtime() if it's available, otherwise fall back to the old behavior. Signed-off-by: AJ Lewis <aj.lewis@quantum.com>
Diffstat (limited to 'src')
-rw-r--r--src/clock.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/clock.cpp b/src/clock.cpp
index 0406c0a..fe85220 100644
--- a/src/clock.cpp
+++ b/src/clock.cpp
@@ -1,6 +1,6 @@
/*
Copyright (c) 2010-2012 250bpm s.r.o.
- Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2012 Other contributors as noted in the AUTHORS file
This file is part of Crossroads project.
@@ -34,7 +34,7 @@
#include <sys/time.h>
#endif
-#if defined HAVE_CLOCK_GETTIME
+#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETHRTIME
#include <time.h>
#endif
@@ -65,7 +65,7 @@ uint64_t xs::clock_t::now_us ()
double ticks_div = (double) (ticksPerSecond.QuadPart / 1000000);
return (uint64_t) (tick.QuadPart / ticks_div);
-#elif defined HAVE_CLOCK_GETTIME
+#elif defined HAVE_CLOCK_GETTIME && defined CLOCK_MONOTONIC
// Use POSIX clock_gettime function to get precise monotonic time.
struct timespec tv;
@@ -73,6 +73,10 @@ uint64_t xs::clock_t::now_us ()
errno_assert (rc == 0);
return (tv.tv_sec * (uint64_t) 1000000 + tv.tv_nsec / 1000);
+#elif defined HAVE_GETHRTIME
+
+ return (gethrtime () / 1000);
+
#else
// Use POSIX gettimeofday function to get precise time.