Red Hat Bugzilla – Bug 1448822
glibc: Add definition of CLOCK_TAI
Last modified: 2018-04-10 10:00:11 EDT
Description of problem:
While CLOCK_TAI is supported by the kernel, it seems not to be supported by glibc yet.
As of now, the customer has to add
# define CLOCK_TAI 11
after the inclusion of <time.h>, to get a usable definition.
According the following document CLOCK_TAI is supported by RHEL7: https://developers.redhat.com/blog/2015/06/01/five-different-ways-handle-leap-seconds-ntp/
The following is mentioned in the article:
"For applications where it would be possible to work with TAI time instead of UTC, the kernel provides a special CLOCK_TAI clock which does include leap seconds and doesn’t need to be corrected after leap second, avoiding the problem with backward jump in the time entirely. It’s implemented as a clock running at a fixed integral offset to CLOCK_REALTIME, which is atomically incremented by 1 when the CLOCK_REALTIME clock is stepped back on leap second. It was introduced in the Linux kernel version 3.10 and is available with the kernels shipped in RHEL7. "
So according the article CLOCK_TAI should be available.
Unfortunately the following code fails to compile:
[root@host2 ~]# cat test.c
struct timespec ts_realtime;
struct timespec ts_tai;
printf("Realtime: %lld.%.9ld\n", (long long)ts_realtime.tv_sec, ts_realtime.tv_nsec);
printf("TAI: %lld.%.9ld\n", (long long)ts_tai.tv_sec, ts_tai.tv_nsec);
[root@host2 ~]# gcc -lrt test.c -o test
test.c: In function ‘main’:
test.c:12:18: error: ‘CLOCK_TAI’ undeclared (first use in this function)
test.c:12:18: note: each undeclared identifier is reported only once for each function it appears in
So CLOCK_TAI is not recognized.
[root@host2 ~]# uname -a
Linux host2 3.10.0-514.16.1.el7.x86_64 #1 SMP Fri Mar 10 13:12:32 EST 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@host2 ~]# rpm -qa | grep glibc
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.