This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi Joseph, Alistair,
> 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).
Ok, I will prepare proper patch with adjusting the *public* struct
timespec.
> (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.)
As for example here [1].
Just for (my) confirmation:
- New 32 bits glibc ports (like RISC-V 32) will get __TIMESIZE ==
64 (__WORDSIZE == 32) and no need to define the -D_TIME_BITS=64
during the compilation. They will just get 64 bit time API support
from the outset.
- Already supported 32 bits architectures (like armv7-a with __WORDSIZE
== 32) will keep __TIMESIZE == 32 and require -D_TIME_BITS=64 for
compilation.
After glibc sets the minimal supported kernel version to 5.1 and all
conversions for syscalls to support 64 bit time API are done the
__TIMESIZE will be set to 64 and -D_TIME_BITS=64 will not be required
anymore for compilation.
Until the above switch happens we will redirect time calls - like in
[2].
>
> 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.
Ok.
> 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.
Yes.
> I think it's cleanest to make the padding explicit even in
> the cases where in fact implicit padding would give the same layout.
Ok. So then we shall keep the condition:
#if __WORDSIZE == 64 \
|| (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64)
# define __timespec64 timespec
#else
// struct __timespec64 with endian dependent, explicit padding and
// __time64_t tv_sec;
#fi
And RV32 shall use the explicitly defined struct __timespec64 (from
#else) as presented in [3] ?
>
> 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.
Ok. Thanks for clarification.
>
Note:
[1] -
https://github.com/lmajewski/y2038_glibc/commit/c6740c05ea9b224a552847d10402f98da8376994#diff-4ddbc47d3262d4f00f3825e4f3627dbbR10
[2] -
https://github.com/lmajewski/y2038_glibc/commit/c6740c05ea9b224a552847d10402f98da8376994#diff-07934c1fe09f0e6357413e138856c786R225
[3] -
https://github.com/lmajewski/y2038_glibc/commit/926634e657fa5a927152bf7eb06a62e8468f75ae#diff-5b9f1c6457e0e10079f657f283c19861R53
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Attachment:
pgpZ_Gs_lnlDo.pgp
Description: OpenPGP digital signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |