]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/adjtimex.2
adjtimex.2: Change 'PPM' (parts per million) to 'ppm'
[thirdparty/man-pages.git] / man2 / adjtimex.2
1 .\" Copyright (c) 1995 Michael Chastain (mec@shell.portal.com), 15 April 1995.
2 .\" and Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
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.
9 .\"
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.
14 .\"
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.
19 .\"
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/>.
23 .\" %%%LICENSE_END
24 .\"
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>
28 .\"
29 .TH ADJTIMEX 2 2014-12-31 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 adjtimex \- tune kernel clock
32 .SH SYNOPSIS
33 .nf
34 .BR "#define _BSD_SOURCE" " /* See feature_test_macros(7) */"
35 .B #include <sys/timex.h>
36
37 .BI "int adjtimex(struct timex *" "buf" );
38 .fi
39 .SH DESCRIPTION
40 Linux uses David L. Mills' clock adjustment algorithm (see RFC\ 5905).
41 The system call
42 .BR adjtimex ()
43 reads and optionally sets adjustment parameters for this algorithm.
44 It takes a pointer to a
45 .I timex
46 structure, updates kernel parameters from field values,
47 and returns the same structure with current kernel values.
48 This structure is declared as follows:
49 .PP
50 .in +4n
51 .nf
52 struct timex {
53 int modes; /* Mode selector */
54 long offset; /* Time offset; nanoseconds, if STA_NANO
55 status flag is set, otherwise
56 microseconds */
57 long freq; /* Frequency offset, in units of 2^-16 ppm
58 (parts per million) (see NOTES below) */
59 long maxerror; /* Maximum error (microseconds) */
60 long esterror; /* Estimated error (microseconds) */
61 int status; /* Clock command/status */
62 long constant; /* PLL (phase-locked loop) time constant */
63 long precision; /* Clock precision (microseconds,
64 read-only) */
65 long tolerance; /* Clock frequency tolerance (ppm, read-only) */
66 struct timeval time;
67 /* Current time (read-only, except for
68 ADJ_SETOFFSET); upon return, time.tv_usec
69 contains nanoseconds, if STA_NANO status
70 flag is set, otherwise microseconds */
71 long tick; /* Microseconds between clock ticks */
72 long ppsfreq; /* PPS (pulse per second) frequency
73 (2^-16 ppm (see NOTES), read-only) */
74 long jitter; /* PPS jitter (read-only); nanoseconds, if
75 STA_NANO status flag is set, otherwise
76 microseconds */
77 int shift; /* PPS interval duration
78 (seconds, read-only) */
79 long stabil; /* PPS stability (2^-16 ppm (see NOTES), read-only) */
80 long jitcnt; /* PPS jitter limit exceeded (read-only) */
81 long calcnt; /* PPS calibration intervals (read-only) */
82 long errcnt; /* PPS calibration errors (read-only) */
83 long stbcnt; /* PPS stability limit exceeded
84 (read-only) */
85 int tai; /* TAI offset, as set by previous ADJ_TAI
86 operation (seconds, read-only,
87 since Linux 2.6.26) */
88 /* Further padding bytes to allow for future expansion */
89 };
90 .fi
91 .in
92 .PP
93 The
94 .I modes
95 field determines which parameters, if any, to set.
96 It is a bit mask containing a
97 .RI bitwise- or
98 combination of zero or more of the following bits:
99 .TP
100 .BR ADJ_OFFSET
101 Set time offset from
102 .IR buf.offset .
103 .TP
104 .BR ADJ_FREQUENCY
105 Set frequency offset from
106 .IR buf.freq .
107 .TP
108 .BR ADJ_MAXERROR
109 Set maximum time error from
110 .IR buf.maxerror .
111 .TP
112 .BR ADJ_ESTERROR
113 Set estimated time error from
114 .IR buf.esterror .
115 .TP
116 .BR ADJ_STATUS
117 Set clock status from
118 .IR buf.status .
119 .TP
120 .BR ADJ_TIMECONST
121 Set PLL time constant from
122 .IR buf.constant .
123 If the
124 .B STA_NANO
125 status flag (see below) is clear, the kernel adds 4 to this value.
126 .TP
127 .BR ADJ_SETOFFSET " (since Linux 2.6.29)"
128 .\" commit 094aa1881fdc1b8889b442eb3511b31f3ec2b762
129 .\" Author: Richard Cochran <richardcochran@gmail.com>
130 Add
131 .I buf.time
132 to the current time.
133 If
134 .I buf.status
135 includes the
136 .B ADJ_NANO
137 flag, then
138 .I buf.time.tv_usec
139 is interpreted as a nanosecond value;
140 otherwise it is interpreted as microseconds.
141 .TP
142 .BR ADJ_MICRO " (since Linux 2.6.36)"
143 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
144 .\" Author: Roman Zippel <zippel@linux-m68k.org>
145 Select microsecond resolution.
146 .TP
147 .BR ADJ_NANO " (since Linux 2.6.36)"
148 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
149 .\" Author: Roman Zippel <zippel@linux-m68k.org>
150 Select nanosecond resolution.
151 Only one of
152 .BR ADJ_MICRO
153 and
154 .BR ADJ_NANO
155 should be specified.
156 .TP
157 .BR ADJ_TAI " (since Linux 2.6.26)"
158 .\" commit 153b5d054ac2d98ea0d86504884326b6777f683d
159 Set TAI (Atomic International Time) offset from
160 .IR buf->constant .
161
162 .BR ADJ_TAI
163 should not be used in conjunction with
164 .BR ADJ_TIMECONST ,
165 since the latter mode also employs the
166 .IR buf->constant
167 field.
168
169 For a complete explanation of TAI
170 and the difference between TAI and UTC, see
171 .UR http://www.bipm.org/en/bipm/tai/tai.html
172 .I BIPM
173 .UE
174 .TP
175 .BR ADJ_TICK
176 Set tick value from
177 .IR buf.tick .
178 .PP
179 Alternatively,
180 .I modes
181 can be specified as either of the following (multibit mask) values,
182 in which case other bits should not be specified in
183 .IR modes :
184 .\" In general, the other bits are ignored, but ADJ_OFFSET_SINGLESHOT 0x8001
185 .\" ORed with ADJ_NANO (0x2000) gives 0xa0001 == ADJ_OFFSET_SS_READ!!
186 .TP
187 .BR ADJ_OFFSET_SINGLESHOT
188 .\" In user space, ADJ_OFFSET_SINGLESHOT is 0x8001
189 .\" In kernel space it is 0x0001, and must be ANDed with ADJ_ADJTIME (0x8000)
190 Old-fashioned
191 .BR adjtime ():
192 (gradually) adjust time by value specified in
193 .IR buf.offset ,
194 which specifies an adjustment in microseconds.
195 .TP
196 .BR ADJ_OFFSET_SS_READ " (functional since Linux 2.6.28)"
197 .\" In user space, ADJ_OFFSET_SS_READ is 0xa001
198 .\" In kernel space there is ADJ_OFFSET_READONLY (0x2000) anded with
199 .\" ADJ_ADJTIME (0x8000) and ADJ_OFFSET_SINGLESHOT (0x0001) to give 0xa001)
200 Return (in
201 .BR buf.offset )
202 the remaining amount of time to be adjusted after an earlier
203 .BR ADJ_OFFSET_SINGLESHOT
204 operation.
205 This feature was added in Linux 2.6.24,
206 .\" commit 52bfb36050c8529d9031d2c2513b281a360922ec
207 but did not work correctly
208 .\" commit 916c7a855174e3b53d182b97a26b2e27a29726a1
209 until Linux 2.6.28.
210 .PP
211 Ordinary users are restricted to a value of either 0 or
212 .B ADJ_OFFSET_SS_READ
213 for
214 .IR modes .
215 Only the superuser may set any parameters.
216
217 The
218 .I buf.status
219 field is a bit mask that is used to set and/or retrieve status
220 bits associated with the NTP implementation.
221 Some bits in the mask are both readable and settable,
222 while others are read-only.
223 .TP
224 .BR STA_PLL
225 Enable phase-locked loop (PLL) updates (read-write) via
226 .BR ADJ_OFFSET .
227 .TP
228 .BR STA_PPSFREQ
229 Enable PPS freq discipline (read-write).
230 .TP
231 .BR STA_PPSTIME
232 Enable PPS time discipline (read-write).
233 .TP
234 .BR STA_FLL
235 Select frequency-locked loop (FLL) mode (read-write).
236 .TP
237 .BR STA_INS
238 Insert leap second (read-write).
239 .TP
240 .BR STA_DEL
241 Delete leap second (read-write).
242 .TP
243 .BR STA_UNSYNC
244 Clock unsynchronized (read-write).
245 .TP
246 .BR STA_FREQHOLD
247 Hold frequency (read-write).
248 .TP
249 .BR STA_PPSSIGNAL
250 PPS signal present (read-only).
251 .TP
252 .BR STA_PPSJITTER
253 PPS signal jitter exceeded (read-only).
254 .TP
255 .BR STA_PPSWANDER
256 PPS signal wander exceeded (read-only).
257 .TP
258 .BR STA_PPSERROR
259 PPS signal calibration error (read-only).
260 .TP
261 .BR STA_CLOCKERR
262 Clock hardware fault (read-only).
263 .TP
264 .BR STA_NANO " (since Linux 2.6.26)"
265 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
266 .\" Author: Roman Zippel <zippel@linux-m68k.org>
267 Resolution (0 = microsecond, 1 = nanoseconds; read-only).
268 Set via
269 .BR ADJ_NANO ,
270 cleared via
271 .BR ADJ_MICRO .
272 .TP
273 .BR STA_MODE " (since Linux 2.6.26)"
274 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
275 .\" Author: Roman Zippel <zippel@linux-m68k.org>
276 Mode (0 = Phase Locked Loop, 1 = Frequency Locked Loop; read-only).
277 .TP
278 .BR STA_CLK " (since Linux 2.6.26)"
279 .\" commit eea83d896e318bda54be2d2770d2c5d6668d11db
280 .\" Author: Roman Zippel <zippel@linux-m68k.org>
281 Clock source (0 = A, 1 = B; read-only).
282 .PP
283 Attempts to set read-only
284 .I status
285 bits are silently ignored.
286 .SH RETURN VALUE
287 On success,
288 .BR adjtimex ()
289 returns the clock state; that is, one of the following values:
290 .TP 12
291 .BR TIME_OK
292 Clock synchronized.
293 .TP
294 .BR TIME_INS
295 Insert leap second.
296 .TP
297 .BR TIME_DEL
298 Delete leap second.
299 .TP
300 .BR TIME_OOP
301 Leap second in progress.
302 .TP
303 .BR TIME_WAIT
304 Leap second has occurred.
305 .TP
306 .BR TIME_ERROR
307 Clock not synchronized.
308 The symbolic name
309 .B TIME_BAD
310 is a synonym for
311 .BR TIME_ERROR ,
312 provided for backward comaptibility.
313 .PP
314 On failure,
315 .BR adjtimex ()
316 returns \-1 and sets
317 .IR errno .
318 .SH ERRORS
319 .TP
320 .B EFAULT
321 .I buf
322 does not point to writable memory.
323 .TP
324 .B EINVAL
325 An attempt was made to set
326 .I buf.offset
327 to a value outside the range \-131071 to +131071,
328 or to set
329 .I buf.status
330 to a value other than those listed above,
331 or to set
332 .I buf.tick
333 to a value outside the range
334 .RB 900000/ HZ
335 to
336 .RB 1100000/ HZ ,
337 where
338 .B HZ
339 is the system timer interrupt frequency.
340 .TP
341 .B EPERM
342 .I buf.modes
343 is neither 0 nor
344 .BR ADJ_OFFSET_SS_READ ,
345 and the caller does not have sufficient privilege.
346 Under Linux, the
347 .B CAP_SYS_TIME
348 capability is required.
349 .SH NOTES
350 In struct
351 .IR timex ,
352 .IR freq ,
353 .IR ppsfreq ,
354 and
355 .I stabil
356 are ppm (parts per million) with a 16-bits fractional part, which means that a
357 value of 1 in one of those fields actually means 2^-16 ppm, and 2^16=65535 is
358 1 ppm. This is the case for both input values (in the case of
359 .IR freq )
360 and output values.
361 .SH CONFORMING TO
362 .BR adjtimex ()
363 is Linux-specific and should not be used in programs
364 intended to be portable.
365 See
366 .BR adjtime (3)
367 for a more portable, but less flexible,
368 method of adjusting the system clock.
369 .SH SEE ALSO
370 .BR settimeofday (2),
371 .BR adjtime (3),
372 .BR capabilities (7),
373 .BR time (7),
374 .BR adjtimex (8)