ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/adjtime.htm

232 lines
6.4 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<!-- Begin Header records -->
<title>adjtime()--Adjust System Clock</title>
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Change History: -->
<!-- YYMMDD USERID Change description -->
<!-- End Header Records -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- Java sync-link =================================================== -->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<a name="Top_Of_Page"></a>
<h2>adjtime()--Adjust System Clock</h2>
<div class="box" style="width: 70%;">
<br>
&nbsp;&nbsp;Syntax
<pre>
#include &lt;sys/time.h&gt;
int adjtime (struct timeval *delta,
struct timeval *olddelta);
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QWCTZUTC<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>adjtime()</strong> function makes small adjustments to the system clock, either slowing it down or speeding it up by the time specified in the <em>delta</em> parameter up to a maximum of two hours. If <em>delta</em> is negative, the clock is slowed down by incrementing it more slowly than normal until the correction is complete. If <em>delta</em> is positive, the clock is sped up by incrementing it more quickly than normal until the correction is complete. If <em>olddelta</em> is not NULL, the amount of time still to be corrected from a previous <strong>adjtime()</strong> call is returned in the structure it points to.
</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong>delta</strong></dt>
<dd>(Input)
<p>A pointer to a timeval structure that contains the amount of time for adjusting the clock.</p>
</dd>
<dt><strong>olddelta</strong></dt>
<dd>(Output)
<p>A pointer to a timeval structure that contains the amount of time still to be corrected from a previous call to <strong>adjtime()</strong>.</p>
</dd>
</dl>
<br>
<h3>Authorities and Locks</h3>
<dl>
<dt><em>Special Authority</em></dt>
<dd>*ALLOBJ<br>
<br>
</dd>
</dl>
<br>
<h3>Return Value</h3>
<table width="100%">
<tr>
<td width="5%" valign=top><strong>0</strong></td>
<td width="95%"><strong>adjtime()</strong> was successful. The requested adjustment was initiated and the value returned in the structure pointed to by the <em>olddelta</em> parameter is the amount of time still to be corrected from a previous <strong>adjtime()</strong>.</td>
</tr>
<tr>
<td valign=top><strong>-1</strong></td>
<td><strong>adjtime()</strong> was not successful. The <em>errno</em> variable is set to indicate the error.</td>
</tr>
</table>
<br>
<br>
<h3>Error Conditions</h3>
<p>If <strong>adjtime()</strong> is not successful, <em>errno</em> usually indicates one of the following errors. Under some conditions, <em>errno</em> could indicate an error other than those listed here.</p>
<table cellpadding="5">
<!-- cols="15 85" -->
<tr>
<td align="left" valign="top"><em>[EACCES]</em></td>
<td align="left" valign="top">Permission denied.
<p>An attempt was made to access an object in a way forbidden by its object
access permissions.</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EINVAL]</em></td>
<td align="left" valign="top">An invalid parameter was found.
<p>A parameter passed to this function is not valid.</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EFAULT]</em></td>
<td align="left" valign="top">The address used for an argument is not correct.
<p>In attempting to use an argument in a call, the system detected an address
that is not valid.</p>
<p>While attempting to access a parameter passed to this function, the system
detected an address that is not valid.</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EPERM]</em></td>
<td align="left" valign="top">Operation not permitted.
<p>You must have appropriate privileges or be the owner of the object or other
resource to do the requested operation.</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[ENOTSUP]</em></td>
<td align="left" valign="top">Operation not supported.
<p>The operation is not supported.</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EUNKNOWN]</em></td>
<td align="left" valign="top">Unknown system state.
<p>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.</p>
</td>
</tr>
</table>
<br>
<h3>Error Messages</h3>
<p>None.</p>
<br>
<h3>Related Information</h3>
<ul>
<li>The &lt;<strong>sys/time.h</strong>&gt; file (see <a href=
"unix13.htm">Header Files for UNIX-Type Functions</a>)<br>
<br>
</li>
<li><a href="gettod.htm">gettimeofday()--Get Current UTC Time</a><br>
<br>
</li>
<li><a href="settod.htm">settimeofday()--Set System Clock</a></li>
</ul>
<br>
<h3><a name="example.htm">Example</a></h3>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<p>The following example initiates a system clock adjustment:</p>
<pre>
#include &lt;sys/time.h&gt;
#include &lt;stdio.h&gt;
#include &lt;errno.h&gt;
int main(int argc, char *argv[])
{
struct timeval adj, old;
int rc;
/* Speed up the clock by 1.5 seconds. */
adj.tv_sec=1;
adj.tv_usec=500000;
rc=adjtime(&amp;adj, &amp;old);
if(rc==0) {
printf(&quot;adjtime() successful. &quot;
&quot;Olddelta = %u.%06u\n&quot;,
old.tv_sec, old.tv_usec);
}
else {
printf(&quot;adjtime() failed, errno = %d\n&quot;,errno);
return -1;
}
return 0;
}
</pre>
<strong>Example Output:</strong>
<pre>
adjtime() successful. Olddelta = 0.000000
</pre>
<br>
<hr>
API introduced: V4R2
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
</tr>
</table>
</center>
</body>
</html>