History

time: Add struct __kernel_timex

struct timex uses struct timeval internally. struct timeval is not y2038 safe. Introduce a new UAPI type struct __kernel_timex that is y2038 safe. struct __kernel_timex uses a timeval type that is similar to struct __kernel_timespec which preserves the same structure size across 32 bit and 64 bit ABIs. struct __kernel_timex also restructures other members of the structure to make the structure the same on 64 bit and 32 bit architectures. Note that struct __kernel_timex is the same as struct timex on a 64 bit architecture. The above solution is similar to other new y2038 syscalls that are being introduced: both 32 bit and 64 bit ABIs have a common entry, and the compat entry supports the old 32 bit syscall interface. Alternatives considered were: 1. Add new time type to struct timex that makes use of padded bits. This time type could be based on the struct __kernel_timespec. modes will use a flag to notify which time structure should be used internally. This needs some application level changes on both 64 bit and 32 bit architectures. Although 64 bit machines could continue to use the older timeval structure without any changes. 2. Add a new u8 type to struct timex that makes use of padded bits. This can be used to save higher order tv_sec bits. modes will use a flag to notify presence of such a type. This will need some application level changes on 32 bit architectures. 3. Add a new compat_timex structure that differs in only the size of the time type; keep rest of struct timex the same. This requires extra syscalls to manage all 3 cases on 64 bit architectures. This will not need any application level changes but will add more complexity from kernel side.

Deepa Dinamani committed 8 years ago

Commit 2c620ff1 parent 4d5f0072 files · +48 −0Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/timex.h+41−0
@@ -92,6 +92,47 @@ struct timex { · 91 unmodified lines
92 int :32; int :32; int :32;92 int :32; int :32; int :32;
93};93};
94 94
95struct __kernel_timex_timeval {
96 __kernel_time64_t tv_sec;
97 long long tv_usec;
98};
99
100#ifndef __kernel_timex
101struct __kernel_timex {
102 unsigned int modes; /* mode selector */
103 int :32; /* pad */
104 long long offset; /* time offset (usec) */
105 long long freq; /* frequency offset (scaled ppm) */
106 long long maxerror;/* maximum error (usec) */
107 long long esterror;/* estimated error (usec) */
108 int status; /* clock command/status */
109 int :32; /* pad */
110 long long constant;/* pll time constant */
111 long long precision;/* clock precision (usec) (read only) */
112 long long tolerance;/* clock frequency tolerance (ppm)
113 * (read only)
114 */
115 struct __kernel_timex_timeval time; /* (read only, except for ADJ_SETOFFSET) */
116 long long tick; /* (modified) usecs between clock ticks */
117
118 long long ppsfreq;/* pps frequency (scaled ppm) (ro) */
119 long long jitter; /* pps jitter (us) (ro) */
120 int shift; /* interval duration (s) (shift) (ro) */
121 int :32; /* pad */
122 long long stabil; /* pps stability (scaled ppm) (ro) */
123 long long jitcnt; /* jitter limit exceeded (ro) */
124 long long calcnt; /* calibration intervals (ro) */
125 long long errcnt; /* calibration errors (ro) */
126 long long stbcnt; /* stability limit exceeded (ro) */
127
128 int tai; /* TAI offset (ro) */
129
130 int :32; int :32; int :32; int :32;
131 int :32; int :32; int :32; int :32;
132 int :32; int :32; int :32;
133};
134#endif
135
95/*136/*
96 * Mode codes (timex.mode)137 * Mode codes (timex.mode)
97 */138 */