From patchwork Wed Apr 18 20:17:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert ARIBAUD X-Patchwork-Id: 26780 Received: (qmail 96667 invoked by alias); 18 Apr 2018 20:18:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 96548 invoked by uid 89); 18 Apr 2018 20:18:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_RP_RNBL autolearn=ham version=3.3.2 spammy= X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Cc: "Albert ARIBAUD (3ADEV)" Subject: [[PATCH RFC 2] 01/63] Y2038: add type __time64_t Date: Wed, 18 Apr 2018 22:17:17 +0200 Message-Id: <20180418201819.15952-2-albert.aribaud@3adev.fr> In-Reply-To: <20180418201819.15952-1-albert.aribaud@3adev.fr> References: <20180418201819.15952-1-albert.aribaud@3adev.fr> This type is public, so that time_t can be a typedef of it when we switch the public API to 64-bit time. Also, provide a function to check if a __time64_t value fits in a (32-bit) __time_t. --- bits/typesizes.h | 1 + include/time.h | 9 ++++++++- posix/bits/types.h | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bits/typesizes.h b/bits/typesizes.h index 85eacf2518..0b6a19c230 100644 --- a/bits/typesizes.h +++ b/bits/typesizes.h @@ -48,6 +48,7 @@ #define __ID_T_TYPE __U32_TYPE #define __CLOCK_T_TYPE __SLONGWORD_TYPE #define __TIME_T_TYPE __SLONGWORD_TYPE +#define __TIME64_T_TYPE __SQUAD_TYPE #define __USECONDS_T_TYPE __U32_TYPE #define __SUSECONDS_T_TYPE __SLONGWORD_TYPE #define __DADDR_T_TYPE __S32_TYPE diff --git a/include/time.h b/include/time.h index aab26d7768..7eda265a66 100644 --- a/include/time.h +++ b/include/time.h @@ -3,6 +3,7 @@ #ifndef _ISOMAC # include +# include extern __typeof (strftime_l) __strftime_l; libc_hidden_proto (__strftime_l) @@ -97,10 +98,16 @@ extern char * __strptime_internal (const char *rp, const char *fmt, extern double __difftime (time_t time1, time_t time0); - /* Use in the clock_* functions. Size of the field representing the actual clock ID. */ #define CLOCK_IDFIELD_SIZE 3 +/* check whether a time64_t value fits in a time_t */ +static inline bool +fits_in_time_t (__time64_t t) +{ + return t == (time_t) t; +} + #endif #endif diff --git a/posix/bits/types.h b/posix/bits/types.h index 5e22ce41bf..4c6553a266 100644 --- a/posix/bits/types.h +++ b/posix/bits/types.h @@ -155,7 +155,8 @@ __STD_TYPE __CLOCK_T_TYPE __clock_t; /* Type of CPU usage counts. */ __STD_TYPE __RLIM_T_TYPE __rlim_t; /* Type for resource measurement. */ __STD_TYPE __RLIM64_T_TYPE __rlim64_t; /* Type for resource measurement (LFS). */ __STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */ -__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */ +__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch, Y2038-unsafe. */ +__STD_TYPE __TIME64_T_TYPE __time64_t; /* Seconds since the Epoch, Y2038-safe. */ __STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */ __STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */