time.c 560 B

12345678910111213141516171819202122232425262728293031
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * time() for uClibc
  4. *
  5. * Copyright (C) 2000-2004 by Erik Andersen <andersen@codpoet.org>
  6. *
  7. * GNU Library General Public License (LGPL) version 2 or later.
  8. */
  9. #include "syscalls.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