Fix cpu graph on single core.

(pushed upstream)
from Tobias Ulmer <tobiasu at tmux dot org>, thanks!

Use the new APM_ARCHS.
This commit is contained in:
ajacoutot 2010-03-21 11:37:17 +00:00
parent 12bea17ac0
commit 5480e81690
2 changed files with 30 additions and 1 deletions

View File

@ -1,8 +1,11 @@
# $OpenBSD: Makefile,v 1.1.1.1 2010/01/09 13:55:15 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.2 2010/03/21 11:37:17 ajacoutot Exp $
ONLY_FOR_ARCHS= ${APM_ARCHS}
COMMENT= simple system monitor bar
DISTNAME= xstatbar-0.3
PKGNAME= ${DISTNAME}p0
CATEGORIES= sysutils x11

View File

@ -0,0 +1,26 @@
$OpenBSD: patch-stats_c,v 1.1 2010/03/21 11:37:17 ajacoutot Exp $
Fix cpu graph on single cores:
sizeof(long) != sizeof(int64_t) on i386
--- stats.c.orig Thu Jan 7 18:08:14 2010
+++ stats.c Mon Feb 1 08:29:25 2010
@@ -456,9 +456,16 @@ sysinfo_update()
err(1, "sysinfo update: KERN.CPTIME2.%d failed", cpu);
}
} else {
+ int i;
+ long cpu_raw_tmp[CPUSTATES];
+ size = sizeof(cpu_raw_tmp);
mib_cpus[1] = KERN_CPTIME;
- if (sysctl(mib_cpus, 2, sysinfo.cpu_raw[0][cur], &size, NULL, 0) < 0)
- err(1, "sysinfo update: KERN.CPTIME2 failed");
+
+ if (sysctl(mib_cpus, 2, cpu_raw_tmp, &size, NULL, 0) < 0)
+ err(1, "sysinfo update: KERN.CPTIME failed");
+
+ for (i = 0; i < CPUSTATES; i++)
+ sysinfo.cpu_raw[0][cur][i] = cpu_raw_tmp[i];
}
/* convert ticks to percentages */