syscall_emul: Implement clock_getres() system call
authorMichael LeBeane <Michael.Lebeane@amd.com>
Sat, 13 Feb 2016 17:33:07 +0000 (12:33 -0500)
committerMichael LeBeane <Michael.Lebeane@amd.com>
Sat, 13 Feb 2016 17:33:07 +0000 (12:33 -0500)
This patch implements the clock_getres() system call for arm and x86 in linux
SE mode.

src/arch/arm/linux/process.cc
src/arch/x86/linux/process.cc
src/sim/syscall_emul.hh

index 89a085002bce6dbe7fcd8a6a66194c35d9f63aa3..48aebadc879434d930df69bd69e019999ca959dc 100644 (file)
@@ -383,7 +383,7 @@ static SyscallDesc syscallDescs32[] = {
     /* 261 */ SyscallDesc("timer_delete", unimplementedFunc),
     /* 262 */ SyscallDesc("clock_settime", unimplementedFunc),
     /* 263 */ SyscallDesc("clock_gettime", clock_gettimeFunc<ArmLinux32>),
-    /* 264 */ SyscallDesc("clock_getres", unimplementedFunc),
+    /* 264 */ SyscallDesc("clock_getres", clock_getresFunc<ArmLinux32>),
     /* 265 */ SyscallDesc("clock_nanosleep", unimplementedFunc),
     /* 266 */ SyscallDesc("statfs64", unimplementedFunc),
     /* 267 */ SyscallDesc("fstatfs64", unimplementedFunc),
index 5bb237c107fff34b6f8b2b05c0b432d366d1e8fb..9651f7436e81874a8a2e2ec4e50ec5a80d02992c 100644 (file)
@@ -447,7 +447,7 @@ static SyscallDesc syscallDescs64[] = {
     /* 226 */ SyscallDesc("timer_delete", unimplementedFunc),
     /* 227 */ SyscallDesc("clock_settime", unimplementedFunc),
     /* 228 */ SyscallDesc("clock_gettime", clock_gettimeFunc<X86Linux64>),
-    /* 229 */ SyscallDesc("clock_getres", unimplementedFunc),
+    /* 229 */ SyscallDesc("clock_getres", clock_getresFunc<X86Linux64>),
     /* 230 */ SyscallDesc("clock_nanosleep", unimplementedFunc),
     /* 231 */ SyscallDesc("exit_group", exitGroupFunc),
     /* 232 */ SyscallDesc("epoll_wait", unimplementedFunc),
index ee305fbe9fe99ac678c7a5679cff267c3d6181bb..bff7b79a43d26539f87f670cc0ae212379e571ec 100644 (file)
@@ -1357,6 +1357,23 @@ clock_gettimeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
     return 0;
 }
 
+/// Target clock_getres() function.
+template <class OS>
+SyscallReturn
+clock_getresFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
+{
+    int index = 1;
+    TypedBufferArg<typename OS::timespec> tp(p->getSyscallArg(tc, index));
+
+    // Set resolution at ns, which is what clock_gettime() returns
+    tp->tv_sec = 0;
+    tp->tv_nsec = 1;
+
+    tp.copyOut(tc->getMemProxy());
+
+    return 0;
+}
+
 /// Target gettimeofday() handler.
 template <class OS>
 SyscallReturn