This is one of multiple possible extended definitions for timex, to
allow future user space to keep working while defining time_t
to 64-bit. The idea is that clock_adjtime() will take the new
structure, which has an identical layout between 32-bit and 64-bit
tasks, so we can use the compat_sys_clock_adjtime() function to
always handle the old 32-bit layout, and use sys_clock_adjtime()
to handle the new layout, without introducing an extra compat
function.

Alternatives to this approach are:

- define a new __kernel_timex that only differs in the size of the
  timex->time member, so we can keep using the old definition in
  source form, but with the new timeval definition. This requires
  adding an extra system call on 64-bit machines, to handle all
  three layouts.

- use some of the padding words to store the upper half of the
  time_t. This allows us to keep using the existing system calls,
  but requires source-level changes in every user program to
  actually access the new data.

Signed-off-by: Arnd Bergmann <[email protected]>
---
 include/uapi/linux/timex.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/include/uapi/linux/timex.h b/include/uapi/linux/timex.h
index 92685d826444..80c429ecdf4e 100644
--- a/include/uapi/linux/timex.h
+++ b/include/uapi/linux/timex.h
@@ -92,6 +92,50 @@ struct timex {
        int  :32; int  :32; int  :32;
 };
 
+
+/*
+ * __kernel_timex is the new structure that uses the same layout
+ * as timex on 64-bit machines
+ */
+struct __kernel_timex_timeval {
+       long long tv_sec;
+       long long tv_usec;
+};
+
+struct __kernel_timex {
+       unsigned int modes;     /* mode selector */
+       unsigned 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 */
+       unsigned int :32;       /* pad */
+       long long constant;     /* pll time constant */
+       long long precision;    /* clock precision (usec) (read only) */
+       long long tolerance;    /* clock frequency tolerance (ppm)
+                                * (read only)
+                                */
+       struct __kernel_timex_timeval 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) */
+       unsigned 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;
+};
+
 /*
  * Mode codes (timex.mode)
  */
-- 
2.1.0.rc2

_______________________________________________
Y2038 mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/y2038

Reply via email to