[LEAPSECS] Time math libraries, UTC to TAI

Zefram zefram at fysh.org
Fri Jan 6 07:10:26 EST 2017


Steve Summit wrote:
>                I have implemented gmtime_ts_r() and mktime_ts()
>which operate on struct timespec, and do the right thing with :60.

Have you also extended struct tm to include tm_nsec?

>I'm not ready to think about the filesystem yet (beyond thinking
>that leapsecond-aware filesystem timestamps don't seem nearly as
>important).

These days filesystem interfaces such as struct stat actually use a
struct timespec for the inode timestamps.  It would be easy to use
a CLOCK_UTC-style denormalised tv_nsec to represent leap seconds at
the kernel interface.  Actually storing them in the filesystem is a
different matter.  Most filesystems only store with second resolution
anyway, so have no place and no need for the extra information.

ext4 does store sub-second timestamps, down to nanosecond resolution,
but it only allocates 30 bits for the nanoseconds.  It uses the remaining
2 bits of that word to extend the representable range, postponing the
Y2038 problem until 2242.  Still need to bum a bit somewhere else to
represent leap seconds.

-zefram


More information about the LEAPSECS mailing list