1 .\" $OpenBSD: clock_gettime.2,v 1.4 1997/05/08 20:21:16 kstailey Exp $
3 .\" Copyright (c) 1980, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 4. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 .Nd get/set/calibrate date and time
45 .Fn clock_gettime "clockid_t clock_id" "struct timespec *tp"
47 .Fn clock_settime "clockid_t clock_id" "const struct timespec *tp"
49 .Fn clock_getres "clockid_t clock_id" "struct timespec *tp"
55 system calls allow the calling process to retrieve or set the value
56 used by a clock which is specified by
62 can be one of five values:
64 for time that increments as
67 which increments in SI seconds,
69 which starts at zero when the kernel boots and increments
70 monotonically in SI seconds while the machine is running,
72 for time that increments only when
73 the CPU is running in user mode on behalf of the calling process, or
75 for time that increments when the CPU is running in user or
78 The structure pointed to by
86 time_t tv_sec; /* seconds */
87 long tv_nsec; /* and nanoseconds */
91 Only the super-user may set the time of day.
92 If the system securelevel is greater than 1 (see
94 the time may only be advanced.
95 This limitation is imposed to prevent a malicious super-user
96 from setting arbitrary time stamps on files.
97 The system time can still be adjusted backwards using the
99 system call even when the system is secure.
101 The resolution (granularity) of a clock is returned by the
104 This value is placed in a (non-NULL)
109 The following error codes may be set in
116 was not a valid value.
120 argument address referenced invalid memory.
122 A user other than the super-user attempted to set the time.
135 system calls conform to