TIME(2)                                                   TIME(2)

     NAME
          bintime, time, nsec - time in seconds and nanoseconds since
          epoch

     SYNOPSIS
          #include <u.h>
          #include <libc.h>

          int bintime(int fd, vlong *nsec, vlong *ticks, vlong *hz)

          long 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.

          These functions work by reading /dev/bintime, opening that
          file when they are first called.

          Bintime reads from fd instead.  It is assumed to have the
          format of /dev/bintime.  If fd is -1, then /dev/bintime is
          opened.  The non-null vlong arguments are set to nanoseconds
          since start of epoch, hardware clock ticks, and hardware
          clock frequency.  The given file descriptor is returned on
          success.  On failure, the file descriptor is closed and -1
          is returned.

     SOURCE
          /sys/src/libc/9sys/bintime.c
          /sys/src/libc/9sys/time.c
          /sys/src/libc/9sys/nsec.c

     SEE ALSO
          cputime(2), cons(3)

     DIAGNOSTICS
          Sets errstr.

     BUGS
          Both time and nsec maintain a static file descriptor.  This
          can cause problems with programs that share memory but not
          file descriptors.  Use bintime instead.

     Page 1                       Plan 9             (printed 4/24/24)