=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/top/machine.c,v retrieving revision 1.40 retrieving revision 1.41 diff -c -r1.40 -r1.41 *** src/usr.bin/top/machine.c 2004/06/11 01:32:11 1.40 --- src/usr.bin/top/machine.c 2004/06/11 05:29:28 1.41 *************** *** 1,4 **** ! /* $OpenBSD: machine.c,v 1.40 2004/06/11 01:32:11 deraadt Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert --- 1,4 ---- ! /* $OpenBSD: machine.c,v 1.41 2004/06/11 05:29:28 deraadt Exp $ */ /*- * Copyright (c) 1994 Thorsten Lockert *************** *** 140,145 **** --- 140,147 ---- /* define pagetok in terms of pageshift */ #define pagetok(size) ((size) << pageshift) + int ncpu; + unsigned int maxslp; static int *************** *** 159,166 **** int machine_init(struct statics *statics) { ! int pagesize; stathz = getstathz(); if (stathz == -1) return (-1); --- 161,174 ---- int machine_init(struct statics *statics) { ! 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) return (-1); *************** *** 369,376 **** { static char buf[10]; ! snprintf(buf, sizeof buf, "%s/%d", ! state_abbrev[(unsigned char)pp->p_stat], pp->p_cpuid); return buf; } --- 377,388 ---- { static char buf[10]; ! 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; }