[PATCH v8 1/2] Y2038: Add 64-bit time for all architectures
Florian Weimer
fweimer@redhat.com
Wed Sep 26 08:41:00 GMT 2018
* Albert ARIBAUD:
> diff --git a/posix/bits/types.h b/posix/bits/types.h
> index 5e22ce41bf..cda0a70dd8 100644
> --- a/posix/bits/types.h
> +++ b/posix/bits/types.h
> @@ -211,6 +213,12 @@ __STD_TYPE __U32_TYPE __socklen_t;
> It is not currently necessary for this to be machine-specific. */
> typedef int __sig_atomic_t;
>
> +#if __TIMESIZE == 64
> +# define __time64_t __time_t
> +#else
> +__STD_TYPE __TIME64_T_TYPE __time64_t; /* Seconds since the Epoch. */
> +#endif
Should the __TIMESIZE == 64 case use typedef as well?
> diff --git a/sysdeps/unix/sysv/linux/x86/bits/time64.h b/sysdeps/unix/sysv/linux/x86/bits/time64.h
> new file mode 100644
> index 0000000000..81de09e23f
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/x86/bits/time64.h
> +#if defined __x86_64__ && defined __ILP32__
> +/* For x32, time is 64-bit even though word size is 32-bit. */
> +# define __TIME64_T_TYPE __SQUAD_TYPE
> +#elif __TIMESIZE == 64
> +/* If we already have 64-bit time then use it. */
> +# define __TIME64_T_TYPE __TIME_T_TYPE
> +#else
> +/* Define a 64-bit type alongsize the 32-bit one. */
> +# define __TIME64_T_TYPE __SQUAD_TYPE
> +#endif
Perhaps I'm missing something, but I think this should be put into a
generic header and could be written like this:
#if __TIMESIZE == 64
# define __TIME64_T_TYPE __TIME_T_TYPE
#else
# if __WORDSIZE != 32
# error "32-bit word size expected for non-64-bit time_t"
# endif
# define __TIME64_T_TYPE __SQUAD_TYPE
#endif
I don't think there is a 64-bit port with a 32-bit time_t.
> diff --git a/sysdeps/unix/sysv/linux/x86/bits/timesize.h b/sysdeps/unix/sysv/linux/x86/bits/timesize.h
> new file mode 100644
> index 0000000000..8b88ab84b0
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/x86/bits/timesize.h
> +#if defined __x86_64__ && defined __ILP32__
> +/* For x32, time is 64-bit even though word size is 32-bit. */
> +# define __TIMESIZE 64
> +#else
> +/* For others, time size is word size. */
> +# define __TIMESIZE __WORDSIZE
> +#endif
I think writing this as
#ifdef __x86_64__
/* This includes x32, where time_t is 64-bit even though the word size
is 32-bit. */
# define __TIMESIZE 64
#else
# define __TIMESIZE 32
#endif
is much clearer. It's not that there's going to be a different x86-64
API with yet another time_t size any time soon.
> index 72ef75f074..844a68de8c 100644
> --- a/time/tzfile.c
> +++ b/time/tzfile.c
The tzfile.c changes look okay to me.
Thanks,
Florian
More information about the Libc-alpha
mailing list