2 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
8 .\" This notice shall appear on any product containing this material.
9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .TH CLOCK_SETTIME 3C "Feb 5, 2008"
14 clock_settime, clock_gettime, clock_getres \- high-resolution clock operations
20 \fBint\fR \fBclock_settime\fR(\fBclockid_t\fR \fIclock_id\fR, \fBconst struct timespec *\fR\fItp\fR);
25 \fBint\fR \fBclock_gettime\fR(\fBclockid_t\fR \fIclock_id\fR, \fBstruct timespec *\fR\fItp\fR);
30 \fBint\fR \fBclock_getres\fR(\fBclockid_t\fR \fIclock_id\fR, \fBstruct timespec *\fR\fIres\fR);
36 The \fBclock_settime()\fR function sets the specified clock, \fIclock_id\fR, to
37 the value specified by \fItp\fR. Time values that are between two consecutive
38 non-negative integer multiples of the resolution of the specified clock are
39 truncated down to the smaller multiple of the resolution.
42 The \fBclock_gettime()\fR function returns the current value \fItp\fR for the
43 specified clock, \fIclock_id\fR.
46 The resolution of any clock can be obtained by calling \fBclock_getres()\fR.
47 Clock resolutions are system-dependent and cannot be set by a process. If the
48 argument \fIres\fR is not \fINULL\fR, the resolution of the specified clock is
49 stored in the location pointed to by \fIres\fR. If \fIres\fR is \fINULL\fR, the
50 clock resolution is not returned. If the time argument of \fBclock_settime()\fR
51 is not a multiple of \fIres\fR, then the value is truncated to a multiple of
55 A clock may be systemwide (that is, visible to all processes) or per-process
56 (measuring time that is meaningful only within a process).
59 A \fIclock_id\fR of \fBCLOCK_REALTIME\fR is defined in <\fBtime.h\fR>. This
60 clock represents the realtime clock for the system. For this clock, the values
61 returned by \fBclock_gettime()\fR and specified by \fBclock_settime()\fR
62 represent the amount of time (in seconds and nanoseconds) since the Epoch.
63 Additional clocks may also be supported. The interpretation of time values for
64 these clocks is unspecified.
67 A \fIclock_id\fR of \fBCLOCK_HIGHRES\fR represents the non-adjustable,
68 high-resolution clock for the system. For this clock, the value returned by
69 \fBclock_gettime\fR(3C) represents the amount of time (in seconds and
70 nanoseconds) since some arbitrary time in the past; it is not correlated in any
71 way to the time of day, and thus is not subject to resetting or drifting by way
72 of \fBadjtime\fR(2), \fBntp_adjtime\fR(2), \fBsettimeofday\fR(3C), or
73 \fBclock_settime()\fR. The time source for this clock is the same as that for
77 Additional clocks may also be supported. The interpretation of time values for
78 these clocks is unspecified.
82 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
83 returned and \fBerrno\fR is set to indicate the error.
87 The \fBclock_settime()\fR, \fBclock_gettime()\fR and \fBclock_getres()\fR
88 functions will fail if:
95 The \fIclock_id\fR argument does not specify a known clock.
104 The functions \fBclock_settime()\fR, \fBclock_gettime()\fR, and
105 \fBclock_getres()\fR are not supported by this implementation.
110 The \fBclock_settime()\fR function will fail if:
117 The \fItp\fR argument to \fBclock_settime()\fR is outside the range for the
118 given clock ID; or the \fItp\fR argument specified a nanosecond value less than
119 zero or greater than or equal to 1000 million.
124 The \fBclock_settime()\fR function may fail if:
131 The requesting process does not have the appropriate privilege to set the
138 See \fBattributes\fR(5) for descriptions of the following attributes:
146 ATTRIBUTE TYPE ATTRIBUTE VALUE
148 Interface Stability Committed
150 MT-Level \fBclock_gettime()\fR is Async-Signal-Safe
152 Standard See \fBstandards\fR(5).
158 \fBtime\fR(2), \fBctime\fR(3C), \fBgethrtime\fR(3C), \fBtime.h\fR(3HEAD),
159 \fBtimer_gettime\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)