gettimeofday.c 543 B

123456789101112131415161718192021222324252627282930
  1. #include "config.h"
  2. #include "libiberty.h"
  3. #ifdef HAVE_TIME_H
  4. #include <time.h>
  5. #endif
  6. #ifdef HAVE_SYS_TIME_H
  7. #include <sys/time.h>
  8. #endif
  9. /*
  10. @deftypefn Supplemental int gettimeofday (struct timeval *@var{tp}, void *@var{tz})
  11. Writes the current time to @var{tp}. This implementation requires
  12. that @var{tz} be NULL. Returns 0 on success, -1 on failure.
  13. @end deftypefn
  14. */
  15. int
  16. gettimeofday (struct timeval *tp, void *tz)
  17. {
  18. if (tz)
  19. abort ();
  20. tp->tv_usec = 0;
  21. if (time (&tp->tv_sec) == (time_t) -1)
  22. return -1;
  23. return 0;
  24. }