1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include "platform.h"
#include "getText.c"
#include "mkdir2.c"
#include "showMem.linux.c"
#include "ssmmap.c"
#include "totalRam.sysconf.c"
/* Work around Linux kernel bugs associated with the user and system times. */
int fixedGetrusage (int who, struct rusage *rup) {
struct tms tbuff;
int res;
clock_t user,
sys;
static bool first = TRUE;
static long hz;
if (first) {
first = FALSE;
hz = sysconf (_SC_CLK_TCK);
}
res = getrusage (who, rup);
unless (res == 0)
return (res);
if (times (&tbuff) == -1)
diee ("Impossible: times() failed");
switch (who) {
case RUSAGE_SELF:
user = tbuff.tms_utime;
sys = tbuff.tms_stime;
break;
case RUSAGE_CHILDREN:
user = tbuff.tms_cutime;
sys = tbuff.tms_cstime;
break;
default:
die ("getrusage() accepted unknown who: %d", who);
exit (1); /* needed to keep gcc from whining. */
}
rup->ru_utime.tv_sec = user / hz;
rup->ru_utime.tv_usec = (user % hz) * (1000000 / hz);
rup->ru_stime.tv_sec = sys / hz;
rup->ru_stime.tv_usec = (sys % hz) * (1000000 / hz);
return (0);
}
|