Cleanup various type-o's in comments.
[dragonfly.git] / lib / libcr / sys / clock_gettime.2
1 .\"     $OpenBSD: clock_gettime.2,v 1.4 1997/05/08 20:21:16 kstailey Exp $
2 .\" $FreeBSD: src/lib/libc/sys/clock_gettime.2,v 1.3.2.8 2001/12/14 18:34:00 ru Exp $
3 .\" $DragonFly: src/lib/libcr/sys/Attic/clock_gettime.2,v 1.2 2003/06/17 04:26:47 dillon Exp $
4 .\"
5 .\" Copyright (c) 1980, 1991, 1993
6 .\"     The Regents of the University of California.  All rights reserved.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\"    must display the following acknowledgement:
18 .\"     This product includes software developed by the University of
19 .\"     California, Berkeley and its contributors.
20 .\" 4. Neither the name of the University nor the names of its contributors
21 .\"    may be used to endorse or promote products derived from this software
22 .\"    without specific prior written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" SUCH DAMAGE.
35 .\"
36 .Dd May 8, 1997
37 .Dt CLOCK_GETTIME 2
38 .Os
39 .Sh NAME
40 .Nm clock_gettime ,
41 .Nm clock_settime ,
42 .Nm clock_getres
43 .Nd get/set/calibrate date and time
44 .Sh LIBRARY
45 .Lb libc
46 .Sh SYNOPSIS
47 .In sys/time.h
48 .Ft int
49 .Fn clock_gettime "clockid_t clock_id" "struct timespec *tp"
50 .Ft int
51 .Fn clock_settime "clockid_t clock_id" "const struct timespec *tp"
52 .Ft int
53 .Fn clock_getres "clockid_t clock_id" "struct timespec *tp"
54 .Sh DESCRIPTION
55 The
56 .Fn clock_gettime
57 and
58 .Fn clock_settime
59 allow the calling process to retrieve or set the value used by a clock
60 which is specifed by
61 .Fa clock_id .
62 .Pp
63 .Fa clock_id
64 can be one of three values: CLOCK_REALTIME for time that increments as
65 a wall clock should, CLOCK_VIRTUAL for time that increments only when
66 the CPU is running in user mode on behalf of the calling process, or
67 CLOCK_PROF for time that increments when the CPU is running in user or
68 kernel mode.
69 .Pp
70 The structure pointed to by
71 .Fa tp
72 is defined in
73 .Ao Pa sys/time.h Ac
74 as:
75 .Pp
76 .Bd -literal
77 struct timespec {
78         time_t  tv_sec;         /* seconds */
79         long    tv_nsec;        /* and nanoseconds */
80 };
81 .Ed
82 .Pp
83 Only the super-user may set the time of day.
84 If the system securelevel is greater than 1 (see
85 .Xr init 8 ) ,
86 the time may only be advanced.
87 This limitation is imposed to prevent a malicious super-user
88 from setting arbitrary time stamps on files.
89 The system time can still be adjusted backwards using the
90 .Xr adjtime 2
91 system call even when the system is secure.
92 .Pp
93 The resolution (granularity) of a clock is returned by the
94 .Fn clock_getres
95 call.  This value is placed in a (non-NULL)
96 .Fa *tp .
97 .Sh RETURN VALUES
98 .Rv -std
99 .Sh ERRORS
100 The following error codes may be set in
101 .Va errno :
102 .Bl -tag -width Er
103 .It Bq Er EINVAL
104 The
105 .Fa clock_id
106 was not a valid value.
107 .It Bq Er EFAULT
108 The
109 .Fa *tp
110 argument address referenced invalid memory.
111 .It Bq Er EPERM
112 A user other than the super-user attempted to set the time.
113 .El
114 .Sh SEE ALSO
115 .Xr date 1 ,
116 .Xr adjtime 2 ,
117 .Xr ctime 3 ,
118 .Xr timed 8
119 .Sh STANDARDS
120 The
121 .Fn clock_gettime ,
122 etc.\&
123 functions conform to
124 .St -p1003.1b-93 .