This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v7 0/3] y2038: Linux: Introduce __clock_settime64 function
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Lukasz Majewski <lukma at denx dot de>
- Cc: Alistair Francis <alistair23 at gmail dot com>, Zack Weinberg <zackw at panix dot com>, Arnd Bergmann <arnd at arndb dot de>, Alistair Francis <alistair dot francis at wdc dot com>, GNU C Library <libc-alpha at sourceware dot org>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Florian Weimer <fweimer at redhat dot com>, Carlos O'Donell <carlos at redhat dot com>, Stepan Golosunov <stepan at golosunov dot pp dot ru>
- Date: Tue, 17 Sep 2019 13:42:52 +0000
- Subject: Re: [PATCH v7 0/3] y2038: Linux: Introduce __clock_settime64 function
- Ironport-sdr: mSy0MYCOIm02/bp8Bissov9b0d6hFFMuBnwJGrLwLYQAHAmayGmOtkg87y+dnTUuY1EeOIKtJr 1h2+IlmHdrDBAIDx3cAegMhqLe4bh+NEjuBI0WXR/XBnKVZKcpooVKquDxpgBznvT21LaV9BMK zr6UVnFBbTNOWi/f5FYW+0Yplq5OecWqFxwt0uS1XuM5Mqh2C4hKQRBeLdEuc8v+lX5Rx+lApG iH1V5FW5xhJsxumX0SaVb3Vg5uk0PFcGx1RmFm2/neF1o3bPuv0FlgutORjw+laDNAShEJTHf+ igU=
- Ironport-sdr: DlvOGDZCcTfYj82PhH6KLlLKVAYJI1feLVbcnYDA8Krg83WtkAWewTVYMMjYF0VU6Q1Xc6YgSF OjqFltTNr4C36GVqFDN+ZASRiQQsKP8NKauBZu4hORSe4A6eEJ0/mJ5YVdDB8XSTAx93Xg/H+y FziNKLqAjHK8obqFQT149NT2t0mlMSBj/87owpe/t08wmBmmMD8oeNx0k60Jzy9rc9ACkLl85v lgWf+w8nXWA4S1PTmAIcfFX8yHal9MWzgfKKs5gy617huhaDxYPvq6rSwAEkz5cduSJDSE0+jh nIg=
- References: <20190906145911.30207-1-lukma@denx.de> <CAKmqyKMdsVZg_ZS7fLTt23dy2vnZc1z85b_+8heiK-8UiqMx+g@mail.gmail.com> <alpine.DEB.2.21.1909062122220.30243@digraph.polyomino.org.uk> <CAKmqyKP=kmeJjcsDepetvsVrph3xJ7G8yQdNFNyX-wL2ZMtqmA@mail.gmail.com> <20190917121151.01629dad@jawa>
On Tue, 17 Sep 2019, Lukasz Majewski wrote:
> Then if you replace the condition [1] with #if __TIMESIZE == 64 you
> would have:
>
> struct timespec
> {
> __time_t tv_sec; /* Seconds. */
> __syscall_slong_t tv_nsec; /* Nanoseconds. */
> }
The *public* struct timespec (defined in
time/bits/types/struct_timespec.h) should be changed for ports that define
__TIMESIZE == 64 while __SYSCALL_WORDSIZE == 32.
That is, if __TIMESIZE == 64, and if __SYSCALL_WORDSIZE (if defined) is 32
or __WORDSIZE (if __SYSCALL_WORDSIZE is not defined), then struct timespec
needs endian-dependent padding (defined as an *unnamed* 32-bit bit-field,
so that it gets ignored for initializers). (This is the same padding as
would be needed in the case where __TIMESIZE == 32 but _TIME_BITS=64 is
defined, but _TIME_BITS=64 support for headers comes later.)
RV32 has got away without that change to struct timespec because it's
little-endian, and as long as __time_t is 8-byte-aligned implicit padding
works as well as explicit in the little-endian case. If BE, or if 8-byte
__time_t is only 4-byte-aligned in structs (and so the struct ends up as
12-byte without explicit padding), there would be problems. I think it's
cleanest to make the padding explicit even in the cases where in fact
implicit padding would give the same layout.
RV32 does not need any support for clearing the padding before passing
struct timespec to the kernel, because that's only relevant for compat
syscalls in Linux 5.1.0 to 5.1.4 and the RISC-V kernel doesn't yet have
compat syscall support for running RV32 binaries under RV64 kernels.
--
Joseph S. Myers
joseph@codesourcery.com