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
commit7cdd5316abaf91755edd9186d3836ff371902146 (patch)
treeafe2df61811839a90771807e6fbf50a1af7ec49d /src/sim
parent6c60db8ce99eabdbfcbe0f78a50817494142e39e (diff)
downloadgem5-7cdd5316abaf91755edd9186d3836ff371902146.tar.xz
syscall: Implementation of the time system call.
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/syscall_emul.hh19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index ce7c7fa87..6937e35f0 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -1156,6 +1156,25 @@ timesFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
return clocks;
}
+/// Target time() function.
+template <class OS>
+SyscallReturn
+timeFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
+ ThreadContext *tc)
+{
+ typename OS::time_t sec, usec;
+ getElapsedTime(sec, usec);
+ sec += seconds_since_epoch;
+
+ Addr taddr = (Addr)process->getSyscallArg(tc, 0);
+ if(taddr != 0) {
+ typename OS::time_t t = sec;
+ t = htog(t);
+ TranslatingPort *p = tc->getMemPort();
+ p->writeBlob(taddr, (uint8_t*)&t, (int)sizeof(typename OS::time_t));
+ }
+ return sec;
+}
#endif // __SIM_SYSCALL_EMUL_HH__