summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorTimothy M. Jones <tjones1@inf.ed.ac.uk>2009-10-24 10:53:57 -0700
committerTimothy M. Jones <tjones1@inf.ed.ac.uk>2009-10-24 10:53:57 -0700
commit6c60db8ce99eabdbfcbe0f78a50817494142e39e (patch)
tree4a7d1524cf82166d1b5314efd64bd469eaa67707 /src/sim
parent56154cff5eab4a28a6d86a820a4364f99889555f (diff)
downloadgem5-6c60db8ce99eabdbfcbe0f78a50817494142e39e.tar.xz
syscall: Implementation of the times system call
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/syscall_emul.hh24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index e45a6c797..ce7c7fa87 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -1131,6 +1131,30 @@ getrusageFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
return 0;
}
+/// Target times() function.
+template <class OS>
+SyscallReturn
+timesFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
+ ThreadContext *tc)
+{
+ TypedBufferArg<typename OS::tms> bufp(process->getSyscallArg(tc, 0));
+
+ // Fill in the time structure (in clocks)
+ int64_t clocks = curTick * OS::_SC_CLK_TCK / Clock::Int::s;
+ bufp->tms_utime = clocks;
+ bufp->tms_stime = 0;
+ bufp->tms_cutime = 0;
+ bufp->tms_cstime = 0;
+
+ // Convert to host endianness
+ bufp->tms_utime = htog(bufp->tms_utime);
+
+ // Write back
+ bufp.copyOut(tc->getMemPort());
+
+ // Return clock ticks since system boot
+ return clocks;
+}