head 1.2; access; symbols pkgsrc-2013Q2:1.2.0.24 pkgsrc-2013Q2-base:1.2 pkgsrc-2012Q4:1.2.0.22 pkgsrc-2012Q4-base:1.2 pkgsrc-2011Q4:1.2.0.20 pkgsrc-2011Q4-base:1.2 pkgsrc-2011Q2:1.2.0.18 pkgsrc-2011Q2-base:1.2 pkgsrc-2009Q4:1.2.0.16 pkgsrc-2009Q4-base:1.2 pkgsrc-2008Q4:1.2.0.14 pkgsrc-2008Q4-base:1.2 pkgsrc-2008Q3:1.2.0.12 pkgsrc-2008Q3-base:1.2 cube-native-xorg:1.2.0.10 cube-native-xorg-base:1.2 pkgsrc-2008Q2:1.2.0.8 pkgsrc-2008Q2-base:1.2 pkgsrc-2008Q1:1.2.0.6 pkgsrc-2008Q1-base:1.2 pkgsrc-2007Q4:1.2.0.4 pkgsrc-2007Q4-base:1.2 pkgsrc-2007Q3:1.2.0.2 pkgsrc-2007Q3-base:1.2 pkgsrc-2007Q2:1.1.0.12 pkgsrc-2007Q2-base:1.1 pkgsrc-2007Q1:1.1.0.10 pkgsrc-2007Q1-base:1.1 pkgsrc-2006Q4:1.1.0.8 pkgsrc-2006Q4-base:1.1 pkgsrc-2006Q3:1.1.0.6 pkgsrc-2006Q3-base:1.1 pkgsrc-2006Q2:1.1.0.4 pkgsrc-2006Q2-base:1.1 pkgsrc-2006Q1:1.1.0.2 pkgsrc-2006Q1-base:1.1; locks; strict; comment @# @; 1.2 date 2007.09.20.21.12.20; author wiz; state dead; branches; next 1.1; 1.1 date 2006.02.28.23.48.11; author joerg; state Exp; branches; next ; desc @@ 1.2 log @Rename libgtop2 to libgtop, to match upstream name. @ text @$NetBSD: patch-ae,v 1.1 2006/02/28 23:48:11 joerg Exp $ --- sysdeps/freebsd/cpu.c.orig 2005-07-08 19:49:56.000000000 +0000 +++ sysdeps/freebsd/cpu.c @@@@ -27,16 +27,73 @@@@ #include -#ifdef __NetBSD__ -#include -#endif - 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); +#if defined(__DragonFly__) +#include + +/* Init function. */ + +void +glibtop_init_cpu_p (glibtop *server) +{ + server->sysdeps.cpu = _glibtop_sysdeps_cpu; +} + +/* Provides information about cpu usage. */ +void +glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf) +{ + struct kinfo_cputime cp_time; + int hz; + + glibtop_init_p (server, (1L << GLIBTOP_SYSDEPS_CPU), 0); + + memset (buf, 0, sizeof (glibtop_cpu)); + + /* If this fails, the module was not setuped. */ + if (server->sysdeps.cpu == 0) + return; + + if (kinfo_get_sched_cputime(&cp_time)) { + glibtop_warn_io_r (server, "kinfo_get_sched_cputime"); + return; + } + if (kinfo_get_sched_hz(&hz)) { + glibtop_warn_io_r (server, "kinfo_get_sched hz"); + return; + } + /* set user time */ + buf->user = cp_time.cp_user; + /* set nice time */ + buf->nice = cp_time.cp_nice; + /* set sys time */ + buf->sys = cp_time.cp_sys; + /* set idle time */ + buf->idle = cp_time.cp_idle; + /* set iowait (really just interrupt) time */ + buf->iowait = cp_time.cp_idle; + + /* set frequency */ + buf->frequency = hz; + /* set total */ + buf->total = cp_time.cp_user + cp_time.cp_sys + cp_time.cp_nice + + cp_time.cp_idle; + + /* Set the flags last. */ + buf->flags = _glibtop_sysdeps_cpu; +} + +#else + +#ifdef __NetBSD__ +#include +#endif + #ifndef KERN_CP_TIME /* nlist structure for kernel access */ static struct nlist nlst [] = { @@@@ -141,3 +198,4 @@@@ glibtop_get_cpu_p (glibtop *server, glib /* Set the flags last. */ buf->flags = _glibtop_sysdeps_cpu; } +#endif @ 1.1 log @Add support for DragonFly. There are some minor issues left, e.g. installing of the backend daemon as kmem, but I don't want to make it the default, since almost all operations work without it. @ text @d1 1 a1 1 $NetBSD$ @