summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-09-12 15:59:36 +0000
committerderaadt <deraadt@openbsd.org>2015-09-12 15:59:36 +0000
commitf0a5b740cf9cc29d720b8728ca99cd8e0a63f994 (patch)
treef0ac21bd823d6601e06749826a7a5a61bb320dd2
parentmark up arguments individually and drop redundant .Bk (diff)
downloadwireguard-openbsd-f0a5b740cf9cc29d720b8728ca99cd8e0a63f994.tar.xz
wireguard-openbsd-f0a5b740cf9cc29d720b8728ca99cd8e0a63f994.zip
use sysctl() to get FSCALE value; ok guenther
-rw-r--r--usr.bin/systat/pigs.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/usr.bin/systat/pigs.c b/usr.bin/systat/pigs.c
index 515d9f22409..f9af1b0e111 100644
--- a/usr.bin/systat/pigs.c
+++ b/usr.bin/systat/pigs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pigs.c,v 1.29 2015/01/16 00:03:37 deraadt Exp $ */
+/* $OpenBSD: pigs.c,v 1.30 2015/09/12 15:59:36 deraadt Exp $ */
/* $NetBSD: pigs.c,v 1.3 1995/04/29 05:54:50 cgd Exp $ */
/*-
@@ -98,23 +98,21 @@ field_view views_pg[] = {
{NULL, NULL, 0, NULL}
};
+int fscale;
-#ifdef FSCALE
-# define FIXED_LOADAVG FSCALE
-# define FIXED_PCTCPU FSCALE
-#endif
+#define pctdouble(p) ((double)(p) / fscale)
-#ifdef FIXED_PCTCPU
- typedef long pctcpu;
-# define pctdouble(p) ((double)(p) / FIXED_PCTCPU)
-#else
-typedef double pctcpu;
-# define pctdouble(p) (p)
-#endif
+typedef long pctcpu;
int
select_pg(void)
{
+ int mib[] = { CTL_KERN, KERN_FSCALE };
+ size_t size = sizeof(fscale);
+
+ if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
+ &fscale, &size, NULL, 0) < 0)
+ return (-1);
num_disp = pigs_cnt;
return (0);
}