[PATCH v7 0/3] y2038: Linux: Introduce __clock_settime64 function
Joseph Myers
joseph@codesourcery.com
Tue Sep 17 13:43:00 GMT 2019
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
More information about the Libc-alpha
mailing list