time.c 676 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * time() for uClibc
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <sys/syscall.h>
  10. #include <time.h>
  11. #include <sys/time.h>
  12. /* Experimentally off - libc_hidden_proto(time) */
  13. #ifdef __NR_time
  14. _syscall1(time_t, time, time_t *, t)
  15. #else
  16. libc_hidden_proto(gettimeofday)
  17. time_t time(time_t * t)
  18. {
  19. time_t result;
  20. struct timeval tv;
  21. if (gettimeofday(&tv, (struct timezone *) NULL)) {
  22. result = (time_t) - 1;
  23. } else {
  24. result = (time_t) tv.tv_sec;
  25. }
  26. if (t != NULL) {
  27. *t = result;
  28. }
  29. return result;
  30. }
  31. #endif
  32. libc_hidden_def(time)