diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-06-11 05:29:29 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-06-11 05:29:29 +0000 |
commit | 764a5f1f8b5809eeb9476fcf554d92912a376f5b (patch) | |
tree | bf0fb1aecb84d8e9b1978c2018a82aad061eaf82 /usr.bin/top | |
parent | e03316ce38964a9bbf441a423cfa20ae881a9846 (diff) |
only print /# if > 1 cpu on a machine
Diffstat (limited to 'usr.bin/top')
-rw-r--r-- | usr.bin/top/machine.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 14d578379b2..1f2cef12024 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machine.c,v 1.40 2004/06/11 01:32:11 deraadt Exp $ */ +/* $OpenBSD: machine.c,v 1.41 2004/06/11 05:29:28 deraadt Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert <tholo@sigmasoft.com> @@ -140,6 +140,8 @@ static int pageshift; /* log base 2 of the pagesize */ /* define pagetok in terms of pageshift */ #define pagetok(size) ((size) << pageshift) +int ncpu; + unsigned int maxslp; static int @@ -159,7 +161,13 @@ getstathz(void) int machine_init(struct statics *statics) { - int pagesize; + size_t size = sizeof(ncpu); + int mib[2], pagesize; + + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + if (sysctl(mib, 2, &ncpu, &size, NULL, 0) == -1) + return (-1); stathz = getstathz(); if (stathz == -1) @@ -369,8 +377,12 @@ state_abbr(struct kinfo_proc2 *pp) { static char buf[10]; - snprintf(buf, sizeof buf, "%s/%d", - state_abbrev[(unsigned char)pp->p_stat], pp->p_cpuid); + if (ncpu > 1) + snprintf(buf, sizeof buf, "%s/%d", + state_abbrev[(unsigned char)pp->p_stat], pp->p_cpuid); + else + snprintf(buf, sizeof buf, "%s", + state_abbrev[(unsigned char)pp->p_stat]); return buf; } |