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

Paul Sheer p at 2038bug.com
Sat Oct 1 17:34:34 EDT 2011

On Sat, 2011-10-01 at 13:35 -0700, Tom Van Baak 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() wraps every 36 minutes on 32-bit systems *sigh*

What would work is CLOCK_MONOTONIC (if supported). But that requires
a lot of *thinking* about the sense of the old code one is working on.
Suppose one wanted to audit as little as possible - ?

BTW within Linux headers....

#define CLOCKS_PER_SEC 1000000l

#define __SLONGWORD_TYPE long int
__STD_TYPE __CLOCK_T_TYPE __clock_t;
typedef __clock_t clock_t;
extern clock_t clock (void) __THROW;


More information about the LEAPSECS mailing list