1 .\" Copyright (c) 1995 Michael Chastain (mec@shell.portal.com), 15 April 1995.
2 .\" and Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 .\" GNU General Public License for more details.
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, see
22 .\" <http://www.gnu.org/licenses/>.
25 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
26 .\" Modified 1997-07-30 by Paul Slootman <paul@wurtel.demon.nl>
27 .\" Modified 2004-05-27 by Michael Kerrisk <mtk.manpages@gmail.com>
29 .TH ADJTIMEX 2 2014-12-31 "Linux" "Linux Programmer's Manual"
31 adjtimex \- tune kernel clock
34 .B #include <sys/timex.h>
36 .BI "int adjtimex(struct timex *" "buf" );
39 Linux uses David L. Mills' clock adjustment algorithm (see RFC\ 5905).
42 reads and optionally sets adjustment parameters for this algorithm.
43 It takes a pointer to a
45 structure, updates kernel parameters from field values,
46 and returns the same structure with current kernel values.
47 This structure is declared as follows:
52 int modes; /* Mode selector */
53 long offset; /* Time offset; nanoseconds, if STA_NANO
54 status flag is set, otherwise microseconds */
55 long freq; /* Frequency offset, in units of 2^-16 ppm
56 (parts per million, see NOTES below) */
57 long maxerror; /* Maximum error (microseconds) */
58 long esterror; /* Estimated error (microseconds) */
59 int status; /* Clock command/status */
60 long constant; /* PLL (phase-locked loop) time constant */
61 long precision; /* Clock precision (microseconds, read-only) */
62 long tolerance; /* Clock frequency tolerance (ppm, read-only) */
64 /* Current time (read-only, except for
65 ADJ_SETOFFSET); upon return, time.tv_usec
66 contains nanoseconds, if STA_NANO status
67 flag is set, otherwise microseconds */
68 long tick; /* Microseconds between clock ticks */
69 long ppsfreq; /* PPS (pulse per second) frequency (in units
70 of 2^-16 ppm\-\-see NOTES, read-only) */
71 long jitter; /* PPS jitter (read-only); nanoseconds, if
72 STA_NANO status flag is set, otherwise
74 int shift; /* PPS interval duration (seconds, read-only) */
75 long stabil; /* PPS stability (2^-16 ppm\-\-see NOTES,
77 long jitcnt; /* PPS jitter limit exceeded (read-only) */
78 long calcnt; /* PPS calibration intervals (read-only) */
79 long errcnt; /* PPS calibration errors (read-only) */
80 long stbcnt; /* PPS stability limit exceeded (read-only) */
81 int tai; /* TAI offset, as set by previous ADJ_TAI
82 operation (seconds, read-only,
83 since Linux 2.6.26) */
84 /* Further padding bytes to allow for future expansion */
91 field determines which parameters, if any, to set.
92 It is a bit mask containing a
94 combination of zero or more of the following bits:
101 Set frequency offset from
105 Set maximum time error from
109 Set estimated time error from
113 Set clock status from
117 Set PLL time constant from
121 status flag (see below) is clear, the kernel adds 4 to this value.
123 .BR ADJ_SETOFFSET " (since Linux 2.6.29)"
124 .\" commit 094aa1881fdc1b8889b442eb3511b31f3ec2b762
125 .\" Author: Richard Cochran <richardcochran@gmail.com>
135 is interpreted as a nanosecond value;
136 otherwise it is interpreted as microseconds.
138 .BR ADJ_MICRO " (since Linux 2.6.36)"
139 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
140 .\" Author: Roman Zippel <zippel@linux-m68k.org>
141 Select microsecond resolution.
143 .BR ADJ_NANO " (since Linux 2.6.36)"
144 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
145 .\" Author: Roman Zippel <zippel@linux-m68k.org>
146 Select nanosecond resolution.
153 .BR ADJ_TAI " (since Linux 2.6.26)"
154 .\" commit 153b5d054ac2d98ea0d86504884326b6777f683d
155 Set TAI (Atomic International Time) offset from
159 should not be used in conjunction with
161 since the latter mode also employs the
165 For a complete explanation of TAI
166 and the difference between TAI and UTC, see
167 .UR http://www.bipm.org/en/bipm/tai/tai.html
177 can be specified as either of the following (multibit mask) values,
178 in which case other bits should not be specified in
180 .\" In general, the other bits are ignored, but ADJ_OFFSET_SINGLESHOT 0x8001
181 .\" ORed with ADJ_NANO (0x2000) gives 0xa0001 == ADJ_OFFSET_SS_READ!!
183 .BR ADJ_OFFSET_SINGLESHOT
184 .\" In user space, ADJ_OFFSET_SINGLESHOT is 0x8001
185 .\" In kernel space it is 0x0001, and must be ANDed with ADJ_ADJTIME (0x8000)
188 (gradually) adjust time by value specified in
190 which specifies an adjustment in microseconds.
192 .BR ADJ_OFFSET_SS_READ " (functional since Linux 2.6.28)"
193 .\" In user space, ADJ_OFFSET_SS_READ is 0xa001
194 .\" In kernel space there is ADJ_OFFSET_READONLY (0x2000) anded with
195 .\" ADJ_ADJTIME (0x8000) and ADJ_OFFSET_SINGLESHOT (0x0001) to give 0xa001)
198 the remaining amount of time to be adjusted after an earlier
199 .BR ADJ_OFFSET_SINGLESHOT
201 This feature was added in Linux 2.6.24,
202 .\" commit 52bfb36050c8529d9031d2c2513b281a360922ec
203 but did not work correctly
204 .\" commit 916c7a855174e3b53d182b97a26b2e27a29726a1
207 Ordinary users are restricted to a value of either 0 or
208 .B ADJ_OFFSET_SS_READ
211 Only the superuser may set any parameters.
215 field is a bit mask that is used to set and/or retrieve status
216 bits associated with the NTP implementation.
217 Some bits in the mask are both readable and settable,
218 while others are read-only.
221 Enable phase-locked loop (PLL) updates (read-write) via
222 .\" FIXME Any pointer to further information about what this means?
223 .\" (It was not immediately obvious from a scan of the RFC, whether
224 .\" this is described in the RFC.)
228 Enable PPS freq discipline (read-write).
229 .\" FIXME Any pointer to further information about what this means?
230 .\" (It was not immediately obvious from a scan of the RFC, whether
231 .\" this is described in the RFC.)
234 Enable PPS time discipline (read-write).
235 .\" FIXME Any pointer to further information about what this means?
236 .\" (It was not immediately obvious from a scan of the RFC, whether
237 .\" this is described in the RFC.)
240 Select frequency-locked loop (FLL) mode (read-write).
241 .\" FIXME Any pointer to further information about what this means?
242 .\" (It was not immediately obvious from a scan of the RFC, whether
243 .\" this is described in the RFC.)
246 Insert leap second (read-write).
247 .\" FIXME Is the following correct?
248 .\" Insert a leap second after the last second of the day.
249 .\" That is, at 24:00:00, set the clock 1 second back, thus extending
250 .\" the last minute of the day by one second.
251 .\" Leap second insertion will occur each day, so long as this flag
255 Delete leap second (read-write).
256 .\" FIXME Is the following correct?
257 .\" Delete a leap second at the last second of the leap day.
258 .\" That is, at 23:5:59, add one extra second to the clock.
259 .\" Leap second deletion will occur each day, so long as this flag
261 .\" FIXME Does there need to be a statement that it is nonsensical to set
262 .\" to set both STA_INS and STA_DEL?
265 Clock unsynchronized (read-write).
268 Hold frequency (read-write).
269 .\" FIXME Any pointer to further information about what this means?
270 .\" (It was not immediately obvious from a scan of the RFC, whether
271 .\" this is described in the RFC.)
274 PPS signal present (read-only).
275 .\" FIXME Any pointer to further information about what this means?
276 .\" (It was not immediately obvious from a scan of the RFC, whether
277 .\" this is described in the RFC.)
280 PPS signal jitter exceeded (read-only).
281 .\" FIXME Any pointer to further information about what this means?
282 .\" (It was not immediately obvious from a scan of the RFC, whether
283 .\" this is described in the RFC.)
286 PPS signal wander exceeded (read-only).
287 .\" FIXME Any pointer to further information about what this means?
288 .\" (It was not immediately obvious from a scan of the RFC, whether
289 .\" this is described in the RFC.)
292 PPS signal calibration error (read-only).
293 .\" FIXME Any pointer to further information about what this means?
294 .\" (It was not immediately obvious from a scan of the RFC, whether
295 .\" this is described in the RFC.)
298 Clock hardware fault (read-only).
299 .\" FIXME Any pointer to further information about what this means?
300 .\" (It was not immediately obvious from a scan of the RFC, whether
301 .\" this is described in the RFC.)
303 .BR STA_NANO " (since Linux 2.6.26)"
304 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
305 .\" Author: Roman Zippel <zippel@linux-m68k.org>
306 Resolution (0 = microsecond, 1 = nanoseconds; read-only).
312 .BR STA_MODE " (since Linux 2.6.26)"
313 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
314 .\" Author: Roman Zippel <zippel@linux-m68k.org>
315 Mode (0 = Phase Locked Loop, 1 = Frequency Locked Loop; read-only).
317 .BR STA_CLK " (since Linux 2.6.26)"
318 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
319 .\" Author: Roman Zippel <zippel@linux-m68k.org>
320 Clock source (0 = A, 1 = B; read-only).
321 .\" FIXME It would be helpful to have some explanation of what
322 .\" "Clock source" is.
324 Attempts to set read-only
326 bits are silently ignored.
330 returns the clock state; that is, one of the following values:
337 .\" FIXME Is the following correct:
338 .\" Indicates that a leap second will be added at the end of the day
342 .\" FIXME Is the following correct:
343 .\" Indicates that a leap second will be deleted at the end of the day
346 Leap second in progress.
347 .\" FIXME Is the following correct:
348 .\" Indicates that we are currently in the middle of the leap second
349 .\" that is being added at the end of the day (as a result of STA_INS)
352 Leap second has occurred.
353 .\" FIXME Is the following correct:
354 .\" Indicates that a leap second has just been added or deleted
355 .\" during the previous second
358 Clock not synchronized.
359 .\" FIXME Should more be said about how the TIME_ERROR state can occur?
364 provided for backward compatibility.
365 Note that starting with Linux 3.4,
366 .\" commit 6b43ae8a619d17c4935c3320d2ef9e92bdeed05d changed to asynchronous
367 .\" operation, so we can no longer rely on the return code.
368 the call operates asynchronously and the return value usually will
369 not reflect a state change caused by the call itself.
379 does not point to writable memory.
381 .BR EINVAL " (kernels before Linux 2.6.26)"
382 An attempt was made to set
384 to a value outside the permitted range.
385 In kernels before Linux 2.0, the permitted range was (\-131072, +131072).
386 From Linux 2.0 onwards, the permitted range was (\-512000, +512000).
389 An attempt was made to set
391 to a value other than those listed above.
394 An attempt was made to set
396 to a value outside the range
402 is the system timer interrupt frequency.
407 .BR ADJ_OFFSET_SS_READ ,
408 and the caller does not have sufficient privilege.
411 capability is required.
419 are ppm (parts per million) with a 16-bit fractional part,
420 which means that a value of 1 in one of those fields
421 actually means 2^-16 ppm, and 2^16=65536 is 1 ppm.
422 This is the case for both input values (in the case of
427 is Linux-specific and should not be used in programs
428 intended to be portable.
431 for a more portable, but less flexible,
432 method of adjusting the system clock.
434 .BR settimeofday (2),
436 .BR capabilities (7),