summaryrefslogtreecommitdiff
path: root/userland/libc/time
diff options
context:
space:
mode:
Diffstat (limited to 'userland/libc/time')
-rw-r--r--userland/libc/time/clock_gettime.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/userland/libc/time/clock_gettime.c b/userland/libc/time/clock_gettime.c
index 492b968..239b389 100644
--- a/userland/libc/time/clock_gettime.c
+++ b/userland/libc/time/clock_gettime.c
@@ -1,15 +1,12 @@
+#include <errno.h>
+#include <stdint.h>
#include <syscall.h>
#include <time.h>
+#include <unistd.h>
int clock_gettime(clockid_t clock_id, struct timespec *tp) {
- (void)clock_id;
- tp->tv_sec = 0;
- tp->tv_nsec = 0;
- return 0;
- /*
-SYS_CLOCK_GETTIME_PARAMS args = {
-.clk = clock_id,
-.ts = tp,
-};
-return syscall(SYS_CLOCK_GETTIME, &args);*/
+ uint32_t ms = uptime();
+ tp->tv_sec = ms / 1000;
+ tp->tv_nsec = ms * 1000000;
+ RC_ERRNO(syscall(SYS_CLOCK_GETTIME, clock_id, tp, 0, 0, 0));
}