- slightly adjust cpu usage retrieval.

this still doesn't work on i386 (32 bit arches?), whereas it does work
  fine on amd64, mips64el and sparc64..
This commit is contained in:
jasper 2011-05-31 13:47:56 +00:00
parent 89ff636d32
commit 72430a5fe7
2 changed files with 7 additions and 13 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.69 2011/05/26 17:47:24 jasper Exp $
# $OpenBSD: Makefile,v 1.70 2011/05/31 13:47:56 jasper Exp $
COMMENT= portable library for obtaining system information
@ -6,7 +6,7 @@ GNOME_VERSION= 2.28.3
GNOME_PROJECT= libgtop
PKGNAME= libgtop2-${VERSION}
REVISION= 12
REVISION= 13
SHARED_LIBS= gtop-2.0 9.0 # .9.0

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cpu.c,v 1.4 2011/05/24 12:37:15 jasper Exp $ */
/* $OpenBSD: cpu.c,v 1.5 2011/05/31 13:47:56 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;
@ -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;