257 lines
9.7 KiB
Text
257 lines
9.7 KiB
Text
$NetBSD: patch-aa,v 1.11 2013/09/10 14:45:05 joerg Exp $
|
|
|
|
--- xuvmstat.c.orig 2005-09-09 13:38:48.000000000 +0000
|
|
+++ xuvmstat.c
|
|
@@ -24,6 +24,7 @@
|
|
* xuvmstat.c
|
|
*/
|
|
|
|
+#include <err.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
@@ -40,19 +41,19 @@
|
|
|
|
#include "libcdcx.h"
|
|
|
|
-void get_uvmexp __P((struct uvmexp *));
|
|
+void get_uvmexp __P((struct uvmexp_sysctl *));
|
|
void redraw __P((struct xdpy *, Window, GC, int));
|
|
|
|
|
|
u_long black, white, red, green, blue, magenta, orange, purple;
|
|
XFontStruct *fnt_fixed, *fnt_8x13bold;
|
|
-struct uvmexp cexp, oexp; /* current, old */
|
|
+struct uvmexp_sysctl curexp, oexp; /* current, old */
|
|
struct timeval tv, otv;
|
|
struct graph *gp_faults, *gp_traps, *gp_intrs, *gp_ctx;
|
|
|
|
#define WIDTH 300
|
|
|
|
-main(argc, argv)
|
|
+int main(argc, argv)
|
|
|
|
int argc;
|
|
char **argv;
|
|
@@ -100,7 +101,7 @@ char **argv;
|
|
XMapRaised(xdpy.dpy, win);
|
|
XFlush(xdpy.dpy);
|
|
|
|
- get_uvmexp(&cexp);
|
|
+ get_uvmexp(&curexp);
|
|
gettimeofday(&tv, NULL);
|
|
get_uvmexp(&oexp);
|
|
gettimeofday(&otv, NULL);
|
|
@@ -135,8 +136,8 @@ char **argv;
|
|
if (retval == 0) {
|
|
timeradd(&now, &incr, &ping);
|
|
otv = tv;
|
|
- oexp = cexp;
|
|
- get_uvmexp(&cexp);
|
|
+ oexp = curexp;
|
|
+ get_uvmexp(&curexp);
|
|
gettimeofday(&tv, NULL);
|
|
/* NEW GRAPH DATA HERE */
|
|
|
|
@@ -185,8 +186,8 @@ int was_timeout;
|
|
y += 5;
|
|
|
|
XSetFont(xdpy->dpy, gc, fnt_fixed->fid);
|
|
- snprintf(buf, sizeof(buf),"The UVM system manages %d %d-byte pages",
|
|
- cexp.npages, cexp.pagesize);
|
|
+ snprintf(buf, sizeof(buf),"The UVM system manages %jd %jd-byte pages",
|
|
+ (intmax_t)curexp.npages, (intmax_t)curexp.pagesize);
|
|
XDrawImageString(xdpy->dpy, win, gc, 5, get_fontheight(fnt_fixed) + y,
|
|
buf, strlen(buf));
|
|
y += get_fontheight(fnt_fixed) + 5;
|
|
@@ -205,12 +206,12 @@ int was_timeout;
|
|
colors[4] = purple;
|
|
}
|
|
|
|
- vals[0] = cexp.active;
|
|
- vals[1] = cexp.inactive;
|
|
- vals[2] = cexp.free;
|
|
- vals[3] = cexp.wired;
|
|
- vals[4] = cexp.npages - (vals[0]+vals[1]+vals[2]+vals[3]);
|
|
- y = draw_barbox(xdpy, win, gc, fnt_fixed, 5, 295, y, 5, cexp.npages, names,
|
|
+ vals[0] = curexp.active;
|
|
+ vals[1] = curexp.inactive;
|
|
+ vals[2] = curexp.free;
|
|
+ vals[3] = curexp.wired;
|
|
+ vals[4] = curexp.npages - (vals[0]+vals[1]+vals[2]+vals[3]);
|
|
+ y = draw_barbox(xdpy, win, gc, fnt_fixed, 5, 295, y, 5, curexp.npages, names,
|
|
vals, colors, white);
|
|
}
|
|
|
|
@@ -229,12 +230,12 @@ int was_timeout;
|
|
colors[4] = purple;
|
|
}
|
|
|
|
- vals[0] = cexp.filepages;
|
|
- vals[1] = cexp.anonpages;
|
|
- vals[2] = cexp.execpages;
|
|
- vals[3] = cexp.free;
|
|
- vals[4] = cexp.npages - (vals[0]+vals[1]+vals[2]+vals[3]);
|
|
- y = draw_barbox(xdpy, win, gc, fnt_fixed, 5, 295, y, 5, cexp.npages, names,
|
|
+ vals[0] = curexp.filepages;
|
|
+ vals[1] = curexp.anonpages;
|
|
+ vals[2] = curexp.execpages;
|
|
+ vals[3] = curexp.free;
|
|
+ vals[4] = curexp.npages - (vals[0]+vals[1]+vals[2]+vals[3]);
|
|
+ y = draw_barbox(xdpy, win, gc, fnt_fixed, 5, 295, y, 5, curexp.npages, names,
|
|
vals, colors, white);
|
|
}
|
|
|
|
@@ -245,11 +246,11 @@ int was_timeout;
|
|
u_long vals[3];
|
|
u_long colors[3];
|
|
|
|
- vals[0] = cexp.freemin; colors[0] = black;
|
|
- vals[1] = cexp.freetarg; colors[1] = black;
|
|
- vals[2] = cexp.free; colors[2] = green;
|
|
+ vals[0] = curexp.freemin; colors[0] = black;
|
|
+ vals[1] = curexp.freetarg; colors[1] = black;
|
|
+ vals[2] = curexp.free; colors[2] = green;
|
|
|
|
- y = draw_barlvl(xdpy, win, gc, fnt_fixed, 5, 295, y, 3, cexp.npages, names,
|
|
+ y = draw_barlvl(xdpy, win, gc, fnt_fixed, 5, 295, y, 3, curexp.npages, names,
|
|
vals, colors, white);
|
|
}
|
|
|
|
@@ -260,10 +261,10 @@ int was_timeout;
|
|
u_long vals[2];
|
|
u_long colors[2];
|
|
|
|
- vals[0] = cexp.inactarg; colors[0] = black;
|
|
- vals[1] = cexp.inactive; colors[1] = blue;
|
|
+ vals[0] = curexp.inactarg; colors[0] = black;
|
|
+ vals[1] = curexp.inactive; colors[1] = blue;
|
|
|
|
- y = draw_barlvl(xdpy, win, gc, fnt_fixed, 5, 295, y, 2, cexp.npages, names,
|
|
+ y = draw_barlvl(xdpy, win, gc, fnt_fixed, 5, 295, y, 2, curexp.npages, names,
|
|
vals, colors, white);
|
|
}
|
|
|
|
@@ -274,10 +275,10 @@ int was_timeout;
|
|
u_long vals[2];
|
|
u_long colors[2];
|
|
|
|
- vals[0] = cexp.wiredmax; colors[0] = black;
|
|
- vals[1] = cexp.wired; colors[1] = orange;
|
|
+ vals[0] = curexp.wiredmax; colors[0] = black;
|
|
+ vals[1] = curexp.wired; colors[1] = orange;
|
|
|
|
- y = draw_barlvl(xdpy, win, gc, fnt_fixed, 5, 295, y, 2, cexp.npages, names,
|
|
+ y = draw_barlvl(xdpy, win, gc, fnt_fixed, 5, 295, y, 2, curexp.npages, names,
|
|
vals, colors, white);
|
|
}
|
|
|
|
@@ -289,15 +290,15 @@ int was_timeout;
|
|
if (init == 0) {
|
|
static char *names[] = { "faults", "anon", "ancow", "obj",
|
|
"copy", "zero" };
|
|
- static int *before[6], *after[6];
|
|
+ static int64_t *before[6], *after[6];
|
|
static u_long color[6];
|
|
init = 1;
|
|
- before[0] = &oexp.faults; after[0] = &cexp.faults; color[0] = black;
|
|
- before[1] = &oexp.flt_anon; after[1] = &cexp.flt_anon; color[1] = red;
|
|
- before[2] = &oexp.flt_acow; after[2] = &cexp.flt_acow; color[2] = blue;
|
|
- before[3] = &oexp.flt_obj; after[3] = &cexp.flt_obj; color[3] = green;
|
|
- before[4] = &oexp.flt_prcopy; after[4] = &cexp.flt_prcopy; color[4] = orange;
|
|
- before[5] = &oexp.flt_przero; after[5] = &cexp.flt_przero; color[5] = purple;
|
|
+ before[0] = &oexp.faults; after[0] = &curexp.faults; color[0] = black;
|
|
+ before[1] = &oexp.flt_anon; after[1] = &curexp.flt_anon; color[1] = red;
|
|
+ before[2] = &oexp.flt_acow; after[2] = &curexp.flt_acow; color[2] = blue;
|
|
+ before[3] = &oexp.flt_obj; after[3] = &curexp.flt_obj; color[3] = green;
|
|
+ before[4] = &oexp.flt_prcopy; after[4] = &curexp.flt_prcopy; color[4] = orange;
|
|
+ before[5] = &oexp.flt_przero; after[5] = &curexp.flt_przero; color[5] = purple;
|
|
gp_faults = create_graph(6, "FAULTS", names, before, after, color, white);
|
|
}
|
|
|
|
@@ -311,10 +312,10 @@ int was_timeout;
|
|
|
|
if (init == 0) {
|
|
static char *names[] = { "traps" };
|
|
- static int *before[1], *after[1];
|
|
+ static int64_t *before[1], *after[1];
|
|
static u_long color[1];
|
|
init = 1;
|
|
- before[0] = &oexp.traps; after[0] = &cexp.traps; color[0] = black;
|
|
+ before[0] = &oexp.traps; after[0] = &curexp.traps; color[0] = black;
|
|
gp_traps = create_graph(1, "TRAPS", names, before, after, color, white);
|
|
}
|
|
|
|
@@ -330,12 +331,12 @@ int was_timeout;
|
|
|
|
if (init == 0) {
|
|
static char *names[] = { "intrs", "soft", "syscall" };
|
|
- static int *before[3], *after[3];
|
|
+ static int64_t *before[3], *after[3];
|
|
static u_long color[3];
|
|
init = 1;
|
|
- before[0] = &oexp.intrs; after[0] = &cexp.intrs; color[0] = black;
|
|
- before[1] = &oexp.softs; after[1] = &cexp.softs; color[1] = blue;
|
|
- before[2] = &oexp.syscalls; after[2] = &cexp.syscalls; color[2] = red;
|
|
+ before[0] = &oexp.intrs; after[0] = &curexp.intrs; color[0] = black;
|
|
+ before[1] = &oexp.softs; after[1] = &curexp.softs; color[1] = blue;
|
|
+ before[2] = &oexp.syscalls; after[2] = &curexp.syscalls; color[2] = red;
|
|
gp_intrs = create_graph(3, "INTRS", names, before, after, color, white);
|
|
}
|
|
|
|
@@ -349,12 +350,12 @@ int was_timeout;
|
|
|
|
if (init == 0) {
|
|
static char *names[] = { "cswtch", "swin", "swout" };
|
|
- static int *before[3], *after[3];
|
|
+ static int64_t *before[3], *after[3];
|
|
static u_long color[3];
|
|
init = 1;
|
|
- before[0] = &oexp.swtch; after[0] = &cexp.swtch; color[0] = black;
|
|
- before[1] = &oexp.swapins; after[1] = &cexp.swapins; color[1] = green;
|
|
- before[2] = &oexp.swapouts; after[2] = &cexp.swapouts; color[2] = red;
|
|
+ before[0] = &oexp.swtch; after[0] = &curexp.swtch; color[0] = black;
|
|
+ before[1] = &oexp.swapins; after[1] = &curexp.swapins; color[1] = green;
|
|
+ before[2] = &oexp.swapouts; after[2] = &curexp.swapouts; color[2] = red;
|
|
gp_ctx = create_graph(3, "SWITCH/SWAP", names, before, after, color, white);
|
|
}
|
|
|
|
@@ -372,26 +373,31 @@ int was_timeout;
|
|
buf, strlen(buf));
|
|
y += get_fontheight(fnt_fixed) + 5;
|
|
|
|
+#if __NetBSD_Version__ >= 599002100
|
|
+ snprintf(buf, sizeof(buf), " woke=%jd, revs=%jd",
|
|
+ (intmax_t)curexp.pdwoke, (intmax_t)curexp.pdrevs);
|
|
+#else
|
|
snprintf(buf, sizeof(buf), " woke=%d, revs=%d, swout=%d",
|
|
- cexp.pdwoke, cexp.pdrevs, cexp.pdswout);
|
|
+ curexp.pdwoke, curexp.pdrevs, curexp.pdswout);
|
|
+#endif
|
|
XDrawImageString(xdpy->dpy, win, gc, 5, get_fontheight(fnt_fixed) + y,
|
|
buf, strlen(buf));
|
|
y += get_fontheight(fnt_fixed) + 1;
|
|
|
|
- snprintf(buf, sizeof(buf), " scans=%d, anon_scans=%d, obj_scans=%d",
|
|
- cexp.pdscans, cexp.pdanscan, cexp.pdobscan);
|
|
+ snprintf(buf, sizeof(buf), " scans=%jd, anon_scans=%jd, obj_scans=%jd",
|
|
+ (intmax_t)curexp.pdscans, (intmax_t)curexp.pdanscan, (intmax_t)curexp.pdobscan);
|
|
XDrawImageString(xdpy->dpy, win, gc, 5, get_fontheight(fnt_fixed) + y,
|
|
buf, strlen(buf));
|
|
y += get_fontheight(fnt_fixed) + 1;
|
|
|
|
- snprintf(buf, sizeof(buf), " busy=%d, freed=%d, pending=%d",
|
|
- cexp.pdbusy, cexp.pdfreed, cexp.pdpending);
|
|
+ snprintf(buf, sizeof(buf), " busy=%jd, freed=%jd, pending=%jd",
|
|
+ (intmax_t)curexp.pdbusy, (intmax_t)curexp.pdfreed, (intmax_t)curexp.pdpending);
|
|
XDrawImageString(xdpy->dpy, win, gc, 5, get_fontheight(fnt_fixed) + y,
|
|
buf, strlen(buf));
|
|
y += get_fontheight(fnt_fixed) + 1;
|
|
|
|
- snprintf(buf, sizeof(buf), " reactivate=%d, deactivate=%d, pageouts=%d",
|
|
- cexp.pdreact, cexp.pddeact, cexp.pdpageouts);
|
|
+ snprintf(buf, sizeof(buf), " reactivate=%jd, deactivate=%jd, pageouts=%jd",
|
|
+ (intmax_t)curexp.pdreact, (intmax_t)curexp.pddeact, (intmax_t)curexp.pdpageouts);
|
|
XDrawImageString(xdpy->dpy, win, gc, 5, get_fontheight(fnt_fixed) + y,
|
|
buf, strlen(buf));
|
|
y += get_fontheight(fnt_fixed) + 1;
|