.\"
.\" @(#)gettimeofday.2 8.2 (Berkeley) 5/26/95
.\"
-.Dd May 26, 1995
+.Dd August 5, 2008
.Dt GETTIMEOFDAY 2
.Os BSD 4
.Sh NAME
.Sh SYNOPSIS
.Fd #include <sys/time.h>
.Ft int
-.Fn gettimeofday "struct timeval *tp" "struct timezone *tzp"
+.Fo gettimeofday
+.Fa "struct timeval *restrict tp"
+.Fa "void *restrict tzp"
+.Fc
.Ft int
-.Fn settimeofday "const struct timeval *tp" "const struct timezone *tzp"
+.Fo settimeofday
+.Fa "const struct timeval *tp"
+.Fa "const struct timezone *tzp"
+.Fc
.Sh DESCRIPTION
-.Bf -symbolic
-Note: timezone is no longer used; this information is kept outside
-the kernel.
-.Ef
.Pp
The system's notion of the current Greenwich time and the current time
zone is obtained with the
clock is hardware dependent, and the time may be updated continuously or
in ``ticks.'' If
.Fa tp
-or
+is NULL
+and
+.Fa tzp
+is non-NULL,
+.Fn gettimeofday
+will populate the timezone struct in
+.Fa tzp .
+If
+.Fa tp
+is non-NULL and
+.Fa tzp
+is NULL, then only the timeval struct in
+.Fa tp
+is populated. If both
+.Fa tp
+and
.Fa tzp
-is NULL, the associated time
-information will not be returned or set.
+are NULL, nothing is returned.
.Pp
The structures pointed to by
.Fa tp
as:
.Pp
.Bd -literal
+
struct timeval {
- long tv_sec; /* seconds since Jan. 1, 1970 */
- long tv_usec; /* and microseconds */
+ time_t tv_sec; /* seconds since Jan. 1, 1970 */
+ suseconds_t tv_usec; /* and microseconds */
};
struct timezone {
int tz_minuteswest; /* of Greenwich */
int tz_dsttime; /* type of dst correction to apply */
};
+
.Ed
.Pp
The
+.Fa timeval
+structure specifies a time value in seconds and microseconds.
+The values in
+.Fa timeval
+are opaque types whose length may vary on different machines;
+depending on them to have any given length may lead to errors.
+.Pp
+The
.Fa timezone
structure indicates the local time zone
(measured in minutes of time westward from Greenwich),
.Pp
Only the super-user may set the time of day or time zone.
If the system securelevel is greater than 1 (see
-.Xr init 8 ),
+.Xr launchd 8 ),
the time may only be advanced.
This limitation is imposed to prevent a malicious super-user
from setting arbitrary time stamps on files.
.It Bq Er EPERM
A user other than the super-user attempted to set the time.
.El
+.Sh LEGACY SYNOPSIS
+.Fd #include <sys/time.h>
+.Pp
+.Ft int
+.br
+.Fo gettimeofday
+.Fa "struct timeval *tp"
+.Fa "struct timezone *tzp"
+.Fc ;
+.Pp
+The type of
+.Fa tzp
+has changed.
.Sh SEE ALSO
.Xr date 1 ,
.Xr adjtime 2 ,
.Xr ctime 3 ,
+.Xr compat 5 ,
.Xr timed 8
.Sh HISTORY
The