Name

adjtime - correct the time to allow synchronization of the system clock

Library

libc.lib

Synopsis

  #include <sys/time.h>
  int adjtime (const struct timeval *delta, struct timeval *olddelta);

Return values

A successful call will return 0 while a failure will return -1

Detailed description

The adjtime system call makes small adjustments to the system time, as returned by gettimeofday advancing it by the time specified by the timeval delta. If delta is negative, the clock is still incremented by the positive of delta until the correction is complete. 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.In case of success we always set the values to 0

This call may be used by time servers that synchronize the clock.


Examples

#include <sys/time.h>
#include <stdio.h>
int main()
{
        //Fill the input struct with 100 microseconds
        const struct timeval delta = {0, 100};
        struct timeval  olddelta;
        int retval;
        retval = adjtime (δ, &olddelta); //Call adjtime
        printf("adjtime returned %d",retval);
        return 0;
}

         

Output

adjtime returned 0

         

Errors

The adjtime system call will fail if:
[EFAULT]
  The *delta or *olddelta argument was an invalid address

See also

gettimeofday

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top