time.c 648 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * time() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #include <time.h>
  10. #if defined(__NR_time) && !defined(__UCLIBC_USE_TIME64__)
  11. _syscall_noerr1(time_t, time, time_t *, t)
  12. #else
  13. # include <sys/time.h>
  14. time_t time(time_t * t)
  15. {
  16. time_t result;
  17. struct timeval tv;
  18. /* In Linux, gettimeofday fails only on bad parameter.
  19. * We know that here parameter isn't bad.
  20. */
  21. gettimeofday(&tv, NULL);
  22. result = (time_t) tv.tv_sec;
  23. if (t != NULL)
  24. *t = result;
  25. return result;
  26. }
  27. #endif
  28. libc_hidden_def(time)