summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.in2
-rw-r--r--src/clock.cpp10
2 files changed, 9 insertions, 3 deletions
diff --git a/configure.in b/configure.in
index 382329f..72dec47 100644
--- a/configure.in
+++ b/configure.in
@@ -167,6 +167,8 @@ case "${host_os}" in
# Define on HP-UX to enable all library features
CPPFLAGS="-D_POSIX_C_SOURCE=200112L $CPPFLAGS"
AC_DEFINE(XS_HAVE_HPUX, 1, [Have HPUX OS])
+ LIBXS_CHECK_LANG_FLAG_PREPEND([-Ae])
+ AC_CHECK_FUNCS(gethrtime)
;;
*mingw32*)
AC_DEFINE(XS_HAVE_WINDOWS, 1, [Have Windows OS])
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.