aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-09-08 00:41:28 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-06-13 09:10:07 +0200
commit31c83d4fac035599590eeaa63a15b83e7fe2b83c (patch)
treea3ae75196ba34956a747cffd8225374097314ed5
parenta745c837cb51c2efe8900740548cb68ec2a2f7ab (diff)
downloadglibc-31c83d4fac035599590eeaa63a15b83e7fe2b83c.tar
glibc-31c83d4fac035599590eeaa63a15b83e7fe2b83c.tar.gz
glibc-31c83d4fac035599590eeaa63a15b83e7fe2b83c.tar.bz2
glibc-31c83d4fac035599590eeaa63a15b83e7fe2b83c.zip
Y2038: add type __time64_t
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.
-rw-r--r--bits/typesizes.h1
-rw-r--r--include/time.h9
-rw-r--r--posix/bits/types.h3
-rw-r--r--sysdeps/mach/hurd/bits/typesizes.h1
-rw-r--r--sysdeps/unix/sysv/linux/alpha/bits/typesizes.h1
-rw-r--r--sysdeps/unix/sysv/linux/generic/bits/typesizes.h1
-rw-r--r--sysdeps/unix/sysv/linux/s390/bits/typesizes.h1
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/typesizes.h1
-rw-r--r--sysdeps/unix/sysv/linux/x86/bits/typesizes.h1
9 files changed, 17 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 23d2580528..93638aa215 100644
--- a/include/time.h
+++ b/include/time.h
@@ -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
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. */
diff --git a/sysdeps/mach/hurd/bits/typesizes.h b/sysdeps/mach/hurd/bits/typesizes.h
index d3026ba66e..c9dbe2bf33 100644
--- a/sysdeps/mach/hurd/bits/typesizes.h
+++ b/sysdeps/mach/hurd/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/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
index d9a0b0467c..47b1e36165 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
@@ -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
diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
index a2cb3433bf..db03b1ae8b 100644
--- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h
@@ -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
diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
index fdaa421958..138c6d6d10 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/s390/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/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
index b59f2ced75..5d6fb00a93 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/sparc/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 __S32_TYPE
#define __DADDR_T_TYPE __S32_TYPE
diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
index e6f7481a19..f5d792d8f3 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h
@@ -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