summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-07-05 21:04:50 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-07-05 21:08:55 +0200
commit8fc765839f89a43d56530bdf051200903b746325 (patch)
tree4e34e2a1406c2d87db4902dacc1c54bfdb33ab61
parent900eac1572cb173206c0b7615fe4e212552e1d94 (diff)
downloadglibc-8fc765839f89a43d56530bdf051200903b746325.tar.gz
Y2038: implement Y2038-proof struct timeval
When time_t was introduced, all time_t based types were modified to use a 64-bit time_t. However, struct timeval uses __time_t and __suseconds_t rather than time_t, and therefore, is left unaffected by __USE_TIME_BITS64; so we introduce a public 64-bit variant with two 64-bit fields, and a private variant called struct __timeval64 for use by 64-bit API implementations.
-rw-r--r--include/time.h6
-rw-r--r--time/bits/types/struct_timeval.h9
2 files changed, 15 insertions, 0 deletions
diff --git a/include/time.h b/include/time.h
index 18f223aac2..06f4084cda 100644
--- a/include/time.h
+++ b/include/time.h
@@ -43,6 +43,12 @@ struct __timespec64
};
#endif
+struct __timeval64
+{
+ __time64_t tv_sec; /* Seconds */
+ __int64_t tv_usec; /* Microseconds */
+};
+
extern __typeof (clock_getres) __clock_getres;
extern __typeof (clock_gettime) __clock_gettime;
extern int __clock_getres64 (clockid_t __clock_id, struct __timespec64 *__res) __THROW;
diff --git a/time/bits/types/struct_timeval.h b/time/bits/types/struct_timeval.h
index 70394ce886..85e0cb5996 100644
--- a/time/bits/types/struct_timeval.h
+++ b/time/bits/types/struct_timeval.h
@@ -5,9 +5,18 @@
/* A time value that is accurate to the nearest
microsecond but also has a range of years. */
+#ifdef __USE_TIME_BITS64
+struct timeval
+{
+ __time64_t tv_sec; /* Seconds. */
+ __uint64_t tv_usec; /* Microseconds. */
+};
+#else
struct timeval
{
__time_t tv_sec; /* Seconds. */
__suseconds_t tv_usec; /* Microseconds. */
};
#endif
+
+#endif