[RFC,v2,04/20] include/time.h: Fix conflicting timespec types on 32-bit

Message ID 79521bb1530c313aad9ff019769a88ee10c5b135.1561421042.git.alistair.francis@wdc.com
State New
Headers show
Series
  • RISC-V glibc port for the 32-bit
Related show

Commit Message

Alistair Francis June 25, 2019, 12:08 a.m.
On 32-bit systems with 64-bit time_t the timespec variable will be set
to struct __timespec64 which doesn't match the expected function pointer
for __clock_settime64.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

---
 include/time.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.22.0

Comments

Arnd Bergmann June 25, 2019, 11:17 a.m. | #1
On Tue, Jun 25, 2019 at 2:11 AM Alistair Francis
<alistair.francis@wdc.com> wrote:

> --- a/include/time.h

> +++ b/include/time.h

> @@ -53,7 +53,8 @@ extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)

>    __THROW attribute_hidden;

>

>  #if __WORDSIZE == 64 \

> -  || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64)

> +  || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \

> +  || __TIMESIZE == 64

>  # define __timespec64 timespec

>  #else

>  /* The glibc Y2038-proof struct __timespec64 structure for a time value.


I think you need a bit more here: on 32-bit architectures with 64-bit time_t,
we require padding in 'struct timespec' next to tv_nsec (before or after,
depending on endianess), and I don't see  a patch in your series that
changes 'timespec' accordingly.

See also https://sourceware.org/glibc/wiki/Y2038ProofnessDesign#struct_timespec

       Arnd
Alistair Francis June 25, 2019, 10:20 p.m. | #2
On Tue, Jun 25, 2019 at 4:17 AM Arnd Bergmann <arnd@arndb.de> wrote:
>

> On Tue, Jun 25, 2019 at 2:11 AM Alistair Francis

> <alistair.francis@wdc.com> wrote:

>

> > --- a/include/time.h

> > +++ b/include/time.h

> > @@ -53,7 +53,8 @@ extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)

> >    __THROW attribute_hidden;

> >

> >  #if __WORDSIZE == 64 \

> > -  || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64)

> > +  || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \

> > +  || __TIMESIZE == 64

> >  # define __timespec64 timespec

> >  #else

> >  /* The glibc Y2038-proof struct __timespec64 structure for a time value.

>

> I think you need a bit more here: on 32-bit architectures with 64-bit time_t,

> we require padding in 'struct timespec' next to tv_nsec (before or after,

> depending on endianess), and I don't see  a patch in your series that

> changes 'timespec' accordingly.

>

> See also https://sourceware.org/glibc/wiki/Y2038ProofnessDesign#struct_timespec


Good point, I have updated this.

Alistair

>

>        Arnd

Patch

diff --git a/include/time.h b/include/time.h
index 7155b2e4db..d62fc7b2c3 100644
--- a/include/time.h
+++ b/include/time.h
@@ -53,7 +53,8 @@  extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime)
   __THROW attribute_hidden;
 
 #if __WORDSIZE == 64 \
-  || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64)
+  || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \
+  || __TIMESIZE == 64
 # define __timespec64 timespec
 #else
 /* The glibc Y2038-proof struct __timespec64 structure for a time value.