summaryrefslogtreecommitdiff
path: root/lib/libc/time/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/time/time.c')
-rw-r--r--lib/libc/time/time.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/libc/time/time.c b/lib/libc/time/time.c
new file mode 100644
index 00000000..134eed7b
--- /dev/null
+++ b/lib/libc/time/time.c
@@ -0,0 +1,20 @@
+#include <time.h>
+#include <asm/vdso.h>
+#include <syscall.h>
+
+time_t time(time_t *tloc)
+{
+ struct timespec ts;
+
+#if defined(__x86_64__)
+ if (__vdso_time)
+ return __vdso_time(tloc);
+#endif
+
+ clock_gettime(CLOCK_REALTIME, &ts);
+
+ if (tloc)
+ *tloc = ts.tv_sec;
+
+ return ts.tv_sec;
+}