77 lines · 1.3 KB · Text
RawDownload
.TH TIME 2.SH NAMEbintime, time, nsec \- time in seconds and nanoseconds since epoch.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.PP.nf.Bint bintime(int fd, vlong *nsec, vlong *ticks, vlong *hz).PP.Blong time(long *tp).PP.Bvlong nsec(void).SH DESCRIPTIONBoth.I timeand.I nsecreturn 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.IR time ,if.I tpis not zero then.BI * tpis also set to the answer..PPThese functions work by reading.BR /dev/bintime ,opening that file when they are first called..PP.B Bintimereads from.BR fd instead.  It is assumed to have the format of.BR "/dev/bintime" .If.B fdis -1, then.B "/dev/bintime"is opened.The non-null.B vlongarguments are set to nanoseconds since start ofepoch, hardware clock ticks, and hardware clock frequency.The given file descriptor is returned on success.  On failure,the file descriptor is closed and.B -1is returned..SH SOURCE.B /sys/src/libc/9sys/bintime.c.br.B /sys/src/libc/9sys/time.c.br.B /sys/src/libc/9sys/nsec.c.SH SEE ALSO.IR cputime (2),.IR cons (3).SH DIAGNOSTICSSets.IR errstr ..SH BUGSBoth.I timeand.I nsecmaintain a static file descriptor.This can cause problems with programsthat share memory but not file descriptors.Use.I bintimeinstead.