From ada1db899a7a611ee074dc0c3ee9f293131b06ee Mon Sep 17 00:00:00 2001 From: AJ Lewis Date: Thu, 16 Feb 2012 10:02:15 +0900 Subject: 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 --- configure.in | 2 ++ src/clock.cpp | 10 +++++++--- 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 #endif -#if defined HAVE_CLOCK_GETTIME +#if defined HAVE_CLOCK_GETTIME || defined HAVE_GETHRTIME #include #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. -- cgit v1.2.3