=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/systat/vmstat.c,v retrieving revision 1.52 retrieving revision 1.53 diff -c -r1.52 -r1.53 *** src/usr.bin/systat/vmstat.c 2004/07/09 16:32:54 1.52 --- src/usr.bin/systat/vmstat.c 2004/09/23 21:10:21 1.53 *************** *** 1,4 **** ! /* $OpenBSD: vmstat.c,v 1.52 2004/07/09 16:32:54 deraadt Exp $ */ /* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */ /*- --- 1,4 ---- ! /* $OpenBSD: vmstat.c,v 1.53 2004/09/23 21:10:21 deraadt Exp $ */ /* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */ /*- *************** *** 34,40 **** #if 0 static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94"; #endif ! static char rcsid[] = "$OpenBSD: vmstat.c,v 1.52 2004/07/09 16:32:54 deraadt Exp $"; #endif /* not lint */ /* --- 34,40 ---- #if 0 static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94"; #endif ! static char rcsid[] = "$OpenBSD: vmstat.c,v 1.53 2004/09/23 21:10:21 deraadt Exp $"; #endif /* not lint */ /* *************** *** 72,78 **** struct vmtotal Total; struct nchstats nchstats; long nchcount; ! int *intrcnt; } s, s1, s2, z; #include "dkstats.h" --- 72,78 ---- struct vmtotal Total; struct nchstats nchstats; long nchcount; ! u_quad_t *intrcnt; } s, s1, s2, z; #include "dkstats.h" *************** *** 92,97 **** --- 92,98 ---- static void dinfo(int, int); static void getinfo(struct Info *, enum state); static void putint(int, int, int, int); + static void putuint64(u_int64_t, int, int, int); static void putfloat(double, int, int, int, int, int); static int ucount(void); *************** *** 308,314 **** showkre(void) { float f1, f2; ! int psiz, inttotal; int i, l, c; static int failcnt = 0, first_run = 0; --- 309,316 ---- showkre(void) { float f1, f2; ! int psiz; ! u_int64_t inttotal, intcnt; int i, l, c; static int failcnt = 0, first_run = 0; *************** *** 351,362 **** mvprintw(intrloc[i], INTSCOL + 9, "%-8.8s", intrname[i]); } ! X(intrcnt); ! l = (int)((float)s.intrcnt[i]/etime + 0.5); ! inttotal += l; ! putint(l, intrloc[i], INTSCOL, 8); } ! putint(inttotal, INTSROW + 1, INTSCOL, 8); Z(ncs_goodhits); Z(ncs_badhits); Z(ncs_miss); Z(ncs_long); Z(ncs_pass2); Z(ncs_2passes); s.nchcount = nchtotal.ncs_goodhits + nchtotal.ncs_badhits + --- 353,367 ---- mvprintw(intrloc[i], INTSCOL + 9, "%-8.8s", intrname[i]); } ! t = intcnt = s.intrcnt[i]; ! s.intrcnt[i] -= s1.intrcnt[i]; ! if (state == TIME) ! s1.intrcnt[i] = intcnt; ! intcnt = (u_int64_t)((float)s.intrcnt[i]/etime + 0.5); ! inttotal += intcnt; ! putuint64(intcnt, intrloc[i], INTSCOL, 8); } ! putuint64(inttotal, INTSROW + 1, INTSCOL, 8); Z(ncs_goodhits); Z(ncs_badhits); Z(ncs_miss); Z(ncs_long); Z(ncs_pass2); Z(ncs_2passes); s.nchcount = nchtotal.ncs_goodhits + nchtotal.ncs_badhits + *************** *** 557,562 **** --- 562,587 ---- } static void + putuint64(u_int64_t n, int l, int c, int w) + { + char b[128]; + + move(l, c); + if (n == 0) { + while (w-- > 0) + addch(' '); + return; + } + snprintf(b, sizeof b, "%*llu", w, n); + if (strlen(b) > w) { + while (w-- > 0) + addch('*'); + return; + } + addstr(b); + } + + static void putfloat(double f, int l, int c, int w, int d, int nz) { char b[128]; *************** *** 594,601 **** mib[2] = KERN_INTRCNT_CNT; mib[3] = i; size = sizeof(s->intrcnt[i]); ! if (sysctl(mib, 4, &s->intrcnt[i], &size, NULL, 0) < 0) s->intrcnt[i] = 0; } size = sizeof(s->time); --- 619,627 ---- mib[2] = KERN_INTRCNT_CNT; mib[3] = i; size = sizeof(s->intrcnt[i]); ! if (sysctl(mib, 4, &s->intrcnt[i], &size, NULL, 0) < 0) { s->intrcnt[i] = 0; + } } size = sizeof(s->time); *************** *** 627,633 **** allocinfo(struct Info *s) { ! s->intrcnt = (int *) malloc(nintr * sizeof(int)); if (s->intrcnt == NULL) errx(2, "out of memory"); } --- 653,659 ---- allocinfo(struct Info *s) { ! s->intrcnt = (u_quad_t *) malloc(nintr * sizeof(u_quad_t)); if (s->intrcnt == NULL) errx(2, "out of memory"); } *************** *** 635,645 **** static void copyinfo(struct Info *from, struct Info *to) { ! int *intrcnt; intrcnt = to->intrcnt; *to = *from; ! bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (int)); } static void --- 661,671 ---- static void copyinfo(struct Info *from, struct Info *to) { ! u_quad_t *intrcnt; intrcnt = to->intrcnt; *to = *from; ! bcopy(from->intrcnt, to->intrcnt = intrcnt, nintr * sizeof (u_quad_t)); } static void