summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@humppa.nl>2011-06-16 12:57:43 +0200
committerJasper Lievisse Adriaanse <jasper@humppa.nl>2011-06-16 12:57:43 +0200
commit49641cc3639909e76b6798041aa31d0169aea654 (patch)
tree6d97a690b505608d8decfe7da6f6eb038c784678 /sysdeps
parent46706961ac8dcb27a063506b4a178419bb1fd1e3 (diff)
downloadlibgtop-49641cc3639909e76b6798041aa31d0169aea654.tar.gz
Make CPU load retrieval work.
It would sort of work on 64 bits arches, and not work at all no 32 bit arches. Now works on both, and take CP_INTR correctly into account.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/openbsd/cpu.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/sysdeps/openbsd/cpu.c b/sysdeps/openbsd/cpu.c
index a018b726..81b4cace 100644
--- a/sysdeps/openbsd/cpu.c
+++ b/sysdeps/openbsd/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.4 2011/05/24 12:37:15 jasper Exp $ */
+/* $OpenBSD: cpu.c,v 1.6 2011/05/31 14:19:18 jasper Exp $ */
/* Copyright (C) 1998 Joshua Sled
This file is part of LibGTop 1.0.
@@ -34,7 +34,7 @@ static const unsigned long _glibtop_sysdeps_cpu =
(1L << GLIBTOP_CPU_TOTAL) + (1L << GLIBTOP_CPU_USER) +
(1L << GLIBTOP_CPU_NICE) + (1L << GLIBTOP_CPU_SYS) +
(1L << GLIBTOP_CPU_IDLE) + (1L << GLIBTOP_CPU_FREQUENCY) +
-(1L << GLIBTOP_CPU_IOWAIT);
+(1L << GLIBTOP_CPU_IRQ);
/* MIB array for sysctl */
static int mib_length=2;
@@ -54,7 +54,7 @@ _glibtop_init_cpu_p (glibtop *server)
void
glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
{
- guint64 cpts [CPUSTATES];
+ gulong cpts [CPUSTATES];
/* sysctl vars*/
struct clockinfo ci;
@@ -89,20 +89,14 @@ glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
buf->sys = cpts [CP_SYS];
/* set idle time */
buf->idle = cpts [CP_IDLE];
- /* set iowait (really just interrupt) time */
- buf->iowait = cpts [CP_INTR];
+ /* set interrupt time */
+ buf->irq = cpts [CP_INTR];
/* set frequency */
- /*
- FIXME -- is hz, tick, profhz or stathz wanted?
- buf->frequency = sysctl("kern.clockrate", ...);
-
- struct clockinfo
- */
buf->frequency = ci.hz;
/* set total */
buf->total = cpts [CP_USER] + cpts [CP_NICE]
- + cpts [CP_SYS] + cpts [CP_IDLE];
+ + cpts [CP_SYS] + cpts [CP_IDLE] + cpts [CP_INTR];
/* Set the flags last. */
buf->flags = _glibtop_sysdeps_cpu;