1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1995 Michael Chastain (mec@shell.portal.com), 15 April 1995.
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, write to the Free
22 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
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 2004-05-27 "Linux" "Linux Programmer's Manual"
31 adjtimex \- tune kernel clock
33 .B #include <sys/timex.h>
35 .BI "int adjtimex(struct timex *" "buf" );
37 Linux uses David L. Mills' clock adjustment algorithm (see RFC\ 1305).
40 reads and optionally sets adjustment parameters for this algorithm.
41 It takes a pointer to a
43 structure, updates kernel parameters from field values,
44 and returns the same structure with current kernel values.
45 This structure is declared as follows:
50 int modes; /* mode selector */
51 long offset; /* time offset (usec) */
52 long freq; /* frequency offset (scaled ppm) */
53 .\" FIXME -- what is the scaling unit? 2^16 ?
54 long maxerror; /* maximum error (usec) */
55 long esterror; /* estimated error (usec) */
56 int status; /* clock command/status */
57 long constant; /* pll time constant */
58 long precision; /* clock precision (usec) (read-only) */
59 long tolerance; /* clock frequency tolerance (ppm)
61 struct timeval time; /* current time (read-only) */
62 long tick; /* usecs between clock ticks */
69 field determines which parameters, if any, to set.
72 combination of zero or more of the following bits:
76 #define ADJ_OFFSET 0x0001 /* time offset */
77 #define ADJ_FREQUENCY 0x0002 /* frequency offset */
78 #define ADJ_MAXERROR 0x0004 /* maximum time error */
79 #define ADJ_ESTERROR 0x0008 /* estimated time error */
80 #define ADJ_STATUS 0x0010 /* clock status */
81 #define ADJ_TIMECONST 0x0020 /* pll time constant */
82 #define ADJ_TICK 0x4000 /* tick value */
83 #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime() */
87 Ordinary users are restricted to a zero value for
89 Only the superuser may set any parameters.
95 returns the clock state:
99 #define TIME_OK 0 /* clock synchronized */
100 #define TIME_INS 1 /* insert leap second */
101 #define TIME_DEL 2 /* delete leap second */
102 #define TIME_OOP 3 /* leap second in progress */
103 #define TIME_WAIT 4 /* leap second has occurred */
104 #define TIME_BAD 5 /* clock not synchronized */
116 does not point to writable memory.
119 An attempt is made to set
121 to a value outside the range \-131071 to +131071,
124 to a value other than those listed above,
127 to a value outside the range
133 is the system timer interrupt frequency.
137 is nonzero and the caller does not have sufficient privilege.
140 capability is required.
143 is Linux-specific and should not be used in programs
144 intended to be portable.
147 for a more portable, but less flexible,
148 method of adjusting the system clock.
150 .BR settimeofday (2),
152 .BR capabilities (7),