time.c 655 B

123456789101112131415161718192021222324252627282930313233
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * time() for uClibc
  4. *
  5. * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.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. #define __NR___time __NR_time
  14. attribute_hidden _syscall1(time_t, __time, time_t *, t);
  15. #else
  16. time_t attribute_hidden __time(time_t * t)
  17. {
  18. time_t result;
  19. struct timeval tv;
  20. if (gettimeofday(&tv, (struct timezone *) NULL)) {
  21. result = (time_t) - 1;
  22. } else {
  23. result = (time_t) tv.tv_sec;
  24. }
  25. if (t != NULL) {
  26. *t = result;
  27. }
  28. return result;
  29. }
  30. #endif
  31. strong_alias(__time,time)