time.c 593 B

1234567891011121314151617181920212223242526272829303132333435
  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. #ifdef __NR_time
  13. _syscall1(time_t, time, time_t *, t)
  14. #else
  15. time_t time(time_t * t)
  16. {
  17. time_t result;
  18. struct timeval tv;
  19. if (gettimeofday(&tv, (struct timezone *) NULL)) {
  20. result = (time_t) - 1;
  21. } else {
  22. result = (time_t) tv.tv_sec;
  23. }
  24. if (t != NULL) {
  25. *t = result;
  26. }
  27. return result;
  28. }
  29. #endif
  30. libc_hidden_def(time)