syscall: Implementation of the time system call.
authorTimothy M. Jones <tjones1@inf.ed.ac.uk>
Sat, 24 Oct 2009 17:53:57 +0000 (10:53 -0700)
committerTimothy M. Jones <tjones1@inf.ed.ac.uk>
Sat, 24 Oct 2009 17:53:57 +0000 (10:53 -0700)
src/kern/linux/linux.hh
src/sim/syscall_emul.hh

index 2df323712c555a3c5264f96fc5286b86758e825d..736213762b4e8324bc378f5dc033ece2e2af98bf 100644 (file)
@@ -62,6 +62,7 @@ class Linux : public OperatingSystem
     typedef uint64_t size_t;
     typedef uint64_t off_t;
     typedef int64_t time_t;
+    typedef int64_t clock_t;
     typedef uint32_t uid_t;
     typedef uint32_t gid_t;
     //@}
index ce7c7fa8789f9beac2ba211168dd02e4a124c437..6937e35f0d0bbfc5d6e73070ab1a7a6ccfb6091d 100644 (file)
@@ -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__