This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 3/6] y2038: Introduce struct __timeval64 - new internal glibc type
- From: Lukasz Majewski <lukma at denx dot de>
- To: Joseph Myers <joseph at codesourcery dot com>, Paul Eggert <eggert at cs dot ucla dot edu>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Samuel Thibault <samuel dot thibault at ens-lyon dot org>
- Cc: Alistair Francis <alistair23 at gmail dot com>, Alistair Francis <alistair dot francis at wdc dot com>, GNU C Library <libc-alpha at sourceware dot org>, Siddhesh Poyarekar <siddhesh at gotplt dot org>, Florian Weimer <fweimer at redhat dot com>, Florian Weimer <fw at deneb dot enyo dot de>, Zack Weinberg <zackw at panix dot com>, Carlos O'Donell <carlos at redhat dot com>, Andreas Schwab <schwab at suse dot de>, Lukasz Majewski <lukma at denx dot de>
- Date: Sat, 18 Jan 2020 08:20:44 +0100
- Subject: [PATCH 3/6] y2038: Introduce struct __timeval64 - new internal glibc type
- References: <20200118072047.23071-1-lukma@denx.de>
This type is a glibc's "internal" type similar to struct timeval but
whose tv_sec field is a __time64_t rather than a time_t, which makes it
Y2038-proof. This struct is NOT supposed to be passed to the kernel -
instead it shall be converted to struct __timespec64 and clock_[sg]ettime
syscalls shall be used (which are now Y2038 safe).
Build tests:
./src/scripts/build-many-glibcs.py glibcs
---
include/time.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/time.h b/include/time.h
index 047f431a1a..22ecacd0d8 100644
--- a/include/time.h
+++ b/include/time.h
@@ -93,6 +93,20 @@ struct __itimerspec64
};
#endif
+#if __TIMESIZE == 64
+# define __timeval64 timeval
+#else
+/* The glibc Y2038-proof struct __timeval64 structure for a time value.
+ This structure is NOT supposed to be passed to the Linux kernel.
+ Instead, it shall be converted to struct __timespec64 and time shall
+ be [sg]et via clock_[sg]ettime (which are now Y2038 safe). */
+struct __timeval64
+{
+ __time64_t tv_sec; /* Seconds */
+ __suseconds_t tv_usec; /* Microseconds */
+};
+#endif
+
#if __TIMESIZE == 64
# define __ctime64 ctime
#else
--
2.20.1