implement RUSAGE_CHILDREN for getrusage since it's trivial
--HG-- extra : convert_revision : bc12b3b2e9ee02f42c437cbc20680ea00e19a801
This commit is contained in:
parent
31d829d388
commit
4c2e65c94e
1 changed files with 20 additions and 11 deletions
|
@ -934,17 +934,8 @@ getrusageFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
|
|||
int who = tc->getSyscallArg(0); // THREAD, SELF, or CHILDREN
|
||||
TypedBufferArg<typename OS::rusage> 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;
|
||||
|
|
Loading…
Reference in a new issue