📄 clock_settime.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>clock_settime</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_001_503"> </a>NAME</h4><blockquote>clock_settime, clock_gettime, clock_getres - clock and timer functions(<b>REALTIME</b>)</blockquote><h4><a name = "tag_000_001_504"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="time.h.html">time.h</a>>int clock_settime(clockid_t <i>clock_id</i>, const struct timespec *<i>tp</i>);int clock_gettime(clockid_t <i>clock_id</i>, struct timespec *<i>tp</i>);int clock_getres(clockid_t <i>clock_id</i>, struct timespec *<i>res</i>);</code></pre></blockquote><h4><a name = "tag_000_001_505"> </a>DESCRIPTION</h4><blockquote>The<i>clock_settime()</i>function sets the specified clock,<i>clock_id</i>,to the value specified by<i>tp</i>.Time values that are between two consecutive non-negative integermultiples of the resolution of the specified clock are truncated down tothe smaller multiple of the resolution.<p>The<i>clock_gettime()</i>function returns the current value<i>tp</i>for the specified clock,<i>clock_id</i>.<p>The resolution of any clock can be obtained by calling<i>clock_getres()</i>.Clock resolutions are implementation-dependent and cannot be set by a process.If the argument<i>res</i>is not NULL,the resolution of the specified clock is storedin the location pointed to by<i>res</i>.If<i>res</i>is NULL,the clock resolution is not returned.If the time argument of<i>clock_settime()</i>is not a multiple of<i>res</i>,then the value is truncated to a multiple of<i>res</i>.<p>A clock may be systemwide (that is, visible to all processes)or per-process (measuring time that is meaningful only within aprocess).All implementations support a<i>clock_id</i>of CLOCK_REALTIME defined in<i><a href="time.h.html"><time.h></a></i>.This clock represents the realtime clock for the system.For this clock, the values returned by<i>clock_gettime()</i>and specified by<i>clock_settime()</i>represent the amount of time(in seconds and nanoseconds) since the Epoch.An implementation may also support additional clocks.The interpretation of time values for these clocks isunspecified.<p>The effect of setting a clock via<i>clock_settime()</i>on armed per-process timers associatedwith that clock is implementation-dependent.<p>The appropriate privilege to set a particular clock isimplementation-dependent.</blockquote><h4><a name = "tag_000_001_506"> </a>RETURN VALUE</h4><blockquote>A return value of 0 indicates that the call succeeded.A return value of -1 indicates that an error occurred, and<i>errno</i>is set to indicate the error.</blockquote><h4><a name = "tag_000_001_507"> </a>ERRORS</h4><blockquote>The <i>clock_settime()</i>,<i>clock_gettime()</i>and<i>clock_getres()</i>functions will fail if:<dl compact><dt>[EINVAL]<dd>The<i>clock_id</i>argument does not specify a known clock.<dt>[ENOSYS]<dd>The functions<i>clock_settime()</i>,<i>clock_gettime()</i>,and<i>clock_getres()</i>are not supported by this implementation.</dl><p>The<i>clock_settime()</i>function will fail if:<dl compact><dt>[EINVAL]<dd>The<i>tp</i>argument to<i>clock_settime()</i>is outside the range for the given clock id.<dt>[EINVAL]<dd>The<i>tp</i>argument specified a nanosecondvalue less than zero or greater than or equal to 1000 million.</dl><p>The<i>clock_settime()</i>function may fail if:<dl compact><dt>[EPERM]<dd>The requesting process does not have the appropriate privilegeto set the specified clock.</dl></blockquote><h4><a name = "tag_000_001_508"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_001_509"> </a>APPLICATION USAGE</h4><blockquote>None.</blockquote><h4><a name = "tag_000_001_510"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_001_511"> </a>SEE ALSO</h4><blockquote><i><a href="timer_gettime.html">timer_gettime()</a></i>,<i><a href="time.html">time()</a></i>,<i><a href="ctime.html">ctime()</a></i>,<i><a href="time.h.html"><time.h></a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995)</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -