summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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.