Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1448822

Summary: glibc: Add definition of CLOCK_TAI
Product: Red Hat Enterprise Linux 7 Reporter: Daniele <dconsoli>
Component: glibcAssignee: Florian Weimer <fweimer>
Status: CLOSED ERRATA QA Contact: Sergey Kolosov <skolosov>
Severity: low Docs Contact: Vladimír Slávik <vslavik>
Priority: low    
Version: 7.4CC: ashankar, codonell, cww, fweimer, mnewsome, pfrankli, skolosov, vslavik
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
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: Environment:
Last Closed: 2018-04-10 13:58:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1420851, 1473718    

Description Daniele 2017-05-08 09:58:38 UTC
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
#endif

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
glibc-common-2.17-157.el7_3.1.x86_64
glibc-2.17-157.el7_3.1.x86_64
glibc-devel-2.17-157.el7_3.1.x86_64
glibc-headers-2.17-157.el7_3.1.x86_64

Comment 16 errata-xmlrpc 2018-04-10 13:58:28 UTC
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.

https://access.redhat.com/errata/RHSA-2018:0805