1*61181Sbostic.\" Copyright (c) 1980, 1991, 1993 2*61181Sbostic.\" The Regents of the University of California. All rights reserved. 323750Sgusella.\" 443568Strent.\" %sccs.include.redist.man% 523750Sgusella.\" 6*61181Sbostic.\" @(#)adjtime.2 8.1 (Berkeley) 06/04/93 733125Sbostic.\" 847208Scael.Dd 947208Scael.Dt ADJTIME 2 1047208Scael.Os BSD 4.3 1147208Scael.Sh NAME 1247208Scael.Nm adjtime 1347208Scael.Nd "correct the time to allow synchronization of the system clock" 1447208Scael.Sh SYNOPSIS 1547208Scael.Fd #include <sys/time.h> 1647208Scael.Ft int 1747208Scael.Fn adjtime "struct timeval *delta" "struct timeval *olddelta" 1847208Scael.Sh DESCRIPTION 1947208Scael.Fn Adjtime 2028108Skarelsmakes small adjustments to the system time, as returned by 2147208Scael.Xr gettimeofday 2 , 2228108Skarelsadvancing or retarding it 2328224Sanneby the time specified by the timeval 2447208Scael.Fa delta . 2547208ScaelIf 2647208Scael.Fa delta 2747208Scaelis negative, the clock is 2828108Skarelsslowed down by incrementing it more slowly than normal until 2928108Skarelsthe correction is complete. 3047208ScaelIf 3147208Scael.Fa delta 3247208Scaelis positive, a larger increment than normal 3323750Sgusellais used. 3428108SkarelsThe skew used to perform the correction is generally a fraction of one percent. 3523750SgusellaThus, the time is always 3623750Sgusellaa monotonically increasing function. 3747208ScaelA time correction from an earlier call to 3847208Scael.Fn adjtime 3947208Scaelmay not be finished when 4047208Scael.Fn adjtime 4147208Scaelis called again. 4247208ScaelIf 4347208Scael.Fa olddelta 4447208Scaelis non-nil, 4547208Scaelthe structure pointed to will contain, upon return, the 4623750Sgusellanumber of microseconds still to be corrected 4723750Sgusellafrom the earlier call. 4847208Scael.Pp 4928108SkarelsThis call may be used by time servers that synchronize the clocks 5023750Sgusellaof computers in a local area network. 5123750SgusellaSuch time servers would slow down the clocks of some machines 5223750Sgusellaand speed up the clocks of others to bring them to the average network time. 5347208Scael.Pp 5423750SgusellaThe call 5547208Scael.Fn adjtime 5623750Sgusellais restricted to the super-user. 5747208Scael.Sh RETURN VALUES 5823750SgusellaA return value of 0 indicates that the call succeeded. 5947208ScaelA return value of -1 indicates that an error occurred, and in this 6047208Scaelcase an error code is stored in the global variable 6147208Scael.Va errno . 6247208Scael.Sh ERRORS 6347208Scael.Fn Adjtime 6447208Scaelwill fail if: 6547208Scael.Bl -tag -width Er 6647208Scael.It Bq Er EFAULT 6723750SgusellaAn argument points outside the process's allocated address space. 6847208Scael.It Bq Er EPERM 6923750SgusellaThe process's effective user ID is not that of the super-user. 7047208Scael.El 7147208Scael.Sh SEE ALSO 7247208Scael.Xr date 1 , 7347208Scael.Xr gettimeofday 2 , 7447208Scael.Xr timed 8 , 7547208Scael.Xr timedc 8 , 7647208Scael.Rs 7747208Scael.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD" 7847208Scael.%A R. Gusella 7947208Scael.%A S. Zatti 8047208Scael.Re 8147208Scael.Sh HISTORY 8247208ScaelThe 8347208Scael.Nm 8447208Scaelfunction call appeared in 8547208Scael.Bx 4.3 . 86