Hi Martin,

not really sorry. I have zero experience with autotools, we only use
CMake here. clock_gettime is defined in time.h and librt must be
linked to zmq.

There is probably some info in config.log. For me it reads:
configure:18477: checking time.h usability
configure:18477: gcc -std=gnu99 -c -g -O2 -D_GNU_SOURCE -D_REENTRANT
-D_THREAD_SAFE  conftest.c >&5
configure:18477: $? = 0
configure:18477: result: yes
configure:18477: checking time.h presence
configure:18477: gcc -std=gnu99 -E -D_GNU_SOURCE -D_REENTRANT
-D_THREAD_SAFE  conftest.c
configure:18477: $? = 0
configure:18477: result: yes
configure:18477: checking for time.h
configure:18477: result: yes
...
configure:19574: checking for clock_gettime
configure:19574: g++ -o conftest -g -O2 -pedantic -Werror -Wall
-D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE   conftest.cpp -luuid -lrt
-lpthread  >&5
configure:19574: $? = 0
configure:19574: result: yes

Which seems OK since it links against librt. I had hoped that
configure would just include all found headers in conftest.cpp, then
it should work, as it does for me.

I've just found this in configure:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and
sys/time.h may both be included" >&5

Maybe it could also cause problems if the result of it is negative.
For me it's always positive.

What OS are you using, maybe I can try to reproduce it? I've tried it
with OpenSuSE 11.3, SLES 11 SP1, Arch and Gentoo and all of them find
clock_gettime correctly.

Best,
 Mika

On Sat, Dec 3, 2011 at 04:54, Martin Sustrik <[email protected]> wrote:
> Hi Mika,
>
> I've applied the patch locally and for some reason configure doesn't detect
> the fact that clock_gettime is available on my system.
>
>  checking for clock_gettime... no
>
> Any ideas what the problem may be?
>
> Martin
>
>
> On 02/12/11 20:56, Mika Fischer wrote:
>>
>> This makes clock_t insensitive to the system clock being reset by NTP or
>> the sysadmin, which could previously cause long hangs for instance in
>> zmq_poll.
>>
>> Signed-off-by: Mika Fischer<[email protected]>
>> ---
>>  configure.in  |    4 ++--
>>  src/clock.cpp |   12 ++++++++++++
>>  2 files changed, 14 insertions(+), 2 deletions(-)
>>
>> diff --git a/configure.in b/configure.in
>> index fbd0876..bdff0cf 100644
>> --- a/configure.in
>> +++ b/configure.in
>> @@ -254,7 +254,7 @@ LIBZMQ_CHECK_DOC_BUILD
>>  # Checks for header files.
>>  AC_HEADER_STDC
>>  AC_CHECK_HEADERS(errno.h arpa/inet.h netinet/tcp.h netinet/in.h stddef.h
>> \
>> -stdlib.h string.h sys/socket.h sys/time.h unistd.h limits.h)
>> +stdlib.h string.h sys/socket.h sys/time.h time.h unistd.h limits.h)
>>
>>  # Check if we have ifaddrs.h header file.
>>  AC_CHECK_HEADERS(ifaddrs.h, [AC_DEFINE(ZMQ_HAVE_IFADDRS, 1, [Have
>> ifaddrs.h header.])])
>> @@ -376,7 +376,7 @@ AM_CONDITIONAL(ON_MINGW, test "x$libzmq_on_mingw32" =
>> "xyes")
>>
>>  # Checks for library functions.
>>  AC_TYPE_SIGNAL
>> -AC_CHECK_FUNCS(perror gettimeofday memset socket getifaddrs freeifaddrs)
>> +AC_CHECK_FUNCS(perror gettimeofday clock_gettime memset socket getifaddrs
>> freeifaddrs)
>>  AC_CHECK_HEADERS([alloca.h])
>>  LIBZMQ_CHECK_SOCK_CLOEXEC([AC_DEFINE(
>>                                [HAVE_SOCK_CLOEXEC],
>> 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.
>
>
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to