date and time created 91/04/12 13:40:31 by bostic
[unix-history] / usr / src / lib / libc / sys / adjtime.2
CommitLineData
931b8415 1.\" Copyright (c) 1980, 1991 Regents of the University of California.
d4a07fef 2.\" All rights reserved.
ab34755c 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
d4a07fef 5.\"
931b8415 6.\" @(#)adjtime.2 1.7 (Berkeley) %G%
ab34755c 7.\"
931b8415
CL
8.Dd
9.Dt ADJTIME 2
10.Os BSD 4.3
11.Sh NAME
12.Nm adjtime
13.Nd "correct the time to allow synchronization of the system clock"
14.Sh SYNOPSIS
15.Fd #include <sys/time.h>
16.Ft int
17.Fn adjtime "struct timeval *delta" "struct timeval *olddelta"
18.Sh DESCRIPTION
19.Fn Adjtime
9d26ec35 20makes small adjustments to the system time, as returned by
931b8415 21.Xr gettimeofday 2 ,
9d26ec35 22advancing or retarding it
09cfce6f 23by the time specified by the timeval
931b8415
CL
24.Fa delta .
25If
26.Fa delta
27is negative, the clock is
9d26ec35
MK
28slowed down by incrementing it more slowly than normal until
29the correction is complete.
931b8415
CL
30If
31.Fa delta
32is positive, a larger increment than normal
ab34755c 33is used.
9d26ec35 34The skew used to perform the correction is generally a fraction of one percent.
ab34755c
RG
35Thus, the time is always
36a monotonically increasing function.
931b8415
CL
37A time correction from an earlier call to
38.Fn adjtime
39may not be finished when
40.Fn adjtime
41is called again.
42If
43.Fa olddelta
44is non-nil,
45the structure pointed to will contain, upon return, the
ab34755c
RG
46number of microseconds still to be corrected
47from the earlier call.
931b8415 48.Pp
9d26ec35 49This call may be used by time servers that synchronize the clocks
ab34755c
RG
50of computers in a local area network.
51Such time servers would slow down the clocks of some machines
52and speed up the clocks of others to bring them to the average network time.
931b8415 53.Pp
ab34755c 54The call
931b8415 55.Fn adjtime
ab34755c 56is restricted to the super-user.
931b8415 57.Sh RETURN VALUES
ab34755c 58A return value of 0 indicates that the call succeeded.
931b8415
CL
59A return value of -1 indicates that an error occurred, and in this
60case an error code is stored in the global variable
61.Va errno .
62.Sh ERRORS
63.Fn Adjtime
64will fail if:
65.Bl -tag -width Er
66.It Bq Er EFAULT
ab34755c 67An argument points outside the process's allocated address space.
931b8415 68.It Bq Er EPERM
ab34755c 69The process's effective user ID is not that of the super-user.
931b8415
CL
70.El
71.Sh SEE ALSO
72.Xr date 1 ,
73.Xr gettimeofday 2 ,
74.Xr timed 8 ,
75.Xr timedc 8 ,
76.Rs
77.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
78.%A R. Gusella
79.%A S. Zatti
80.Re
81.Sh HISTORY
82The
83.Nm
84function call appeared in
85.Bx 4.3 .