time.c 637 B

12345678910111213141516171819202122232425262728293031323334
  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. _syscall_noerr1(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. /* In Linux, gettimeofday fails only on bad parameter.
  20. * We know that here parameter isn't bad.
  21. */
  22. gettimeofday(&tv, NULL);
  23. result = (time_t) tv.tv_sec;
  24. if (t != NULL) {
  25. *t = result;
  26. }
  27. return result;
  28. }
  29. #endif
  30. libc_hidden_def(time)