time.c 692 B

1234567891011121314151617181920212223242526272829303132333435
  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. #define gettimeofday __gettimeofday
  10. #include "syscalls.h"
  11. #include <time.h>
  12. #include <sys/time.h>
  13. #ifdef __NR_time
  14. #define __NR___time __NR_time
  15. attribute_hidden _syscall1(time_t, __time, time_t *, t);
  16. #else
  17. time_t attribute_hidden __time(time_t * t)
  18. {
  19. time_t result;
  20. struct timeval tv;
  21. if (gettimeofday(&tv, (struct timezone *) NULL)) {
  22. result = (time_t) - 1;
  23. } else {
  24. result = (time_t) tv.tv_sec;
  25. }
  26. if (t != NULL) {
  27. *t = result;
  28. }
  29. return result;
  30. }
  31. #endif
  32. strong_alias(__time,time)