summaryrefslogtreecommitdiff
path: root/src/time/time.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/time.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/time.c')
-rw-r--r--src/time/time.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/time/time.c b/src/time/time.c
index 05e075b9..22754850 100644
--- a/src/time/time.c
+++ b/src/time/time.c
@@ -2,10 +2,12 @@
#include <sys/time.h>
#include "syscall.h"
+int __clock_gettime(clockid_t, struct timespec *);
+
time_t time(time_t *t)
{
- struct timeval tv;
- __syscall(SYS_gettimeofday, &tv, 0);
- if (t) *t = tv.tv_sec;
- return tv.tv_sec;
+ struct timespec ts;
+ __clock_gettime(CLOCK_REALTIME, &ts);
+ if (t) *t = ts.tv_sec;
+ return ts.tv_sec;
}