time.c 380 B

123456789101112131415161718192021222324252627
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <fcntl.h>
  4. #include <time.h>
  5. #include <unistd.h>
  6. #include <string.h>
  7. #include <stdlib.h>
  8. #include "sys9.h"
  9. time_t
  10. time(time_t *tp)
  11. {
  12. char b[20];
  13. int f;
  14. time_t t;
  15. memset(b, 0, sizeof(b));
  16. f = _OPEN("/dev/time", 0);
  17. if(f >= 0) {
  18. _PREAD(f, b, sizeof(b), 0);
  19. _CLOSE(f);
  20. }
  21. t = atol(b);
  22. if(tp)
  23. *tp = t;
  24. return t;
  25. }