1.\" $NetBSD: clock_settime.2,v 1.4 1999/03/22 19:45:01 garbled Exp $ 2.\" 3.\" Copyright (c) 1999 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Klaus Klein. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd February 11, 1999 38.Dt CLOCK_SETTIME 2 39.Os 40.Sh NAME 41.Nm clock_settime , 42.Nm clock_gettime , 43.Nm clock_getres 44.Nd clock and timer functions 45.Sh SYNOPSIS 46.Fd #include <time.h> 47.Ft int 48.Fn clock_settime "clockid_t clock_id" "const struct timespec *tp" 49.Ft int 50.Fn clock_gettime "clockid_t clock_id" "struct timespec *tp" 51.Ft int 52.Fn clock_getres "clockid_t clock_id" "struct timespec *res" 53.Sh DESCRIPTION 54The 55.Fn clock_settime 56function sets the clock identified by 57.Fa clock_id 58to the absolute time specified by 59.Fa tp . 60If the time specified by 61.Fa tp 62is not a multiple of the resolution of the clock, 63.Fa tp 64is truncated to a multiple of the resolution. 65.Pp 66.The 67.Fn clock_gettime 68function stores the time of the clock identified by 69.Fa clock_id 70into the location specified by 71.Fa tp. 72.Pp 73The 74.Fn clock_getres 75function stores the resolution of the clock identified by 76.Fa clock_id 77into the location specified by 78.Fa res , 79unless 80.Fa res 81is 82.Dv NULL . 83.Pp 84A 85.Fa clock_id 86of 87.Dv CLOCK_REALTIME 88identifies the realtime clock for the system. 89For this clock, the values specified by 90.Fn clock_settime 91and obtained by 92.Fn clock_gettime 93represent the amount of time (in seconds and nanoseconds) 94since 00:00 Universal Coordinated Time, January 1, 1970. 95.Sh RETURN VALUES 96A value of 0 is returned on success. Otherwise, a value of -1 is returned and 97.Va errno 98is set to indicate the error. 99.Sh ERRORS 100The 101.Fn clock_settime , 102.Fn clock_gettime 103and 104.Fn clock_getres 105functions will fail if: 106.Bl -tag -width Er 107.It Bq Er EINVAL 108The 109.Fa clock_id 110argument does not specify a known clock. 111.It Bq Er ENOSYS 112The function is not supported by this implementation. 113.El 114.Pp 115The 116.Fn clock_settime 117function will fail if: 118.Bl -tag -width Er 119.It Bq Er EINVAL 120The 121.Fa tp 122argument is outside the range for the specified clock, 123.Fa clock_id . 124.It Bq Er EINVAL 125The 126.Fa tp 127argument specified a nanosecond value less than zero of greater than or equal 1281000 million. 129.It Bq Er EPERM 130The 131calling process does not have the appropriate privilege to set the specified 132clock, 133.Fa clock_id . 134.El 135.Pp 136The 137.Fn clock_gettime 138function will fail if: 139.Bl -tag -width Er 140.It Bq Er EFAULT 141The 142.Fa tp 143argument specifies an address that is not a valid part of the process address 144space. 145.El 146.Sh SEE ALSO 147.Xr ctime 3 , 148.Xr time 3 149.\" .Xr timer_gettime 3 150.Sh STANDARDS 151The 152.Fn clock_settime , 153.Fn clock_gettime 154and 155.Fn clock_getres 156functions conform to 157.St -p1003.1b-93 . 158