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

0 Qp0zAdjTime() was successful. The requested adjustment was initiated and the value returned in the structure pointed to by the olddelta parameter is the amount of time still to be corrected from a previous Qp0zAdjTime().

-1 Qp0zAdjTime() was not successful. The errno variable is set to indicate the error.


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.

[EINVAL] An invalid parameter was found.

A parameter passed to this function is not valid.

[EFAULT] The address used for an argument is not correct.

In attempting to use an argument in a call, the system detected an address that is not valid.

While attempting to access a parameter passed to this function, the system detected an address that is not valid.

[EPERM] Operation not permitted.

You must have appropriate privileges or be the owner of the object or other resource to do the requested operation.

[EUNKNOWN] Unknown system state.

The operation failed because of an unknown system state. See any messages in the job log and correct any errors that are indicated, then retry the operation.



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 ]