From 8fc765839f89a43d56530bdf051200903b746325 Mon Sep 17 00:00:00 2001 From: "Albert ARIBAUD (3ADEV)" Date: Wed, 5 Jul 2017 21:04:50 +0200 Subject: 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. --- include/time.h | 6 ++++++ time/bits/types/struct_timeval.h | 9 +++++++++ 2 files changed, 15 insertions(+) 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 -- cgit v1.2.1