From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5143 invoked by alias); 26 Sep 2018 08:41:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 117015 invoked by uid 89); 26 Sep 2018 08:40:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com From: Florian Weimer To: "Albert ARIBAUD \(3ADEV\)" Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v8 1/2] Y2038: Add 64-bit time for all architectures References: <20180926073053.11710-1-albert.aribaud@3adev.fr> Date: Wed, 26 Sep 2018 08:41:00 -0000 In-Reply-To: <20180926073053.11710-1-albert.aribaud@3adev.fr> (Albert ARIBAUD's message of "Wed, 26 Sep 2018 09:30:52 +0200") Message-ID: <87r2hgfy8w.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2018-09/txt/msg00470.txt.bz2 * 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