On Tue, 2012-07-10 at 15:12 +0100, John Horne wrote:
Printing out what 'now' is gives 0 all the time. 'gettimer' comes from lib/timefunc.c line 49:
====================================== time_t gettimer(void) { int res; struct timespec t;
#if (_POSIX_TIMERS > 0) && defined(_POSIX_MONOTONIC_CLOCK) res = clock_gettime(CLOCK_MONOTONIC, &t); return (time_t) t.tv_sec; #else return time(NULL); #endif }
However printing out 'res' shows that 'clock_gettime' is always returning an error (-1).
Sorry, should have added that errno is showing as 22 (EINVAL). The man page for clock_gettime states:
EINVAL The clk_id specified is not supported on this system.
However, it seems that although _POSIX_MONOTONIC_CLOCK may seem to be available, at runtime it is not. This link (for the 'curl' program) has more discussion about it: http://curl.haxx.se/mail/tracker-2008-07/0003.html
Checking the RHEL3 system using a small program calling 'sysconf' shows that _POSIX_MONOTONIC_CLOCK is available if checked, but is not available at runtime (using sysconf):
=========== monotonic clock: _POSIX_TIMERS: 200112 _POSIX_MONOTONIC_CLOCK: 0 Err found: -1 Err found: -1, errno = 22, string = Invalid argument Sysconf value for _POSIX_MONOTONIC_CLOCK: -1
So the clock seems to be available, but checking at runtime with sysconf says that it is not.
Whereas on an RHEL6 system it shows:
=========== monotonic clock: _POSIX_TIMERS: 200809 _POSIX_MONOTONIC_CLOCK: 0 Sysconf value for _POSIX_MONOTONIC_CLOCK: 200809
Again it seems that the clock is available, and the runtime/sysconf check confirms that.
John.
-- John Horne Tel: +44 (0)1752 587287 Plymouth University, UK Fax: +44 (0)1752 587001