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