xref: /openbsd/lib/libc/sys/adjtime.2 (revision 133306f0)
1.\"	$OpenBSD: adjtime.2,v 1.10 2000/10/18 05:12:08 aaron 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. All advertising materials mentioning features or use of this software
16.\"    must display the following acknowledgement:
17.\"	This product includes software developed by the University of
18.\"	California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\"    may be used to endorse or promote products derived from this software
21.\"    without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\"     @(#)adjtime.2	8.1 (Berkeley) 6/4/93
36.\"
37.Dd June 4, 1993
38.Dt ADJTIME 2
39.Os
40.Sh NAME
41.Nm adjtime
42.Nd "correct the time to allow synchronization of the system clock"
43.Sh SYNOPSIS
44.Fd #include <sys/time.h>
45.Ft int
46.Fn adjtime "const struct timeval *delta" "struct timeval *olddelta"
47.Sh DESCRIPTION
48.Fn adjtime
49makes small adjustments to the system time, as returned by
50.Xr gettimeofday 2 ,
51advancing or retarding it by the time specified by the timeval
52.Fa delta .
53If
54.Fa delta
55is negative, the clock is slowed down by incrementing it more slowly
56than normal until the correction is complete.
57If
58.Fa delta
59is positive, a larger increment than normal is used.
60The skew used to perform the correction is generally a fraction of one percent.
61Thus, the time is always a monotonically increasing function.
62A time correction from an earlier call to
63.Fn adjtime
64may not be finished when
65.Fn adjtime
66is called again.
67If
68.Fa olddelta
69is non-null, the structure pointed to will contain, upon return, the
70number of microseconds still to be corrected from the earlier call.
71.Pp
72This call may be used by time servers that synchronize the clocks
73of computers in a local area network.
74Such time servers would slow down the clocks of some machines
75and speed up the clocks of others to bring them to the average network time.
76.Pp
77The call
78.Fn adjtime
79is restricted to the superuser.
80.Sh RETURN VALUES
81A return value of 0 indicates that the call succeeded.
82A return value of \-1 indicates that an error occurred, and in this
83case an error code is stored in the global variable
84.Va errno .
85.Sh ERRORS
86.Fn adjtime
87will fail if:
88.Bl -tag -width Er
89.It Bq Er EFAULT
90Either of the arguments point outside the process's allocated address space.
91.It Bq Er EPERM
92The process's effective user ID is not that of the superuser.
93.El
94.Sh SEE ALSO
95.Xr date 1 ,
96.Xr gettimeofday 2 ,
97.Xr timed 8 ,
98.Xr timedc 8
99.Rs
100.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
101.%A R. Gusella
102.%A S. Zatti
103.Re
104.Sh HISTORY
105The
106.Fn adjtime
107function call appeared in
108.Bx 4.3 .
109