diff options
author | gallatin <gallatin@FreeBSD.org> | 2001-02-27 17:11:19 +0000 |
---|---|---|
committer | gallatin <gallatin@FreeBSD.org> | 2001-02-27 17:11:19 +0000 |
commit | f23ef63cf90e36a2bced4a758f9966129ee33b5f (patch) | |
tree | 54362831f177e8d3f9a4d312697f393e51625cc3 /usr.bin/top/machine.c | |
parent | e50089028ca4804e1607a7ce76210cd1ed643ab2 (diff) | |
download | FreeBSD-src-f23ef63cf90e36a2bced4a758f9966129ee33b5f.zip FreeBSD-src-f23ef63cf90e36a2bced4a758f9966129ee33b5f.tar.gz |
- An array of 4 32-bit ints for avenrun doesn't work on the alpha because
fscale is a (64-bit) long. So just use a struct loadavg.
This fixes the recent failure of top on alphas:
top: sysctl(vm.loadavg...) failed: Cannot allocate memory
- use size_t for sizeof() so as to fix a few int/long warnings on alpha
Reviewed by: Thomas Moestl <tmoestl@gmx.net>
Diffstat (limited to 'usr.bin/top/machine.c')
-rw-r--r-- | usr.bin/top/machine.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index acd2d53..7525589 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -58,7 +58,7 @@ #include "screen.h" #include "utils.h" -static void getsysctl __P((char *, void *, int)); +static void getsysctl __P((char *, void *, size_t)); #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var)) @@ -204,7 +204,7 @@ struct statics *statics; { register int pagesize; - int modelen; + size_t modelen; struct passwd *pw; modelen = sizeof(smpmode); @@ -285,36 +285,28 @@ struct system_info *si; { long total; - load_avg avenrun[4]; /* 3 values and FSCALE. */ + struct loadavg sysload; int mib[2]; struct timeval boottime; size_t bt_size; /* get the cp_time array */ GETSYSCTL("kern.cp_time", cp_time); - GETSYSCTL("vm.loadavg", avenrun); + GETSYSCTL("vm.loadavg", sysload); GETSYSCTL("kern.lastpid", lastpid); /* convert load averages to doubles */ { register int i; register double *infoloadp; - load_avg *avenrunp; - -#ifdef notyet - struct loadavg sysload; - int size; - getkerninfo(KINFO_LOADAVG, &sysload, &size, 0); -#endif infoloadp = si->load_avg; - avenrunp = avenrun; for (i = 0; i < 3; i++) { #ifdef notyet *infoloadp++ = ((double) sysload.ldavg[i]) / sysload.fscale; #endif - *infoloadp++ = loaddouble(*avenrunp++); + *infoloadp++ = loaddouble(sysload.ldavg[i]); } } @@ -595,10 +587,10 @@ static void getsysctl (name, ptr, len) char *name; void *ptr; -int len; +size_t len; { - int nlen = len; + size_t nlen = len; if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) { fprintf(stderr, "top: sysctl(%s...) failed: %s\n", name, strerror(errno)); |