Rich Felker | e3eb493 | 2011-07-23 23:45:33 -0400 | [diff] [blame] | 1 | #include <time.h> |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 2 | #include <sys/time.h> |
| 3 | #include "syscall.h" |
| 4 | |
Rich Felker | 400c5e5 | 2012-09-06 22:44:55 -0400 | [diff] [blame] | 5 | int gettimeofday(struct timeval *restrict tv, void *restrict tz) |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 6 | { |
Rich Felker | e3eb493 | 2011-07-23 23:45:33 -0400 | [diff] [blame] | 7 | struct timespec ts; |
| 8 | if (!tv) return 0; |
| 9 | clock_gettime(CLOCK_REALTIME, &ts); |
| 10 | tv->tv_sec = ts.tv_sec; |
| 11 | tv->tv_usec = (int)ts.tv_nsec / 1000; |
Rich Felker | 0b44a03 | 2011-02-12 00:22:29 -0500 | [diff] [blame] | 12 | return 0; |
| 13 | } |