1 .\" $NetBSD: gettimeofday.2,v 1.25 2006/10/13 20:57:32 wiz 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 .\" 3. 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
30 .\" @(#)gettimeofday.2 8.2 (Berkeley) 5/26/95
38 .Nd get/set date and time
44 .Fn gettimeofday "struct timeval * restrict tp" "void * restrict tzp"
46 .Fn settimeofday "const struct timeval * restrict tp" "const void * restrict tzp"
49 Note: time zone information is no longer provided by this interface.
52 for information on how to retrieve it.
55 The system's notion of the current UTC time is obtained with the
57 call, and set with the
60 The time is expressed in seconds and microseconds
61 since midnight (0 hour), January 1, 1970.
62 The resolution of the system clock is hardware dependent,
63 and the time may be updated continuously or in ``ticks.''
66 is NULL, the time will not be returned or set.
67 Despite being declared
69 the objects pointed to by
74 The structures pointed to by
84 time_t tv_sec; /* seconds since Jan. 1, 1970 */
85 suseconds_t tv_usec; /* and microseconds */
89 int tz_minuteswest; /* of Greenwich */
90 int tz_dsttime; /* type of dst correction to apply */
96 structure is provided only for source compatibility.
101 will always return zeroes.
103 If the calling user is not the super-user, then the
105 function in the standard C library will try to use the
107 device if present, thus making possible for non privileged users to
111 is not present or not accessible, then
115 system call, which is restricted to the super user.
116 .\" XXX uncomment when/if this is put into place!
117 .\" If the system is running in secure mode (see
119 .\" the time may only be advanced.
120 .\" This limitation is imposed to prevent a malicious super user
121 .\" from setting arbitrary time stamps on files.
122 .\" The system time can still be adjusted backwards using the
124 .\" system call even when the system is secure.
126 A 0 return value indicates that the call succeeded.
127 A \-1 return value indicates an error occurred, and in this
128 case an error code is stored into the global variable
131 The following error codes may be set in
135 An argument address referenced invalid memory.
137 A user other than the super user attempted to set the time, or the specified
138 time was less than the current time, which was not permitted at the current
151 function call appeared in
155 argument was deprecated in
157 (and many other systems).