]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Y2038: add type __time64_t
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
Thu, 7 Sep 2017 22:41:28 +0000 (00:41 +0200)
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
Wed, 13 Jun 2018 07:10:07 +0000 (09:10 +0200)
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
include/time.h
posix/bits/types.h
sysdeps/mach/hurd/bits/typesizes.h
sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
sysdeps/unix/sysv/linux/generic/bits/typesizes.h
sysdeps/unix/sysv/linux/s390/bits/typesizes.h
sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
sysdeps/unix/sysv/linux/x86/bits/typesizes.h

index 85eacf2518708462e15021fd9e6516836f9517fb..0b6a19c230689833e4a86921b5525a0e945ba137 100644 (file)
@@ -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
index 23d2580528b024902d776c0ce5611bc2248a63ec..93638aa215cb62a02aad7b8783b509b48bbf737c 100644 (file)
@@ -3,6 +3,7 @@
 
 #ifndef _ISOMAC
 # include <bits/types/locale_t.h>
+# include <stdbool.h>
 
 extern __typeof (strftime_l) __strftime_l;
 libc_hidden_proto (__strftime_l)
@@ -101,10 +102,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
index 5e22ce41bf4c29b3eee160d589c128e54f1ee4de..4c6553a266575c31355ef843e181c42ed37c2718 100644 (file)
@@ -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.  */
 
index d3026ba66e61c17c3a205580390a58a937e76879..c9dbe2bf33b3be092560e53970fa16f5caf71173 100644 (file)
@@ -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
index d9a0b0467c8d2bfafa86726a69102f6f3e8f63fe..47b1e36165ff8046fab4232724f4ddc3cfbbd987 100644 (file)
@@ -47,6 +47,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     __S64_TYPE
 #define __DADDR_T_TYPE         __S32_TYPE
index a2cb3433bf5f7d9a4400bbe51f1e91bfd5321144..db03b1ae8bc2dcbc6d39f827249c5049cdb07acc 100644 (file)
@@ -49,6 +49,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
index fdaa4219586f606f5db4a0a663f709c55a631831..138c6d6d10d30afc129ccb8881ead7a3beb3db6b 100644 (file)
@@ -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
index b59f2ced75304ec61e0e6d0119642dd66acb6ee6..5d6fb00a931575630f7e7719088e1b86e5f38808 100644 (file)
@@ -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     __S32_TYPE
 #define __DADDR_T_TYPE         __S32_TYPE
index e6f7481a19cbc7857dbbfebef5adbeeaf80a70b8..f5d792d8f3f348d43418a0eb4cb6b852258e7365 100644 (file)
@@ -62,6 +62,7 @@
 #define __ID_T_TYPE            __U32_TYPE
 #define __CLOCK_T_TYPE         __SYSCALL_SLONG_TYPE
 #define __TIME_T_TYPE          __SYSCALL_SLONG_TYPE
+#define __TIME64_T_TYPE                __SQUAD_TYPE
 #define __USECONDS_T_TYPE      __U32_TYPE
 #define __SUSECONDS_T_TYPE     __SYSCALL_SLONG_TYPE
 #define __DADDR_T_TYPE         __S32_TYPE