Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F136915097
D13105.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D13105.diff
View Options
Index: head/usr.bin/systat/Makefile
===================================================================
--- head/usr.bin/systat/Makefile
+++ head/usr.bin/systat/Makefile
@@ -16,6 +16,6 @@
WARNS?= 1
-LIBADD= ncursesw m devstat kvm
+LIBADD= ncursesw m devstat kvm util
.include <bsd.prog.mk>
Index: head/usr.bin/systat/vmstat.c
===================================================================
--- head/usr.bin/systat/vmstat.c
+++ head/usr.bin/systat/vmstat.c
@@ -57,6 +57,7 @@
#include <err.h>
#include <errno.h>
#include <langinfo.h>
+#include <libutil.h>
#include <nlist.h>
#include <paths.h>
#include <signal.h>
@@ -131,6 +132,7 @@
#define oldnchtotal s1.nchstats
static enum state { BOOT, TIME, RUN } state = TIME;
+enum divisor { IEC = 0, SI = HN_DIVISOR_1000 };
static void allocinfo(struct Info *);
static void copyinfo(struct Info *, struct Info *);
@@ -138,6 +140,8 @@
static void dinfo(int, int, struct statinfo *, struct statinfo *);
static void getinfo(struct Info *);
static void putint(int, int, int, int);
+static void putuint64(uint64_t, int, int, int);
+static void do_putuint64(uint64_t, int, int, int, int);
static void putfloat(double, int, int, int, int, int);
static void putlongdouble(long double, int, int, int, int, int);
static int ucount(void);
@@ -491,15 +495,15 @@
putfloat(100.0 * s.v_kmem_map_size / kmem_size,
STATROW + 1, STATCOL + 22, 2, 0, 1);
- putint(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 4, 7);
- putint(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 12, 7);
- putint(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 20, 8);
- putint(pgtokb(total.t_avmshr), MEMROW + 2, MEMCOL + 29, 8);
- putint(pgtokb(total.t_rm), MEMROW + 3, MEMCOL + 4, 7);
- putint(pgtokb(total.t_rmshr), MEMROW + 3, MEMCOL + 12, 7);
- putint(pgtokb(total.t_vm), MEMROW + 3, MEMCOL + 20, 8);
- putint(pgtokb(total.t_vmshr), MEMROW + 3, MEMCOL + 29, 8);
- putint(pgtokb(total.t_free), MEMROW + 2, MEMCOL + 38, 7);
+ putuint64(pgtokb(total.t_arm), MEMROW + 2, MEMCOL + 4, 7);
+ putuint64(pgtokb(total.t_armshr), MEMROW + 2, MEMCOL + 12, 7);
+ putuint64(pgtokb(total.t_avm), MEMROW + 2, MEMCOL + 20, 8);
+ putuint64(pgtokb(total.t_avmshr), MEMROW + 2, MEMCOL + 29, 8);
+ putuint64(pgtokb(total.t_rm), MEMROW + 3, MEMCOL + 4, 7);
+ putuint64(pgtokb(total.t_rmshr), MEMROW + 3, MEMCOL + 12, 7);
+ putuint64(pgtokb(total.t_vm), MEMROW + 3, MEMCOL + 20, 8);
+ putuint64(pgtokb(total.t_vmshr), MEMROW + 3, MEMCOL + 29, 8);
+ putuint64(pgtokb(total.t_free), MEMROW + 2, MEMCOL + 38, 7);
putint(total.t_rq - 1, PROCSROW + 2, PROCSCOL, 3);
putint(total.t_pw, PROCSROW + 2, PROCSCOL + 4, 3);
putint(total.t_dw, PROCSROW + 2, PROCSCOL + 8, 3);
@@ -518,13 +522,13 @@
PUTRATE(v_pdwakeups, VMSTATROW + 9, VMSTATCOL, 8);
PUTRATE(v_pdpages, VMSTATROW + 10, VMSTATCOL, 8);
PUTRATE(v_intrans, VMSTATROW + 11, VMSTATCOL, 8);
- putint(pgtokb(s.v_wire_count), VMSTATROW + 12, VMSTATCOL, 8);
- putint(pgtokb(s.v_active_count), VMSTATROW + 13, VMSTATCOL, 8);
- putint(pgtokb(s.v_inactive_count), VMSTATROW + 14, VMSTATCOL, 8);
- putint(pgtokb(s.v_laundry_count), VMSTATROW + 15, VMSTATCOL, 8);
- putint(pgtokb(s.v_free_count), VMSTATROW + 16, VMSTATCOL, 8);
+ putuint64(pgtokb(s.v_wire_count), VMSTATROW + 12, VMSTATCOL, 8);
+ putuint64(pgtokb(s.v_active_count), VMSTATROW + 13, VMSTATCOL, 8);
+ putuint64(pgtokb(s.v_inactive_count), VMSTATROW + 14, VMSTATCOL, 8);
+ putuint64(pgtokb(s.v_laundry_count), VMSTATROW + 15, VMSTATCOL, 8);
+ putuint64(pgtokb(s.v_free_count), VMSTATROW + 16, VMSTATCOL, 8);
if (LINES - 1 > VMSTATROW + 17)
- putint(s.bufspace / 1024, VMSTATROW + 17, VMSTATCOL, 8);
+ putuint64(s.bufspace / 1024, VMSTATROW + 17, VMSTATCOL, 8);
PUTRATE(v_vnodein, PAGEROW + 2, PAGECOL + 6, 5);
PUTRATE(v_vnodeout, PAGEROW + 2, PAGECOL + 12, 5);
PUTRATE(v_swapin, PAGEROW + 2, PAGECOL + 19, 5);
@@ -666,8 +670,23 @@
static void
putint(int n, int l, int lc, int w)
{
+
+ do_putuint64(n, l, lc, w, SI);
+}
+
+static void
+putuint64(uint64_t n, int l, int lc, int w)
+{
+
+ do_putuint64(n, l, lc, w, IEC);
+}
+
+static void
+do_putuint64(uint64_t n, int l, int lc, int w, int div)
+{
int snr;
char b[128];
+ char buf[128];
move(l, lc);
#ifdef DEBUG
@@ -680,11 +699,12 @@
addch(' ');
return;
}
- snr = snprintf(b, sizeof(b), "%*d", w, n);
- if (snr != w)
- snr = snprintf(b, sizeof(b), "%*dk", w - 1, n / 1000);
- if (snr != w)
- snr = snprintf(b, sizeof(b), "%*dM", w - 1, n / 1000000);
+ snr = snprintf(b, sizeof(b), "%*jd", w, (uintmax_t)n);
+ if (snr != w) {
+ humanize_number(buf, w, n, "", HN_AUTOSCALE,
+ HN_NOSPACE | HN_DECIMAL | div);
+ snr = snprintf(b, sizeof(b), "%*s", w, buf);
+ }
if (snr != w) {
while (w-- > 0)
addch('*');
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 21, 3:33 PM (16 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25773765
Default Alt Text
D13105.diff (4 KB)
Attached To
Mode
D13105: systat: use and correctly display 64bit counters
Attached
Detach File
Event Timeline
Log In to Comment