From 49641cc3639909e76b6798041aa31d0169aea654 Mon Sep 17 00:00:00 2001 From: Jasper Lievisse Adriaanse Date: Thu, 16 Jun 2011 12:57:43 +0200 Subject: 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. --- sysdeps/openbsd/cpu.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'sysdeps') 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; -- cgit v1.2.1