[PATCH 02/10] y2038: Introduce struct __timex64 - new internal glibc type
Lukasz Majewski
lukma@denx.de
Sun Apr 26 13:31:02 GMT 2020
The introduced glibc's 'internal' struct __timex64 is a copy of Linux kernel's
struct __kernel_timex (v5.6) introduced for properly handling data for
clock_adjtime64 syscall.
As the struct's __kernel_timex size is the same as for archs with
__WORDSIZE == 64, proper padding and data types conversion (i.e. long to long
long) had to be added for architectures with __WORDSIZE == 32 &&
__TIMESIZE != 64.
Moreover, it stores time in struct __timeval64 rather than struct
timeval, which makes it Y2038-proof.
Build tests:
./src/scripts/build-many-glibcs.py glibcs
---
sysdeps/unix/sysv/linux/include/sys/timex.h | 38 +++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
index 319d566608..f25081639b 100644
--- a/sysdeps/unix/sysv/linux/include/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
@@ -25,5 +25,43 @@
libc_hidden_proto (__adjtimex)
+# include <struct___timeval64.h>
+/* Local definition of 64 bit time supporting timex struct */
+# if __TIMESIZE == 64
+# define __timex64 timex
+# else
+
+struct __timex64
+{
+ unsigned int modes; /* mode selector */
+ int :32; /* pad */
+ long long offset; /* time offset (usec) */
+ long long freq; /* frequency offset (scaled ppm) */
+ long long maxerror; /* maximum error (usec) */
+ long long esterror; /* estimated error (usec) */
+ int status; /* clock command/status */
+ int :32; /* pad */
+ long long constant; /* pll time constant */
+ long long precision; /* clock precision (usec) (read only) */
+ long long tolerance; /* clock frequency tolerance (ppm) (ro) */
+ struct __timeval64 time; /* (read only, except for ADJ_SETOFFSET) */
+ long long tick; /* (modified) usecs between clock ticks */
+ long long ppsfreq; /* pps frequency (scaled ppm) (ro) */
+ long long jitter; /* pps jitter (us) (ro) */
+ int shift; /* interval duration (s) (shift) (ro) */
+ int :32; /* pad */
+ long long stabil; /* pps stability (scaled ppm) (ro) */
+ long long jitcnt; /* jitter limit exceeded (ro) */
+ long long calcnt; /* calibration intervals (ro) */
+ long long errcnt; /* calibration errors (ro) */
+ long long stbcnt; /* stability limit exceeded (ro) */
+
+ int tai; /* TAI offset (ro) */
+
+ int :32; int :32; int :32; int :32;
+ int :32; int :32; int :32; int :32;
+ int :32; int :32; int :32;
+};
+# endif
# endif /* _ISOMAC */
#endif /* sys/timex.h */
--
2.20.1
More information about the Libc-alpha
mailing list