head 1.8; access; symbols pkgsrc-2026Q1:1.8.0.132 pkgsrc-2026Q1-base:1.8 pkgsrc-2025Q4:1.8.0.130 pkgsrc-2025Q4-base:1.8 pkgsrc-2025Q3:1.8.0.128 pkgsrc-2025Q3-base:1.8 pkgsrc-2025Q2:1.8.0.126 pkgsrc-2025Q2-base:1.8 pkgsrc-2025Q1:1.8.0.124 pkgsrc-2025Q1-base:1.8 pkgsrc-2024Q4:1.8.0.122 pkgsrc-2024Q4-base:1.8 pkgsrc-2024Q3:1.8.0.120 pkgsrc-2024Q3-base:1.8 pkgsrc-2024Q2:1.8.0.118 pkgsrc-2024Q2-base:1.8 pkgsrc-2024Q1:1.8.0.116 pkgsrc-2024Q1-base:1.8 pkgsrc-2023Q4:1.8.0.114 pkgsrc-2023Q4-base:1.8 pkgsrc-2023Q3:1.8.0.112 pkgsrc-2023Q3-base:1.8 pkgsrc-2023Q2:1.8.0.110 pkgsrc-2023Q2-base:1.8 pkgsrc-2023Q1:1.8.0.108 pkgsrc-2023Q1-base:1.8 pkgsrc-2022Q4:1.8.0.106 pkgsrc-2022Q4-base:1.8 pkgsrc-2022Q3:1.8.0.104 pkgsrc-2022Q3-base:1.8 pkgsrc-2022Q2:1.8.0.102 pkgsrc-2022Q2-base:1.8 pkgsrc-2022Q1:1.8.0.100 pkgsrc-2022Q1-base:1.8 pkgsrc-2021Q4:1.8.0.98 pkgsrc-2021Q4-base:1.8 pkgsrc-2021Q3:1.8.0.96 pkgsrc-2021Q3-base:1.8 pkgsrc-2021Q2:1.8.0.94 pkgsrc-2021Q2-base:1.8 pkgsrc-2021Q1:1.8.0.92 pkgsrc-2021Q1-base:1.8 pkgsrc-2020Q4:1.8.0.90 pkgsrc-2020Q4-base:1.8 pkgsrc-2020Q3:1.8.0.88 pkgsrc-2020Q3-base:1.8 pkgsrc-2020Q2:1.8.0.84 pkgsrc-2020Q2-base:1.8 pkgsrc-2020Q1:1.8.0.64 pkgsrc-2020Q1-base:1.8 pkgsrc-2019Q4:1.8.0.86 pkgsrc-2019Q4-base:1.8 pkgsrc-2019Q3:1.8.0.82 pkgsrc-2019Q3-base:1.8 pkgsrc-2019Q2:1.8.0.80 pkgsrc-2019Q2-base:1.8 pkgsrc-2019Q1:1.8.0.78 pkgsrc-2019Q1-base:1.8 pkgsrc-2018Q4:1.8.0.76 pkgsrc-2018Q4-base:1.8 pkgsrc-2018Q3:1.8.0.74 pkgsrc-2018Q3-base:1.8 pkgsrc-2018Q2:1.8.0.72 pkgsrc-2018Q2-base:1.8 pkgsrc-2018Q1:1.8.0.70 pkgsrc-2018Q1-base:1.8 pkgsrc-2017Q4:1.8.0.68 pkgsrc-2017Q4-base:1.8 pkgsrc-2017Q3:1.8.0.66 pkgsrc-2017Q3-base:1.8 pkgsrc-2017Q2:1.8.0.62 pkgsrc-2017Q2-base:1.8 pkgsrc-2017Q1:1.8.0.60 pkgsrc-2017Q1-base:1.8 pkgsrc-2016Q4:1.8.0.58 pkgsrc-2016Q4-base:1.8 pkgsrc-2016Q3:1.8.0.56 pkgsrc-2016Q3-base:1.8 pkgsrc-2016Q2:1.8.0.54 pkgsrc-2016Q2-base:1.8 pkgsrc-2016Q1:1.8.0.52 pkgsrc-2016Q1-base:1.8 pkgsrc-2015Q4:1.8.0.50 pkgsrc-2015Q4-base:1.8 pkgsrc-2015Q3:1.8.0.48 pkgsrc-2015Q3-base:1.8 pkgsrc-2015Q2:1.8.0.46 pkgsrc-2015Q2-base:1.8 pkgsrc-2015Q1:1.8.0.44 pkgsrc-2015Q1-base:1.8 pkgsrc-2014Q4:1.8.0.42 pkgsrc-2014Q4-base:1.8 pkgsrc-2014Q3:1.8.0.40 pkgsrc-2014Q3-base:1.8 pkgsrc-2014Q2:1.8.0.38 pkgsrc-2014Q2-base:1.8 pkgsrc-2014Q1:1.8.0.36 pkgsrc-2014Q1-base:1.8 pkgsrc-2013Q4:1.8.0.34 pkgsrc-2013Q4-base:1.8 pkgsrc-2013Q3:1.8.0.32 pkgsrc-2013Q3-base:1.8 pkgsrc-2013Q2:1.8.0.30 pkgsrc-2013Q2-base:1.8 pkgsrc-2013Q1:1.8.0.28 pkgsrc-2013Q1-base:1.8 pkgsrc-2012Q4:1.8.0.26 pkgsrc-2012Q4-base:1.8 pkgsrc-2012Q3:1.8.0.24 pkgsrc-2012Q3-base:1.8 pkgsrc-2012Q2:1.8.0.22 pkgsrc-2012Q2-base:1.8 pkgsrc-2012Q1:1.8.0.20 pkgsrc-2012Q1-base:1.8 pkgsrc-2011Q4:1.8.0.18 pkgsrc-2011Q4-base:1.8 pkgsrc-2011Q3:1.8.0.16 pkgsrc-2011Q3-base:1.8 pkgsrc-2011Q2:1.8.0.14 pkgsrc-2011Q2-base:1.8 pkgsrc-2011Q1:1.8.0.12 pkgsrc-2011Q1-base:1.8 pkgsrc-2010Q4:1.8.0.10 pkgsrc-2010Q4-base:1.8 pkgsrc-2010Q3:1.8.0.8 pkgsrc-2010Q3-base:1.8 pkgsrc-2010Q2:1.8.0.6 pkgsrc-2010Q2-base:1.8 pkgsrc-2010Q1:1.8.0.4 pkgsrc-2010Q1-base:1.8 pkgsrc-2009Q4:1.8.0.2 pkgsrc-2009Q4-base:1.8 pkgsrc-2008Q4:1.6.0.12 pkgsrc-2008Q4-base:1.6 pkgsrc-2008Q3:1.6.0.10 pkgsrc-2008Q3-base:1.6 cube-native-xorg:1.6.0.8 cube-native-xorg-base:1.6 pkgsrc-2008Q2:1.6.0.6 pkgsrc-2008Q2-base:1.6 pkgsrc-2008Q1:1.6.0.4 pkgsrc-2008Q1-base:1.6 pkgsrc-2007Q4:1.6.0.2 pkgsrc-2007Q4-base:1.6 pkgsrc-2007Q3:1.5.0.2 pkgsrc-2007Q3-base:1.5 pkgsrc-2007Q2:1.4.0.18 pkgsrc-2007Q2-base:1.4 pkgsrc-2007Q1:1.4.0.16 pkgsrc-2007Q1-base:1.4 pkgsrc-2006Q4:1.4.0.14 pkgsrc-2006Q4-base:1.4 pkgsrc-2006Q3:1.4.0.12 pkgsrc-2006Q3-base:1.4 pkgsrc-2006Q2:1.4.0.10 pkgsrc-2006Q2-base:1.4 pkgsrc-2006Q1:1.4.0.8 pkgsrc-2006Q1-base:1.4 pkgsrc-2005Q4:1.4.0.6 pkgsrc-2005Q4-base:1.4 pkgsrc-2005Q3:1.4.0.4 pkgsrc-2005Q3-base:1.4 pkgsrc-2005Q2:1.4.0.2 pkgsrc-2005Q2-base:1.4 pkgsrc-2005Q1:1.3.0.8 pkgsrc-2005Q1-base:1.3 pkgsrc-2004Q4:1.3.0.6 pkgsrc-2004Q4-base:1.3 pkgsrc-2004Q3:1.3.0.4 pkgsrc-2004Q3-base:1.3 pkgsrc-2004Q2:1.3.0.2 pkgsrc-2004Q2-base:1.3 pkgsrc-2004Q1:1.2.0.4 pkgsrc-2004Q1-base:1.2 pkgsrc-2003Q4:1.2.0.2 pkgsrc-2003Q4-base:1.2 buildlink2-base:1.2 pkgsrc-base:1.1.1.2 TNF:1.1.1; locks; strict; comment @# @; 1.8 date 2009.10.30.21.41.20; author wiz; state Exp; branches; next 1.7; 1.7 date 2009.10.30.18.31.41; author tnn; state Exp; branches; next 1.6; 1.6 date 2007.11.05.19.06.04; author drochner; state dead; branches; next 1.5; 1.5 date 2007.09.20.21.12.08; author wiz; state Exp; branches; next 1.4; 1.4 date 2005.05.18.22.02.21; author wiz; state dead; branches; next 1.3; 1.3 date 2004.04.02.12.13.57; author jmmv; state Exp; branches; next 1.2; 1.2 date 98.11.01.23.24.18; author tron; state dead; branches; next 1.1; 1.1 date 98.10.07.13.11.35; author agc; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 98.10.07.13.11.35; author agc; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 2004.04.02.12.10.12; author jmmv; state Exp; branches; next ; desc @@ 1.8 log @Add upstream URL for patch-ae bug report. @ text @$NetBSD: patch-ae,v 1.7 2009/10/30 18:31:41 tnn Exp $ https://bugzilla.gnome.org/show_bug.cgi?id=600172 --- sysdeps/bsd/swap.c.orig 2008-05-24 00:13:21.000000000 +0200 +++ sysdeps/bsd/swap.c @@@@ -195,29 +195,32 @@@@ glibtop_get_swap_p (glibtop *server, gli #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) buf->pagein = vmm.v_swappgsin - swappgsin; buf->pageout = vmm.v_swappgsout - swappgsout; -#else -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) || defined(__OpenBSD__) +#elif defined(__NetBSD__) && (__NetBSD_Version__ >= 599002100) + /* no uvmexp.swap{ins,outs} */ + buf->pagein = 0; + buf->pageout = 0; +#elif defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) || defined(__OpenBSD__) buf->pagein = uvmexp.swapins - swappgsin; buf->pageout = uvmexp.swapouts - swappgsout; #else buf->pagein = vmm.v_swpin - swappgsin; buf->pageout = vmm.v_swpout - swappgsout; #endif -#endif } #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) swappgsin = vmm.v_swappgsin; swappgsout = vmm.v_swappgsout; -#else -#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) || defined(__OpenBSD__) +#elif defined(__NetBSD__) && (__NetBSD_Version__ >= 599002100) + swappgsin = 0; + swappgsout = 0; +#elif defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000) || defined(__OpenBSD__) swappgsin = uvmexp.swapins; swappgsout = uvmexp.swapouts; #else swappgsin = vmm.v_swpin; swappgsout = vmm.v_swpout; #endif -#endif #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) @ 1.7 log @NetBSD-5.99.21 lost struct uvmexp.swap{ins,outs} @ text @d1 3 a3 1 $NetBSD$ @ 1.6 log @update to 2.20.0 This switches to the new gnome-2.20 branch. pkgsrc notes: -System dependant parts were reorganized upstream, in particular there if a subtree for FreeBSD now, and one for the other BSDs. I didn't pull in the DragonFly patches because I can't decide whether to base them on the freebsd or the rest. -I've changed the NetBSD code to use kinfo_proc2 almost completely. Some vm statistics reporting might be less accurate now because some fields in proc2 seem to be unmaintained by the current kernel (eg ixrss). -Also, some libgtop functions might be able to run in the non-privileged part now, but dealing with this would require even more #ifdefs, so we should consider setting up a private subtree as FreeBSD did. -I didn't verify with older NetBSDs; kvm_getproc2() has been in the tree for quite some time so I hope it will just work without the need for excessive "#if __NetBSD_Version__ > t". @ text @d1 1 a1 1 $NetBSD: patch-ae,v 1.5 2007/09/20 21:12:08 wiz Exp $ d3 21 a23 3 --- sysdeps/freebsd/cpu.c.orig 2005-07-08 19:49:56.000000000 +0000 +++ sysdeps/freebsd/cpu.c @@@@ -27,16 +27,73 @@@@ d25 16 a40 1 #include d42 1 a42 9 -#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); a43 69 +#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.5 log @Rename libgtop2 to libgtop, to match upstream name. @ text @d1 1 a1 1 $NetBSD: patch-ae,v 1.1 2006/02/28 23:48:11 joerg Exp $ @ 1.4 log @Remove gnome1 packages except as needed for gnucash. Ok'd by jmmv@@ and rh@@ (gnome 1 maintainers). @ text @d1 1 a1 1 $NetBSD: patch-ae,v 1.3 2004/04/02 12:13:57 jmmv Exp $ d3 1 a3 1 --- sysdeps/freebsd/cpu.c.orig Sun Feb 13 16:47:58 2000 d5 1 a5 1 @@@@ -27,11 +27,16 @@@@ d9 67 d80 1 a80 6 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); +#ifndef KERN_CP_TIME d83 3 a85 28 #ifdef __bsdi__ @@@@ -41,21 +46,27 @@@@ #endif { 0 } }; +#endif /* MIB array for sysctl */ static int mib_length=2; static int mib [] = { CTL_KERN, KERN_CLOCKRATE }; +#ifdef KERN_CP_TIME +static int mib2 [] = { CTL_KERN, KERN_CP_TIME }; +#endif /* Init function. */ void glibtop_init_cpu_p (glibtop *server) { +#ifndef KERN_CP_TIME if (kvm_nlist (server->machine.kd, nlst) < 0) { glibtop_warn_io_r (server, "kvm_nlist (cpu)"); return; } +#endif /* Set this only if kvm_nlist () succeeded. */ server->sysdeps.cpu = _glibtop_sysdeps_cpu; a86 28 @@@@ -65,7 +76,11 @@@@ void glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf) { +#ifdef KERN_CP_TIME + u_int64_t cpts [CPUSTATES]; +#else long cpts [CPUSTATES]; +#endif /* sysctl vars*/ struct clockinfo ci; size_t length; @@@@ -78,11 +93,19 @@@@ if (server->sysdeps.cpu == 0) return; +#ifdef KERN_CP_TIME + length = sizeof (cpts); + if (sysctl (mib2, mib_length, cpts, &length, NULL, 0)) { + glibtop_warn_io_r (server, "sysctl"); + return; + } +#else if (kvm_read (server->machine.kd, nlst [0].n_value, &cpts, sizeof (cpts)) != sizeof (cpts)) { glibtop_warn_io_r (server, "kvm_read (cp_time)"); return; } a87 3 /* Get the clockrate data */ length = sizeof (struct clockinfo); @ 1.3 log @Finish move of libgtop from devel to sysutils, incomplete due to conflicts... So I now see the package was previously here; the reason for the move is to lighten a bit the devel category, which has lots of packages. @ text @d1 1 a1 1 $NetBSD: patch-ae,v 1.8 2001/07/17 11:02:02 wiz Exp $ @ 1.2 log @Move "libgtop" package to "devel" category. @ text @d1 1 a1 1 $NetBSD: patch-ae,v 1.1 1998/10/07 13:11:35 agc Exp $ d3 3 a5 60 Most of this file was taken from the xosview swapinternal.cc file. --- sysdeps/bsd/swap.c 1998/10/06 16:52:26 1.1 +++ sysdeps/bsd/swap.c 1998/10/06 17:02:58 @@@@ -19,6 +19,54 @@@@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Copyright (c) 1995 by Brian Grayson (bgrayson@@ece.utexas.edu) + * + * This code is borrowed HEAVILY from the vmstat source code in the + * NetBSD distribution. As such, the NetBSD copyright claim/disclaimer + * applies to most of this code. The disclaimer, along with the CVS + * header from the version from which this file was created, are included + * below: + * + * Id: swapinternal.cc,v 1.15 1998/05/17 21:34:06 bgrayson Exp + * + * NOTE THAT THIS FILE IS UNDER THE BSD COPYRIGHT, AND NOT GPL! + */ + +/* NetBSD: swap.c,v 1.4 1995/08/31 22:20:19 jtc Exp */ + +/*- + * Copyright (c) 1980, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #include #include #include @@@@ -27,141 +75,151 @@@@ d9 2 a10 53 +#include #include +#include +#include +#ifdef __FreeBSD__ #include +#else +#include +#endif #include +/*--------------------- The remainder of this file is based/borrowed + * from /usr/src/bin/systat/swap.c in the NetBSD + * distribution. Modifications will be + * bracketed by comment markers like these. BCG + */ + +/* + * swapinfo - based on a program of the same name by Kevin Lahey + */ + +/*--------------------- Note: all of these includes were in the + * original source code. I am leaving them + * undisturbed, although it is likely that + * some may be removed, since lots of the swap + * code has been removed. BCG FIXME SOMEDAY + */ + +#include +/*--------------------- It appears buf.h is not needed, and + * causes breakage on FreeBSD. */ +/*#include */ +#include +#include +#include +#include +#include +#include + +#include +#include + +/* extern char *getbsize __P((int *headerlenp, long *printoutblocksizep)); */ + +static int nswap, nswdev, dmmax; +static struct swdevt *sw; +static long *perdev; +#ifdef __FreeBSD__ +static struct rlisthdr swaplist; +#else +static int nswapmap; +static struct map *swapmap, *kswapmap; +static struct mapent *mp; a11 1 +static int nfree; d13 4 a16 4 static const unsigned long _glibtop_sysdeps_swap = (1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) + (1 << GLIBTOP_SWAP_FREE) + (1 << GLIBTOP_SWAP_PAGEIN) + (1 << GLIBTOP_SWAP_PAGEOUT); d18 1 d20 4 a23 25 -static struct nlist nlst [] = { -#define VM_SWAPLIST 0 - { "_swaplist" },/* list of free swap areas */ -#define VM_SWDEVT 1 +static struct nlist syms [] = { +#define VM_SWDEVT 0 { "_swdevt" }, /* list of swap devices and sizes */ -#define VM_NSWAP 2 +#define VM_NSWAP 1 { "_nswap" }, /* size of largest swap device */ -#define VM_NSWDEV 3 +#define VM_NSWDEV 2 { "_nswdev" }, /* number of swap devices */ -#define VM_DMMAX 4 +#define VM_DMMAX 3 { "_dmmax" }, /* maximum size of a swap block */ +#ifdef __NetBSD__ + { "_swapmap" }, /* list of free swap areas */ +#define VM_SWAPMAP 4 + { "_nswapmap" },/* size of the swap map */ +#define VM_NSWAPMAP 5 +#else + { "_swaplist" },/* list of free swap areas */ +#define VM_SWAPLIST 4 +#endif /* !NetBSD */ d26 1 d28 8 a35 11 -/* Init function. */ +#define SVAR(var) __STRING(var) /* to force expansion */ +#define KGET(idx, var) \ + KGET1(idx, &var, sizeof(var), SVAR(var)) +#define KGET1(idx, p, s, msg) \ + KGET2(syms[idx].n_value, p, s, msg) +#define KGET2(addr, p, s, msg) \ + if (kvm_read(server->machine.kd, addr, p, s) != s) { \ + glibtop_error_io_r(server, "cannot read %s: %s", msg, kvm_geterr(server->machine.kd)); \ + return (0); \ + } d37 2 a38 5 -void -glibtop_init_swap_p (glibtop *server) + +static int +BSDInitSwapInfo(glibtop *server) d40 5 a44 3 - server->sysdeps.swap = _glibtop_sysdeps_swap; + static int once = 0; + u_long ptr; d46 3 a48 26 - if (kvm_nlist (server->machine.kd, nlst) != 0) - glibtop_error_io_r (server, "kvm_nlist"); + (void) ptr; /* Avoid gcc warnings. */ + if (once) + return (1); + if (kvm_nlist(server->machine.kd, syms)) { + return (0); + } + KGET(VM_NSWAP, nswap); + KGET(VM_NSWDEV, nswdev); + KGET(VM_DMMAX, dmmax); +#ifdef __FreeBSD__ + sw = glibtop_malloc_r (server, nswdev * sizeof(*sw)); + perdev = glibtop_malloc_r (server, nswdev * sizeof(*perdev)); + KGET1(VM_SWDEVT, &ptr, sizeof ptr, "swdevt"); + KGET2(ptr, sw, (signed) (nswdev * sizeof(*sw)), "*swdevt"); +#else /* __FreeBSD__ */ + KGET(VM_NSWAPMAP, nswapmap); + KGET(VM_SWAPMAP, kswapmap); /* kernel `swapmap' is a pointer */ + sw = glibtop_malloc_r (server, nswdev * sizeof(*sw)); + perdev = glibtop_malloc_r (server, nswdev * sizeof(*perdev)); + mp = glibtop_malloc_r(server, nswapmap * sizeof(*mp)); + KGET1(VM_SWDEVT, sw, (signed) (nswdev * sizeof(*sw)), "swdevt"); +#endif /* __FreeBSD__ */ + once = 1; + return (1); d50 3 a52 14 -/* Provides information about swap usage. */ - -/* - * This function is based on a program called swapinfo written - * by Kevin Lahey . - */ - -void -glibtop_get_swap_p (glibtop *server, glibtop_swap *buf) +#ifdef __FreeBSD__ +/* Taken verbatim from /usr/src/usr.bin/systat/swap.c (pavel 24-Jan-1998) */ +int +fetchswap(glibtop *server) d54 17 a70 122 - char *header; - int hlen, nswap, nswdev, dmmax; - int i, div, avail, nfree, npfree, used; - struct swdevt *sw; - long blocksize, *perdev; struct rlist head; - struct rlisthdr swaplist; struct rlist *swapptr; - size_t sw_size; - u_long ptr; - - /* To get `pagein' and `pageout'. */ - struct vmmeter vmm; - static int swappgsin = -1; - static int swappgsout = -1; - - glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SWAP), 0); - - memset (buf, 0, sizeof (glibtop_swap)); - - /* This is used to get the `pagein' and `pageout' members. */ - - if (kvm_read (server->machine.kd, nlst[0].n_value, - &vmm, sizeof (vmm)) != sizeof (vmm)) - glibtop_error_io_r (server, "kvm_read (cnt)"); - - if (swappgsin < 0) { - buf->pagein = 0; - buf->pageout = 0; - } else { - buf->pagein = vmm.v_swappgsin - swappgsin; - buf->pageout = vmm.v_swappgsout - swappgsout; - } - - swappgsin = vmm.v_swappgsin; - swappgsout = vmm.v_swappgsout; - - /* Size of largest swap device. */ - - if (kvm_read (server->machine.kd, nlst[VM_NSWAP].n_value, - &nswap, sizeof (nswap)) != sizeof (nswap)) - glibtop_error_io_r (server, "kvm_read (nswap)"); - - /* Number of swap devices. */ - - if (kvm_read (server->machine.kd, nlst[VM_NSWDEV].n_value, - &nswdev, sizeof (nswdev)) != sizeof (nswdev)) - glibtop_error_io_r (server, "kvm_read (nswdev)"); - - /* Maximum size of a swap block. */ - - if (kvm_read (server->machine.kd, nlst[VM_DMMAX].n_value, - &dmmax, sizeof (dmmax)) != sizeof (dmmax)) - glibtop_error_io_r (server, "kvm_read (dmmax)"); - - /* List of free swap areas. */ - - if (kvm_read (server->machine.kd, nlst[VM_SWAPLIST].n_value, - &swaplist, sizeof (swaplist)) != sizeof (swaplist)) - glibtop_error_io_r (server, "kvm_read (swaplist)"); - - /* Kernel offset of list of swap devices and sizes. */ - - if (kvm_read (server->machine.kd, nlst[VM_SWDEVT].n_value, - &ptr, sizeof (ptr)) != sizeof (ptr)) - glibtop_error_io_r (server, "kvm_read (swaplist)"); - - /* List of swap devices and sizes. */ - - sw_size = nswdev * sizeof (*sw); - sw = glibtop_malloc_r (server, sw_size); - - if (kvm_read (server->machine.kd, ptr, sw, sw_size) != sw_size) - glibtop_error_io_r (server, "kvm_read (*swdevt)"); - - perdev = glibtop_malloc (nswdev * sizeof (*perdev)); /* Count up swap space. */ - nfree = 0; - memset (perdev, 0, nswdev * sizeof(*perdev)); - + memset(perdev, 0, nswdev * sizeof(*perdev)); + KGET1(VM_SWAPLIST, &swaplist, sizeof swaplist, "swaplist"); swapptr = swaplist.rlh_list; - while (swapptr) { int top, bottom, next_block; - if (kvm_read (server->machine.kd, (int) swapptr, &head, - sizeof (struct rlist)) != sizeof (struct rlist)) - glibtop_error_io_r (server, "kvm_read (swapptr)"); + KGET2((unsigned long)swapptr, &head, + sizeof(struct rlist), "swapptr"); top = head.rl_end; bottom = head.rl_start; @@@@ -191,43 +249,136 @@@@ swapptr = head.rl_next; } + return 0; - header = getbsize (&hlen, &blocksize); +} +#else /* __FreeBSD__ */ +void +fetchswap(glibtop *server) +{ + int s, e, i; + int elast; + struct mapent* localmp; + + localmp = mp; + s = nswapmap * sizeof(*localmp); + if (kvm_read(server->machine.kd, (long)kswapmap, localmp, s) != s) + glibtop_error_io_r(server, "cannot read swapmap: %s", kvm_geterr(server->machine.kd)); + + /* first entry in map is `struct map'; rest are mapent's */ + swapmap = (struct map *)localmp; + if (!swapmap) { + glibtop_error_io_r(server, "Error: swapmap appears to be %p", swapmap); a71 85 + if (nswapmap != swapmap->m_limit - (struct mapent *)kswapmap) + glibtop_error_io_r(server, "panic: swap: nswapmap goof"); - div = blocksize / 512; - avail = npfree = 0; - for (i = 0; i < nswdev; i++) { - int xsize, xfree; + /* + * Count up swap space. + */ + nfree = 0; + elast = 0; + bzero(perdev, nswdev * sizeof(*perdev)); + for (localmp++; localmp->m_addr != 0; localmp++) { + s = localmp->m_addr; /* start of swap region */ + e = localmp->m_addr + localmp->m_size; /* end of region */ + elast = e; + nfree += localmp->m_size; + + /* + * Swap space is split up among the configured disks. + * The first dmmax blocks of swap space some from the + * first disk, the next dmmax blocks from the next, + * and so on. The list of free space joins adjacent + * free blocks, ignoring device boundries. If we want + * to keep track of this information per device, we'll + * just have to extract it ourselves. + */ + + /* calculate first device on which this falls */ + i = (s / dmmax) % nswdev; + while (s < e) { /* XXX this is inefficient */ + int bound = roundup(s + 1, dmmax); + + if (bound > e) + bound = e; + perdev[i] += bound - s; + if (++i >= nswdev) + i = 0; + s = bound; + } + } +} +#endif /* __FreeBSD__ */ - /* - * Don't report statistics for partitions which have not - * yet been activated via swapon(8). - */ - if (!(sw[i].sw_flags & SW_FREED)) - continue; +static void +BSDGetSwapInfo(glibtop *server, glibtop_swap *buf) +{ + int i, avail, npfree, xsize, xfree; - /* The first dmmax is never allocated to avoid trashing of - * disklabels - */ - xsize = sw[i].sw_nblks - dmmax; + fetchswap(server); + avail = npfree = buf->used = buf->pagein = buf->pageout = 0; + for (i = 0; i < nswdev; i++) { + /* + * Don't report statistics for partitions which have not + * yet been activated via swapon(8). + */ + if (!sw[i].sw_freed) { + /* ----- Originally, this printed a + * warning. However, for xosview, we + * don't want the warning printed. + * bgrayson */ + continue; + } +#ifdef __FreeBSD__ + /* + * The first dmmax is never allocated to avoid trashing of + * disklabels + */ + /*xsize = sw[i].sw_nblks - dmmax;*/ + /* Actually, count those dmmax blocks -- pstat, + * top, etc. do. It is swap space that is not + * free for use. bgrayson, on suggestion from + * Andrew Sharp. */ + xsize = sw[i].sw_nblks; d73 9 a81 55 + xsize = sw[i].sw_nblks; +#endif /* __FreeBSD__ */ xfree = perdev[i]; - used = xsize - xfree; - npfree++; - avail += xsize; - } + buf->used = xsize - xfree; + npfree++; + avail += xsize; + } + /* + * If only one partition has been set up via swapon(8), we don't + * need to bother with totals. + */ + if (npfree > 1) { + buf->used = avail - nfree; + } + /* Convert from 512-byte blocks to bytes. */ + buf->total = 512*avail; + buf->free = 512*(avail-buf->used); +} - /* - * If only one partition has been set up via swapon(8), we don't - * need to bother with totals. - */ - used = avail - nfree; +/* Provides information about swap usage. */ - glibtop_free_r (server, sw); - glibtop_free_r (server, perdev); +/* + * This function is based on a program called swapinfo written + * by Kevin Lahey . + */ +void +glibtop_init_swap_p(glibtop *server) +{ + server->sysdeps.swap = _glibtop_sysdeps_swap; - buf->used = used; - buf->free = avail; + if (kvm_nlist (server->machine.kd, syms) != 0) + glibtop_error_io_r (server, "kvm_nlist"); + BSDInitSwapInfo(server); +} - buf->total = used + avail; - buf->flags = _glibtop_sysdeps_swap; +void +glibtop_get_swap_p (glibtop *server, glibtop_swap *buf) +{ + BSDGetSwapInfo(server, buf); } @ 1.1 log @Initial revision @ text @d1 1 a1 1 $NetBSD$ @ 1.1.1.1 log @Initial import of libgtop-0.26 into the Packages Collection. This is part of the GNOME project, and is used to retrieve system information, such as CPU usage etc. This is not yet complete, but is functional to the point where the whole thing compiles and installs. Someone else can pick this up and run with it now. @ text @@ 1.1.1.2 log @Move libgtop to the sysutils category, coming from devel. This is version 1.0.13nb4. @ text @d1 1 a1 1 $NetBSD: patch-ae,v 1.8 2001/07/17 11:02:02 wiz Exp $ d3 60 a62 3 --- sysdeps/freebsd/cpu.c.orig Sun Feb 13 16:47:58 2000 +++ sysdeps/freebsd/cpu.c @@@@ -27,11 +27,16 @@@@ d66 53 a118 2 +#ifdef __NetBSD__ +#include d120 1 d122 4 a125 4 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); a126 1 +#ifndef KERN_CP_TIME d128 25 a152 4 static struct nlist nlst [] = { #ifdef __bsdi__ @@@@ -41,21 +46,27 @@@@ #endif a154 1 +#endif d156 21 a176 6 /* MIB array for sysctl */ static int mib_length=2; static int mib [] = { CTL_KERN, KERN_CLOCKRATE }; +#ifdef KERN_CP_TIME +static int mib2 [] = { CTL_KERN, KERN_CP_TIME }; +#endif d178 27 a204 1 /* Init function. */ d206 13 a218 2 void glibtop_init_cpu_p (glibtop *server) d220 100 a319 4 +#ifndef KERN_CP_TIME if (kvm_nlist (server->machine.kd, nlst) < 0) { glibtop_warn_io_r (server, "kvm_nlist (cpu)"); return; d321 1 d323 19 a341 25 +#endif /* Set this only if kvm_nlist () succeeded. */ server->sysdeps.cpu = _glibtop_sysdeps_cpu; } @@@@ -65,7 +76,11 @@@@ void glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf) { +#ifdef KERN_CP_TIME + u_int64_t cpts [CPUSTATES]; +#else long cpts [CPUSTATES]; +#endif /* sysctl vars*/ struct clockinfo ci; size_t length; @@@@ -78,11 +93,19 @@@@ if (server->sysdeps.cpu == 0) return; +#ifdef KERN_CP_TIME + length = sizeof (cpts); + if (sysctl (mib2, mib_length, cpts, &length, NULL, 0)) { + glibtop_warn_io_r (server, "sysctl"); + return; d343 85 d429 55 a483 9 if (kvm_read (server->machine.kd, nlst [0].n_value, &cpts, sizeof (cpts)) != sizeof (cpts)) { glibtop_warn_io_r (server, "kvm_read (cp_time)"); return; } +#endif /* Get the clockrate data */ length = sizeof (struct clockinfo); @