[LEAPSECS] Coding this week, and a trick for timeouts over leap seconds.

Paul Sheer p at 2038bug.com
Fri Oct 14 10:21:18 EDT 2011

On Mon, 2011-10-03 at 12:19 +0100, Tony Finch wrote:

> Tom Van Baak <tvb at LeapSecond.com> wrote:

> >

> > Try using clock() instead of gettimeofday_in_millisecs(). The former

> > nicely increments with CLOCKS_PER_SEC resolution and is immune

> > from UTC, timezones, and leap seconds. At least it does on windows.

> > Can someone comment on unix/linux?


> clock() is broken on Windows in order to be backwards-compatible with DOS.

> It is supposed to return the time the process has spent running on the

> CPU, which is traditionally rather slower than real time, though it may be

> faster for a multithreaded process on a multicore computer. Since DOS

> didn't multitask it just returned elapsed time since the process started,

> and Windows has retained this braindamaged semantics.


BTW Windows has QueryPerformanceCounter(). However much as I like Unix
clock() and clock_gettime(CLOCK_MONOTONIC), I'm stuck with the problem
that there are many third party libraries with which I link and much
code written by other teams that I have no idea about.

Any one of those components (some of which run on other machines to
my code - to which I communicate over the network) could have a false
1 second delay.

So it still seems the best way is to assume the delay might be there
and to program defensively. *shrug*


More information about the LEAPSECS mailing list