diff options
author | Martin Lucina <martin@lucina.net> | 2012-01-23 09:00:29 +0100 |
---|---|---|
committer | Martin Lucina <martin@lucina.net> | 2012-01-23 09:00:29 +0100 |
commit | ba0336b4d129a9e261c95276f89640b3459176bf (patch) | |
tree | a488f7efb61a6950a462815062c3b0f007f40ff5 /src/clock.cpp | |
parent | c3363afa881b46f3df8a6b72ed15cfbac18f4713 (diff) | |
parent | 4016b657973bba87caf75168ba70aaa85d556487 (diff) |
Merge commit 'upstream/2.1.11'
Diffstat (limited to 'src/clock.cpp')
-rw-r--r-- | src/clock.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/clock.cpp b/src/clock.cpp index f98a2f4..f1da091 100644 --- a/src/clock.cpp +++ b/src/clock.cpp @@ -34,6 +34,10 @@ #include <sys/time.h> #endif +#if defined HAVE_CLOCK_GETTIME +#include <time.h> +#endif + zmq::clock_t::clock_t () : last_tsc (rdtsc ()), last_time (now_us () / 1000) @@ -61,6 +65,14 @@ uint64_t zmq::clock_t::now_us () double ticks_div = (double) (ticksPerSecond.QuadPart / 1000000); return (uint64_t) (tick.QuadPart / ticks_div); +#elif defined HAVE_CLOCK_GETTIME + + // Use POSIX clock_gettime function to get precise monotonic time. + struct timespec tv; + int rc = clock_gettime (CLOCK_MONOTONIC, &tv); + errno_assert (rc == 0); + return (tv.tv_sec * (uint64_t) 1000000 + tv.tv_nsec / 1000); + #else // Use POSIX gettimeofday function to get precise time. |