1 /*
2  * gettimeofday() for uClibc
3  *
4  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
5  *
6  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7  */
8 
9 #include <sys/syscall.h>
10 #include <sys/time.h>
11 #include <time.h>
12 
13 #ifdef __VDSO_SUPPORT__
14 #include "ldso.h"
15 #endif
16 
gettimeofday(struct timeval * tv,__timezone_ptr_t tz)17 int gettimeofday(struct timeval * tv, __timezone_ptr_t tz) {
18     if (!tv)
19         return 0;
20 #if defined(__VDSO_SUPPORT__) && defined(ARCH_VDSO_GETTIMEOFDAY)
21     return ARCH_VDSO_GETTIMEOFDAY(tv, tz);
22 #else
23     struct timespec __ts;
24     int __ret = clock_gettime(CLOCK_REALTIME, &__ts);
25     tv->tv_sec = __ts.tv_sec;
26     tv->tv_usec = (suseconds_t)__ts.tv_nsec / 1000;
27     return __ret;
28 #endif
29 }
30 
31 
32 libc_hidden_def(gettimeofday)
33