[ntp:hackers] smearing the leap second

Hal Murray hmurray at megapathdsl.net
Sat Jul 11 08:32:21 UTC 2015


john.stultz at linaro.org said:
>> No systems support TAI.  There is no API to get time in TAI.
> Linux supports CLOCK_TAI via clock_gettime().   One can also get the
> tai_offset via adjtimex(). 

Thanks for the correction.  I thought I checked, but either I fat-fingered 
something or I tried it on an old-old system.

The man page for clock_gettime() doesn't mention CLOCK_TAI, at least not on 
any of the boxes I tried.  It is defined in /usr/include/linux/time.h (at 
least for recent kernels)

Including time.h isn't good enough on many of the systems I tried.  Maybe it 
would work if I defined the right magic feature symbol.

It gives sensible results if somebody tells the kernel the TAI offset.  ntpd 
does that if it has a leap file.

If the TAI offset isn't setup, it lies rather than giving an error.

Do you know of any distros that setup and maintain a leap file out of the box?

----------

I couldn't find CLOCK_TAI on NetBSD or FreeBSD.

---------

Getting TAI using the tai_offset via adjtimex() isn't trivial, at least if 
you expect your code to do the right thing when running over a leap second.  
You have to do something like:
  read tai_offset
  read time in UTC
  read tai_offset again
If the tai_offsets differ, you were reading the clock close to the leap 
second.  Try again.


-- 
These are my opinions.  I hate spam.





More information about the hackers mailing list