time 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. .TH TIME 2
  2. .SH NAME
  3. time, nsec \- time in seconds and nanoseconds since epoch
  4. .SH SYNOPSIS
  5. .B #include <u.h>
  6. .br
  7. .B #include <libc.h>
  8. .PP
  9. .nf
  10. .B
  11. long time(long *tp)
  12. .PP
  13. .B
  14. vlong nsec(void)
  15. .SH DESCRIPTION
  16. Both
  17. .I time
  18. and
  19. .I nsec
  20. return the time since the epoch 00:00:00 GMT, Jan. 1, 1970.
  21. The return value of the former is in seconds and the latter in nanoseconds.
  22. For
  23. .IR time ,
  24. if
  25. .I tp
  26. is not zero then
  27. .BI * tp
  28. is also set to the answer.
  29. .PP
  30. Times from
  31. .I time
  32. should be stored in and treated as
  33. .BR ulong s;
  34. this extends the range of valid times into the year 2106.
  35. .PP
  36. .I Time
  37. simply calls
  38. .I nsec
  39. and returns the value divided by 1000000000.
  40. .PP
  41. .I Nsec
  42. is a system call.
  43. Previous implementations read
  44. .BR /dev/bintime ,
  45. opening that file when first called,
  46. and maintaining a static file descriptor;
  47. however,
  48. the maintenance of file descriptors in the face
  49. of process forks is overly complex and prone to error.
  50. .SH SOURCE
  51. .B /sys/src/libc/9sys/time.c
  52. .br
  53. .B /sys/src/libc/9syscall
  54. .SH SEE ALSO
  55. .IR cputime (2),
  56. .IR cons (3)
  57. .SH DIAGNOSTICS
  58. Sets
  59. .IR errstr .