From 4c2e65c94e2c66daf4be8c424c84002c63693ca2 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 16 Nov 2006 13:08:29 -0800 Subject: [PATCH] implement RUSAGE_CHILDREN for getrusage since it's trivial --HG-- extra : convert_revision : bc12b3b2e9ee02f42c437cbc20680ea00e19a801 --- src/sim/syscall_emul.hh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh index 07689ef06..27356c9f1 100644 --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -934,17 +934,8 @@ getrusageFunc(SyscallDesc *desc, int callnum, LiveProcess *process, int who = tc->getSyscallArg(0); // THREAD, SELF, or CHILDREN TypedBufferArg rup(tc->getSyscallArg(1)); - if (who != OS::TGT_RUSAGE_SELF) { - // don't really handle THREAD or CHILDREN, but just warn and - // plow ahead - warn("getrusage() only supports RUSAGE_SELF. Parameter %d ignored.", - who); - } - - getElapsedTime(rup->ru_utime.tv_sec, rup->ru_utime.tv_usec); - rup->ru_utime.tv_sec = htog(rup->ru_utime.tv_sec); - rup->ru_utime.tv_usec = htog(rup->ru_utime.tv_usec); - + rup->ru_utime.tv_sec = 0; + rup->ru_utime.tv_usec = 0; rup->ru_stime.tv_sec = 0; rup->ru_stime.tv_usec = 0; rup->ru_maxrss = 0; @@ -962,6 +953,24 @@ getrusageFunc(SyscallDesc *desc, int callnum, LiveProcess *process, rup->ru_nvcsw = 0; rup->ru_nivcsw = 0; + switch (who) { + case OS::TGT_RUSAGE_SELF: + getElapsedTime(rup->ru_utime.tv_sec, rup->ru_utime.tv_usec); + rup->ru_utime.tv_sec = htog(rup->ru_utime.tv_sec); + rup->ru_utime.tv_usec = htog(rup->ru_utime.tv_usec); + break; + + case OS::TGT_RUSAGE_CHILDREN: + // do nothing. We have no child processes, so they take no time. + break; + + default: + // don't really handle THREAD or CHILDREN, but just warn and + // plow ahead + warn("getrusage() only supports RUSAGE_SELF. Parameter %d ignored.", + who); + } + rup.copyOut(tc->getMemPort()); return 0; -- 2.30.2