xref: /freebsd/lib/libsys/adjtime.2 (revision d15f2551b25f79ddcbe289faa95e655100b952da)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd June 19, 2026
29.Dt ADJTIME 2
30.Os
31.Sh NAME
32.Nm adjtime
33.Nd "correct the time to allow synchronization of the system clock"
34.Sh LIBRARY
35.Lb libc
36.Sh SYNOPSIS
37.In sys/time.h
38.Ft int
39.Fn adjtime "const struct timeval *delta" "struct timeval *olddelta"
40.Sh DESCRIPTION
41The
42.Fn adjtime
43system call
44makes small adjustments to the system time, as returned by
45.Xr gettimeofday 2 ,
46advancing or retarding it
47by the time specified by the timeval
48.Fa delta .
49.Pp
50If
51.Fa delta
52is negative, the clock is
53slowed down by incrementing it more slowly than normal until
54the correction is complete.
55If
56.Fa delta
57is positive, a larger increment than normal
58is used.
59.Fa delta
60may also be a
61.Dv NULL
62pointer to fetch
63.Fa olddelta
64without making any adjustment.
65.Pp
66The skew used to perform the correction is generally a fraction of one percent.
67Thus, the time is always
68a monotonically increasing function.
69A time correction from an earlier call to
70.Fn adjtime
71may not be finished when
72.Fn adjtime
73is called again.
74If
75.Fa olddelta
76is not a
77.Dv NULL
78pointer,
79the structure pointed to will contain, upon return, the
80number of microseconds still to be corrected
81from the earlier call.
82.Pp
83This call may be used by time servers that synchronize the clocks
84of computers in a local area network.
85Such time servers would slow down the clocks of some machines
86and speed up the clocks of others to bring them to the average network time.
87.Pp
88The
89.Fn adjtime
90system call
91is restricted to the super-user.
92.Sh RETURN VALUES
93.Rv -std adjtime
94.Sh ERRORS
95The
96.Fn adjtime
97system call will fail if:
98.Bl -tag -width Er
99.It Bq Er EFAULT
100An argument points outside the process's allocated address space.
101.It Bq Er EPERM
102The process's effective user ID is not that of the super-user.
103.El
104.Sh SEE ALSO
105.Xr date 1 ,
106.Xr gettimeofday 2
107.Rs
108.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
109.%A R. Gusella
110.%A S. Zatti
111.Re
112.Sh HISTORY
113The
114.Fn adjtime
115system call appeared in
116.Bx 4.3 .
117