Bugzilla will be upgraded to version 5.0 on December 2, 2018. The outage period for the upgrade will start at 0:00 UTC and have a duration of 12 hours
Bug 1448822 - glibc: Add definition of CLOCK_TAI
glibc: Add definition of CLOCK_TAI
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: glibc (Show other bugs)
All Linux
low Severity low
: rc
: ---
Assigned To: Florian Weimer
Sergey Kolosov
Vladimír Slávik
: Patch
Depends On:
Blocks: 1420851 1473718
  Show dependency treegraph
Reported: 2017-05-08 05:58 EDT by Daniele
Modified: 2018-04-10 10:00 EDT (History)
8 users (show)

See Also:
Fixed In Version: glibc-2.17-209.el7
Doc Type: Enhancement
Doc Text:
TAI clock macro available Previously, the kernel provided the `CLOCK_TAI` clock, but the `CLOCK_TAI` macro to access it was missing in the *glibc* header file `time.h`. The macro definition has been added to the header file. As a result, applications can now access the `CLOCK_TAI` kernel clock.
Story Points: ---
Clone Of:
Last Closed: 2018-04-10 09:58:28 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Sourceware 17608 None None None 2017-10-18 06:43 EDT
Red Hat Product Errata RHSA-2018:0805 None None None 2018-04-10 10:00 EDT

  None (edit)
Description Daniele 2017-05-08 05:58:38 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

#ifndef CLOCK_TAI
# define CLOCK_TAI 11

after the inclusion of <time.h>, to get a usable definition.

Additional info:
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int main()
   struct timespec ts_realtime;
   struct timespec ts_tai;

   clock_gettime(CLOCK_REALTIME, &ts_realtime);
   clock_gettime(CLOCK_TAI, &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)
    clock_gettime(CLOCK_TAI, &ts_tai);
test.c:12:18: note: each undeclared identifier is reported only once for each function it appears in

So CLOCK_TAI is not recognized.
Used kernel:
[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
Comment 16 errata-xmlrpc 2018-04-10 09:58:28 EDT
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.


Note You need to log in before you can comment on or make changes to this bug.