aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
authorLuís Marques <luis@luismarques.eu>2019-01-05 02:08:06 +0000
committerAndrew Waterman <aswaterman@gmail.com>2019-01-04 18:08:06 -0800
commit31e531b2b4afe8ec5e08d700727afdbbbe45bf34 (patch)
treeab87fa9f201640737681ea1e1b45eeed27e6c7f8 /pk
parentcb28d01e1dc80ff9a0c599105bc4e97fdc5274e3 (diff)
downloadpk-31e531b2b4afe8ec5e08d700727afdbbbe45bf34.zip
pk-31e531b2b4afe8ec5e08d700727afdbbbe45bf34.tar.gz
pk-31e531b2b4afe8ec5e08d700727afdbbbe45bf34.tar.bz2
Implement clock_gettime syscall (#139)
Diffstat (limited to 'pk')
-rw-r--r--pk/syscall.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/pk/syscall.c b/pk/syscall.c
index d944c52..5a86c5c 100644
--- a/pk/syscall.c
+++ b/pk/syscall.c
@@ -380,6 +380,15 @@ int sys_gettimeofday(long* loc)
return 0;
}
+long sys_clock_gettime(int clk_id, long *loc)
+{
+ uintptr_t t = rdcycle();
+ loc[0] = t / CLOCK_FREQ;
+ loc[1] = (t % CLOCK_FREQ) / (CLOCK_FREQ / 1000000000);
+
+ return 0;
+}
+
ssize_t sys_writev(int fd, const long* iov, int cnt)
{
ssize_t ret = 0;
@@ -455,7 +464,7 @@ long do_syscall(long a0, long a1, long a2, long a3, long a4, long a5, unsigned l
[SYS_readlinkat] = sys_stub_nosys,
[SYS_rt_sigprocmask] = sys_stub_success,
[SYS_ioctl] = sys_stub_nosys,
- [SYS_clock_gettime] = sys_stub_nosys,
+ [SYS_clock_gettime] = sys_clock_gettime,
[SYS_getrusage] = sys_stub_nosys,
[SYS_getrlimit] = sys_stub_nosys,
[SYS_setrlimit] = sys_stub_nosys,