# HG changeset patch
# User Timothy M. Jones <[email protected]>
# Date 1255004953 -3600
# Node ID 7435b8dcb32f7952491c8aa531051ab2c664979c
# Parent  4b6b39589edfceea071214a718bc2492bbc23b5a
Implementation of the times system call.

diff --git a/src/kern/linux/linux.hh b/src/kern/linux/linux.hh
--- a/src/kern/linux/linux.hh
+++ b/src/kern/linux/linux.hh
@@ -136,6 +136,14 @@
         int64_t tv_usec;        //!< microseconds
     };
 
+    /// For times().
+    struct tms {
+        int64_t tms_utime;      //!< user time
+        int64_t tms_stime;      //!< system time
+        int64_t tms_cutime;     //!< user time of children
+        int64_t tms_cstime;     //!< system time of children
+    };
+
     // For writev/readv
     struct tgt_iovec {
         uint64_t iov_base; // void *
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -1131,6 +1131,29 @@
     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 clock ticks)
+    bufp->tms_utime = curTick;
+    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 curTick;
+}
 
 
 

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to