Qp0zAdjTime()--Adjust Software Clock


  Syntax
 #include <sys/time.h>

 int Qp0zAdjTime (struct timeval *delta,
                  struct timeval *olddelta);

  Service Program Name: QP0ZSETC

  Default Public Authority: *USE

  Threadsafe: Yes

The Qp0zAdjTime() function makes small adjustments to the software clock, either slowing it down or speeding it up by the time specified in the delta parameter. 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, the clock is sped up by incrementing it more quickly than normal until the correction is complete. If olddelta is not NULL, the amount of time still to be corrected from a previous Qp0zAdjTime() call is returned in the structure it points to.

The software clock maintains a time that can be set independently of the system clock. It is not integrated with the system and will be removed in a future release. The adjtime() function should be used instead.


Parameters

delta
(Input) A pointer to a timeval structure that contains the amount of time for adjusting the software clock.

olddelta
(Output) A pointer to a timeval structure that contains the amount of time still to be corrected from a previous call to Qp0zAdjTime()

Authorities and Locks

QSYS/QP0ZXCPA Service Program Authority
*USE

Return Value



Error Conditions

If Qp0zAdjTime() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.



Error Messages

None.


Usage Notes

If the value of the environment variable QIBM_USE_SFWCLK is "N", Qp0zAdjTime() calls adjtime() to adjust the system clock.


Related Information


Example

The following example initiates a software clock adjustment.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

#include <sys/time.h>
#include <stdio.h>
#include <errno.h>

int main(int argc, char *argv[])
{
    struct timeval adj, old;
    int rc;

    /* Speed up the software clock by 1.5 seconds. */
    adj.tv_sec=1;
    adj.tv_usec=500000;

    rc=Qp0zAdjTime(&adj, &old);
    if(rc==0) {
        printf("Qp0zAdjTime() successful. "
               "Olddelta = %u.%06u\n",
                old.tv_sec, old.tv_usec);
    }
    else {
        printf("Qp0zAdjTime() failed, errno = %d\n",errno);
        return -1;
    }

    return 0;
}

Example Output:

Qp0zAdjTime() successful. Olddelta = 0.000000


API introduced: V5R3

[ Back to top | UNIX-Type APIs | APIs by category ]