NAME
time, nsec – time in seconds and nanoseconds since epoch |
SYNOPSIS
#include <u.h> #include <libc.h>
ulong time(long *tp)
vlong nsec(void) |
DESCRIPTION
Both time and nsec return the time since the epoch 00:00:00 GMT,
Jan. 1, 1970. The return value of the former is in seconds and
the latter in nanoseconds. For time, if tp is not zero then *tp
is also set to the answer. Times should be stored in and treated as ulongs, or cast to ulong then stored in vlongs; this extends the range of valid times into the year 2106. Before subtraction, times should be cast to vlong. Time simply calls nsec and returns the value divided by 1000000000. Nsec is a system call. Previous implementations read /dev/bintime, opening that file when first called, and maintaining a static file descriptor; however, the maintenance of file descriptors in the face of process forks is overly complex and prone to error, and this process added considerable jitter. |
SOURCE
/sys/src/libc/9sys/time.c /sys/src/libc/9syscall |
SEE ALSO
cputime(2), ctime(2), cons(3) |
DIAGNOSTICS
Sets errstr. Programs should test for the exact time value (ulong)–1
as a failure indication, not just for any negative value. |