diff options
Diffstat (limited to 'usr/klibc/gettimeofday.c')
-rw-r--r-- | usr/klibc/gettimeofday.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/usr/klibc/gettimeofday.c b/usr/klibc/gettimeofday.c new file mode 100644 index 0000000..919c46d --- /dev/null +++ b/usr/klibc/gettimeofday.c @@ -0,0 +1,22 @@ +#include <time.h> +#include <sys/time.h> +#include <sys/syscall.h> + +extern int __gettimeofday(void *, struct timezone *); + +int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + struct timespec ts; + + if (tv) { + if (clock_gettime(CLOCK_REALTIME, &ts)) + return -1; + tv->tv_sec = ts.tv_sec; + tv->tv_usec = ts.tv_nsec / 1000; + } + + if (tz && __gettimeofday(NULL, tz)) + return -1; + + return 0; +} |