summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/gettimeofday.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/common/gettimeofday.c')
-rwxr-xr-x[-rw-r--r--]libc/sysdeps/linux/common/gettimeofday.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/libc/sysdeps/linux/common/gettimeofday.c b/libc/sysdeps/linux/common/gettimeofday.c
index 1c62b3937..9b29fe5a0 100644..100755
--- a/libc/sysdeps/linux/common/gettimeofday.c
+++ b/libc/sysdeps/linux/common/gettimeofday.c
@@ -8,6 +8,25 @@
#include <sys/syscall.h>
#include <sys/time.h>
+#include <time.h>
+
+#ifdef __VDSO_SUPPORT__
+#include "ldso.h"
+#endif
+
+int gettimeofday(struct timeval * tv, __timezone_ptr_t tz) {
+ if (!tv)
+ return 0;
+#if defined(__VDSO_SUPPORT__) && defined(ARCH_VDSO_GETTIMEOFDAY)
+ return ARCH_VDSO_GETTIMEOFDAY(tv, tz);
+#else
+ struct timespec __ts;
+ int __ret = clock_gettime(CLOCK_REALTIME, &__ts);
+ tv->tv_sec = __ts.tv_sec;
+ tv->tv_usec = (suseconds_t)__ts.tv_nsec / 1000;
+ return __ret;
+#endif
+}
+
-_syscall2(int, gettimeofday, struct timeval *, tv, __timezone_ptr_t, tz)
libc_hidden_def(gettimeofday)