summaryrefslogtreecommitdiff
path: root/src/time/gettimeofday.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-07-23 23:45:33 -0400
committerRich Felker <dalias@aerifal.cx>2011-07-23 23:45:33 -0400
commite3eb49321c85e43fcc6842f3f57ee097b32555e4 (patch)
tree126e8f35f23c92fdb7ff8f805c7d59b662c8b7ae /src/time/gettimeofday.c
parentc0fe5b9da9f98b83262717c0090817f1fbb3d8a0 (diff)
downloadmusl-e3eb49321c85e43fcc6842f3f57ee097b32555e4.tar.gz
some preliminaries for vdso clock support
these changes also make it so clock_gettime(CLOCK_REALTIME, &ts) works even on pre-2.6 kernels, emulated via the gettimeofday syscall. there is no cost for the fallback check, as it falls under the error case that already must be checked for storing the error code in errno, but which would normally be hidden inside __syscall_ret.
Diffstat (limited to 'src/time/gettimeofday.c')
-rw-r--r--src/time/gettimeofday.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/time/gettimeofday.c b/src/time/gettimeofday.c
index 2436e490..09afb70b 100644
--- a/src/time/gettimeofday.c
+++ b/src/time/gettimeofday.c
@@ -1,8 +1,13 @@
+#include <time.h>
#include <sys/time.h>
#include "syscall.h"
int gettimeofday(struct timeval *tv, void *tz)
{
- __syscall(SYS_gettimeofday, tv, 0);
+ struct timespec ts;
+ if (!tv) return 0;
+ clock_gettime(CLOCK_REALTIME, &ts);
+ tv->tv_sec = ts.tv_sec;
+ tv->tv_usec = (int)ts.tv_nsec / 1000;
return 0;
}