Bug 1448822 - glibc: Add definition of CLOCK_TAI
Summary: glibc: Add definition of CLOCK_TAI
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: glibc (Show other bugs)
(Show other bugs)
Version: 7.4
Hardware: All Linux
low
low
Target Milestone: rc
: ---
Assignee: Florian Weimer
QA Contact: Sergey Kolosov
Vladimír Slávik
URL:
Whiteboard:
Keywords: Patch
Depends On:
Blocks: 1420851 1473718
TreeView+ depends on / blocked
 
Reported: 2017-05-08 09:58 UTC by Daniele
Modified: 2018-04-10 14:00 UTC (History)
8 users (show)

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: ---


Attachments (Terms of Use)


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

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


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