INtime SDK Help

Corrects the time to allow synchronization of the system clock with an external reference.

#include <sys/time.h>

int adjtime(
const struct timeval *delta,
struct timeval *olddelta
); int _adjtime32( const struct _timeval32 *delta, struct _timeval32 *olddelta ); int _adjtime64( const struct _timeval64 *delta, struct _timeval64 *olddelta );


The adjtime() system call makes small adjustments to the system time, as returned by gettimeofday(), advancing or retarding it by the time specified by the timeval delta. If delta is negative, the clock is slowed down by incrementing it more slowly than normal until the correction is complete. If delta is positive, a larger increment than normal is used. The skew used to perform the correction is generally a fraction of one percent. Thus, the time is always a monotonically increasing function. A time correction from an earlier call to adjtime() may not be finished when adjtime() is called again. If olddelta is not a null pointer, the structure pointed to will contain, upon return, the number of microseconds still to be corrected from the earlier call.

This call may be used by time servers that synchronize the clocks of computers in a local area network. Such time servers would slow down the clocks of some machines and speed up the clocks of others to bring them to the average network time.

The _adjtime32 call uses the _timeval32 structure and the _adjtime64 call uses the _timeval64 structure (see gettimeofday for details).

If the macro _USE_32BIT_TIMEVAL is defined, adjtime will actually call _adjtime32.

If the macro _USE_64BIT_TIMEVAL is defined, adjtime will actually call _adjtime64.

If neither macro is defined the original call is made.


Note: this call does not make any adjustment to the system timer hardware, but only modifies the system counter used to record the time of day.


The adjtime() system call appeared in 4.3BSD.

Return Values

0 (zero)
Failure, and the global variable errno is set to indicate the error.


An argument points outside the process's allocated address space.


Versions Defined in Include Link to
INtime 4.0 intime/rt/include/sys/time.h sys/time.h clib.lib
INtime 6.0 (32- and 64-bit versions) intime/rt/include/sys/time.h sys/time.h clib.lib
See Also