Hi again,

Grmpf, I actually have a problem: hurd.h can't be #included in C++ for
stupid reason (inline function that makes a cast which is valid in C but
not in C++), so I fixed that on my system and submitted a patch
upstream.  The problem is that upstream refuses to make this
modification.  As a consequence here is a (third...) patch that makes
use of a tiny .c file just for making the Hurd calls.

Samuel
diff -urN xosview-1.8.2/config/Makefile.gnu.in 
xosview-1.8.2-gnu/config/Makefile.gnu.in
--- xosview-1.8.2/config/Makefile.gnu.in        1970-01-01 00:00:00.000000000 
+0000
+++ xosview-1.8.2-gnu/config/Makefile.gnu.in    2007-08-05 20:42:32.000000000 
+0000
@@ -0,0 +1,43 @@
+#
+# GNU Makefile template
+#
+#
+# $Id$
+#
+include ../Makefile.config
[EMAIL PROTECTED]@
+
+#arch=$(shell uname -m)
+#export arch
+
+CXXFLAGS += [EMAIL PROTECTED]@
+
+CXXOBJS = \
+memmeter.o \
+swapmeter.o \
+pagemeter.o \
+loadmeter.o \
+MeterMaker.o
+
+OBJS = $(CXXOBJS) get_def_pager.o
+
+ARCH = @host_cpu@
+
+CFILES := $(CXXOBJS:.o=.cc) get_def_pager.c
+DEPFILES := $(OBJS:%=.%.d)
+
+vpath %.h $(TOP)
+vpath %.cc $(TOP)
+
+#-----------------------------------------------------------------------
+
+all : libmeter.a
+
+clean :
+       rm -f $(OBJS) $(DEPFILES) libmeter.a *~
+
+libmeter.a : $(OBJS)
+       ar cvr libmeter.a $(OBJS)
+       @RANLIB@ $@
+
[EMAIL PROTECTED]@
diff -urN xosview-1.8.2/config/aclocal.m4 xosview-1.8.2-gnu/config/aclocal.m4
--- xosview-1.8.2/config/aclocal.m4     2007-08-05 17:14:27.270121000 +0000
+++ xosview-1.8.2-gnu/config/aclocal.m4 2007-08-05 16:41:34.183578000 +0000
@@ -245,6 +245,10 @@
     AC_DEFINE(HAVE_SNPRINTF)
 ])
 
+AC_DEFUN(AC_XOSV_GNU, [
+EXTRALIBS=$XPMLIB
+])
+
 dnl MY_C_SWITCH(switch)
 dnl -------------------
 dnl try to compile and link a simple C program with the switch compile switch
diff -urN xosview-1.8.2/config/configure.in 
xosview-1.8.2-gnu/config/configure.in
--- xosview-1.8.2/config/configure.in   2007-08-05 17:14:27.000000000 +0000
+++ xosview-1.8.2-gnu/config/configure.in       2007-08-05 16:41:34.000000000 
+0000
@@ -79,7 +79,7 @@
 dnl
 
 case $host_os in
-linux*)
+linux*|gnu*)
   LIBS="-L$x_libraries $LIBS"
   ELF_LINK_FLAGS="" ;;
 *)
@@ -341,6 +341,10 @@
        EXTRALIBS="-R$x_libraries -lsocket -lnsl -lkstat $XPMLIB"
        host_dir=sunos5
        host_os=sunos5 ;;
+gnu*)  AC_XOSV_GNU
+       AC_GCC_EXTRA_CXXFLAGS
+       host_dir=gnu
+       host_os=gnu ;;
 *)       AC_MSG_ERROR([xosview has not been ported to $host_os :(.  Sorry.]) ;;
 esac
 
diff -urN xosview-1.8.2/configure xosview-1.8.2-gnu/configure
--- xosview-1.8.2/configure     2007-08-05 17:14:27.000000000 +0000
+++ xosview-1.8.2-gnu/configure 2007-08-05 16:41:34.000000000 +0000
@@ -4023,7 +4023,7 @@
 
 
 case $host_os in
-linux*)
+linux*|gnu*)
   LIBS="-L$x_libraries $LIBS"
   ELF_LINK_FLAGS="" ;;
 *)
@@ -6077,6 +6077,14 @@
        EXTRALIBS="-R$x_libraries -lsocket -lnsl -lkstat $XPMLIB"
        host_dir=sunos5
        host_os=sunos5 ;;
+gnu*)
+EXTRALIBS=$XPMLIB
+
+
+       EXTRA_CXXFLAGS="-W -Wall -O2"
+
+       host_dir=gnu
+        host_os=gnu ;;
 *)       { { echo "$as_me:$LINENO: error: xosview has not been ported to 
$host_os :(.  Sorry." >&5
 echo "$as_me: error: xosview has not been ported to $host_os :(.  Sorry." >&2;}
    { (exit 1); exit 1; }; } ;;
diff -urN xosview-1.8.2/gnu/.cvsignore xosview-1.8.2-gnu/gnu/.cvsignore
--- xosview-1.8.2/gnu/.cvsignore        1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/.cvsignore    2007-08-05 16:41:34.000000000 +0000
@@ -0,0 +1 @@
+Makefile
diff -urN xosview-1.8.2/gnu/MeterMaker.cc xosview-1.8.2-gnu/gnu/MeterMaker.cc
--- xosview-1.8.2/gnu/MeterMaker.cc     1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/MeterMaker.cc 2007-08-05 16:41:34.070113000 +0000
@@ -0,0 +1,36 @@
+//
+//  Copyright (c) 1994, 1995, 2002 by Mike Romberg ( [EMAIL PROTECTED] )
+//  2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+//
+// $Id$
+//
+#include "MeterMaker.h"
+#include "xosview.h"
+
+#include "memmeter.h"
+#include "swapmeter.h"
+#include "pagemeter.h"
+#include "loadmeter.h"
+
+#include <stdlib.h>
+
+
+MeterMaker::MeterMaker(XOSView *xos){
+  _xos = xos;
+}
+
+void MeterMaker::makeMeters(void){
+  if (_xos->isResourceTrue("load"))
+    push(new LoadMeter(_xos));
+
+  if (_xos->isResourceTrue("mem"))
+    push(new MemMeter(_xos));
+  if (_xos->isResourceTrue("swap"))
+    push(new SwapMeter(_xos));
+
+  if (_xos->isResourceTrue("page"))
+    push(new PageMeter(_xos, atof(_xos->getResource("pageBandwidth"))));
+}
diff -urN xosview-1.8.2/gnu/MeterMaker.h xosview-1.8.2-gnu/gnu/MeterMaker.h
--- xosview-1.8.2/gnu/MeterMaker.h      1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/MeterMaker.h  2007-08-05 16:41:34.000000023 +0000
@@ -0,0 +1,28 @@
+//  
+//  Copyright (c) 1994, 1995 by Mike Romberg ( [EMAIL PROTECTED] )
+//  2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+//
+// $Id$
+//
+#ifndef _MeterMaker_h
+#define _MeterMaker_h
+
+#include "pllist.h"
+
+class Meter;
+class XOSView;
+
+class MeterMaker : public PLList<Meter *> {
+public:
+  MeterMaker(XOSView *xos);
+
+  void makeMeters(void);
+
+private:
+  XOSView *_xos;
+};
+
+#endif
diff -urN xosview-1.8.2/gnu/get_def_pager.c 
xosview-1.8.2-gnu/gnu/get_def_pager.c
--- xosview-1.8.2/gnu/get_def_pager.c   1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/get_def_pager.c       2007-08-05 20:51:54.000000023 
+0000
@@ -0,0 +1,43 @@
+//
+//  Copyright (c) 2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+//
+// $Id$
+//
+
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <error.h>
+
+#include <mach.h>
+#include <mach/mach_traps.h>
+#include <mach/default_pager.h>
+#include <hurd.h>
+#include <hurd/paths.h>
+
+mach_port_t get_def_pager(void) {
+  mach_port_t def_pager = MACH_PORT_NULL;
+  kern_return_t err;
+  mach_port_t host;
+
+  err = get_privileged_ports (&host, 0);
+  if (err == EPERM) {
+    def_pager = file_name_lookup (_SERVERS_DEFPAGER, O_READ, 0);
+    if (def_pager == MACH_PORT_NULL)
+      error (0, errno, _SERVERS_DEFPAGER);
+    return def_pager;
+  } else if (err) {
+    error (0, err, "get_privileged_ports");
+    return MACH_PORT_NULL;
+  } else {
+    err = vm_set_default_memory_manager (host, &def_pager);
+    mach_port_deallocate (mach_task_self(), host);
+    if (err) {
+      error (0, err, "vm_set_default_memory_manager");
+      return MACH_PORT_NULL;
+    }
+    return def_pager;
+  }
+}
diff -urN xosview-1.8.2/gnu/get_def_pager.h 
xosview-1.8.2-gnu/gnu/get_def_pager.h
--- xosview-1.8.2/gnu/get_def_pager.h   1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/get_def_pager.h       2007-08-05 20:33:46.000000000 
+0000
@@ -0,0 +1,10 @@
+//
+//  Copyright (c) 2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+//
+// $Id$
+//
+
+extern mach_port_t get_def_pager(void);
diff -urN xosview-1.8.2/gnu/loadmeter.cc xosview-1.8.2-gnu/gnu/loadmeter.cc
--- xosview-1.8.2/gnu/loadmeter.cc      1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/loadmeter.cc  2007-08-05 16:41:34.000000000 +0000
@@ -0,0 +1,111 @@
+//
+//  Copyright (c) 1994, 1995 by Mike Romberg ( [EMAIL PROTECTED] )
+//  2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+//  Most of this code was written by Werner Fink <[EMAIL PROTECTED]>.
+//  Only small changes were made on my part (M.R.)
+//
+// $Id$
+//
+#include "loadmeter.h"
+#include "xosview.h"
+#include <fstream>
+#include <stdlib.h>
+#include <error.h>
+
+extern "C" {
+#include <mach/mach_traps.h>
+#include <mach/mach_host.h>
+}
+
+LoadMeter::LoadMeter( XOSView *parent )
+  : FieldMeterGraph( parent, 2, "LOAD", "PROCS/MIN", 1, 1, 0 ){
+  lastalarmstate = -1;
+  total_ = 2.0;
+}
+
+LoadMeter::~LoadMeter( void ){
+}
+
+void LoadMeter::checkResources( void ){
+  FieldMeterGraph::checkResources();
+
+  procloadcol_ = parent_->allocColor(parent_->getResource( "loadProcColor" ));
+  warnloadcol_ = parent_->allocColor(parent_->getResource( "loadWarnColor" ));
+  critloadcol_ = parent_->allocColor(parent_->getResource( "loadCritColor" ));
+
+  setfieldcolor( 0, procloadcol_ );
+  setfieldcolor( 1, parent_->getResource( "loadIdleColor" ) );
+  priority_ = atoi (parent_->getResource( "loadPriority" ) );
+  useGraph_ = parent_->isResourceTrue( "loadGraph" );
+  dodecay_ = parent_->isResourceTrue( "loadDecay" );
+  SetUsedFormat (parent_->getResource("loadUsedFormat"));
+
+  warnThreshold = atoi (parent_->getResource("loadWarnThreshold"));
+  critThreshold = atoi (parent_->getResource("loadCritThreshold"));
+
+
+  if (dodecay_){
+    //  Warning:  Since the loadmeter changes scale occasionally, old
+    //  decay values need to be rescaled.  However, if they are rescaled,
+    //  they could go off the edge of the screen.  Thus, for now, to
+    //  prevent this whole problem, the load meter can not be a decay
+    //  meter.  The load is a decaying average kind of thing anyway,
+    //  so having a decaying load average is redundant.
+    std::cerr << "Warning:  The loadmeter can not be configured as a decay\n"
+         << "  meter.  See the source code (" << __FILE__ << ") for further\n"
+         << "  details.\n";
+    dodecay_ = 0;
+  }
+}
+
+void LoadMeter::checkevent( void ){
+  getloadinfo();
+  drawfields();
+}
+
+
+void LoadMeter::getloadinfo( void ){
+  host_load_info_data_t info;
+  mach_msg_type_number_t count = HOST_LOAD_INFO_COUNT;
+  kern_return_t err;
+
+  err = host_info(mach_host_self(), HOST_LOAD_INFO, (host_info_t) &info, 
&count);
+  if (err) {
+    std::cerr << "Can not get host info";
+    parent_->done(1);
+    return;
+  }
+  fields_[0] = (float) info.avenrun[0] / LOAD_SCALE;
+
+  if ( fields_[0] <  warnThreshold ) alarmstate = 0;
+  else
+  if ( fields_[0] >= critThreshold ) alarmstate = 2;
+  else
+  /* if fields_[0] >= warnThreshold */ alarmstate = 1;
+
+  if ( alarmstate != lastalarmstate ){
+    if ( alarmstate == 0 ) setfieldcolor( 0, procloadcol_ );
+    else
+    if ( alarmstate == 1 ) setfieldcolor( 0, warnloadcol_ );
+    else
+    /* if alarmstate == 2 */ setfieldcolor( 0, critloadcol_ );
+    if (dolegends_) drawlegend();
+    lastalarmstate = alarmstate;
+  }
+
+  if ( fields_[0]*5.0<total_ )
+    total_ = fields_[0];
+  else
+  if ( fields_[0]>total_ )
+    total_ = fields_[0]*5.0;
+
+  if ( total_ < 1.0)
+    total_ = 1.0;
+
+  fields_[1] = (float) (total_ - fields_[0]);
+
+  setUsed(fields_[0], (float) 1.0);
+}
diff -urN xosview-1.8.2/gnu/loadmeter.h xosview-1.8.2-gnu/gnu/loadmeter.h
--- xosview-1.8.2/gnu/loadmeter.h       1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/loadmeter.h   2007-08-05 16:41:34.300190000 +0000
@@ -0,0 +1,37 @@
+//  
+//  Copyright (c) 1994, 1995 by Mike Romberg ( [EMAIL PROTECTED] )
+//  2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+//  Most of this code was written by Werner Fink <[EMAIL PROTECTED]>
+//  Only small changes were made on my part (M.R.)
+//
+// $Id$
+//
+#ifndef _LOADMETER_H_
+#define _LOADMETER_H_
+
+
+#include "fieldmetergraph.h"
+
+
+class LoadMeter : public FieldMeterGraph {
+public:
+  LoadMeter( XOSView *parent );
+  ~LoadMeter( void );
+
+  const char *name( void ) const { return "LoadMeter"; }  
+  void checkevent( void );
+
+  void checkResources( void );
+protected:
+
+  void getloadinfo( void );
+  unsigned long procloadcol_, warnloadcol_, critloadcol_;
+private:
+  int warnThreshold, critThreshold, alarmstate, lastalarmstate;
+};
+
+
+#endif
diff -urN xosview-1.8.2/gnu/memmeter.cc xosview-1.8.2-gnu/gnu/memmeter.cc
--- xosview-1.8.2/gnu/memmeter.cc       1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/memmeter.cc   2007-08-05 17:06:43.000000000 +0000
@@ -0,0 +1,63 @@
+//
+//  Copyright (c) 1994, 1995 by Mike Romberg ( [EMAIL PROTECTED] )
+//  2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+// $Id$
+//
+#include "memmeter.h"
+#include "xosview.h"
+#include <fstream>
+#include <sstream>
+#include <stdlib.h>
+#include <error.h>
+
+extern "C" {
+#include <mach/mach_traps.h>
+#include <mach/mach_interface.h>
+}
+
+MemMeter::MemMeter( XOSView *parent )
+: FieldMeterGraph( parent, 4, "MEM", "ACT/INACT/WIRE/FREE" ){
+}
+
+MemMeter::~MemMeter( void ){
+}
+
+void MemMeter::checkResources( void ){
+  FieldMeterGraph::checkResources();
+
+  setfieldcolor( 0, parent_->getResource( "memActiveColor" ) );
+  setfieldcolor( 1, parent_->getResource( "memInactiveColor" ) );
+  setfieldcolor( 2, parent_->getResource( "memCacheColor" ) );
+  setfieldcolor( 3, parent_->getResource( "memFreeColor" ) );
+  priority_ = atoi (parent_->getResource( "memPriority" ) );
+  dodecay_ = parent_->isResourceTrue( "memDecay" );
+  useGraph_ = parent_->isResourceTrue( "memGraph" );
+  SetUsedFormat (parent_->getResource("memUsedFormat"));
+}
+
+void MemMeter::checkevent( void ){
+  getmeminfo();
+  drawfields();
+}
+
+void MemMeter::getmeminfo( void ){
+  kern_return_t err;
+
+  err = vm_statistics (mach_task_self(), &vmstats);
+  if (err) {
+    error (0, err, "vm_statistics");
+    parent_->done(1);
+    return;
+  }
+
+  fields_[0] = vmstats.active_count * vmstats.pagesize;
+  fields_[1] = vmstats.inactive_count * vmstats.pagesize;;
+  fields_[2] = vmstats.wire_count * vmstats.pagesize;;
+  fields_[3] = vmstats.free_count * vmstats.pagesize;;
+  total_ = fields_[0] + fields_[1] + fields_[2] + fields_[3];
+
+  FieldMeterDecay::setUsed (total_ - fields_[3], total_);
+}
diff -urN xosview-1.8.2/gnu/memmeter.h xosview-1.8.2-gnu/gnu/memmeter.h
--- xosview-1.8.2/gnu/memmeter.h        1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/memmeter.h    2007-08-05 16:41:34.000000000 +0000
@@ -0,0 +1,37 @@
+//  
+//  Copyright (c) 1994, 1995 by Mike Romberg ( [EMAIL PROTECTED] )
+//  2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+//
+// $Id$
+//
+#ifndef _MEMMETER_H_
+#define _MEMMETER_H_
+
+#include "fieldmetergraph.h"
+
+extern "C" {
+#include <mach/vm_statistics.h>
+}
+
+class MemMeter : public FieldMeterGraph {
+public:
+  MemMeter( XOSView *parent );
+  ~MemMeter( void );
+
+  const char *name( void ) const { return "MemMeter"; }  
+  void checkevent( void );
+
+  void checkResources( void );
+protected:
+
+  void getmeminfo( void );
+private:
+
+  struct vm_statistics vmstats;
+};
+
+
+#endif
diff -urN xosview-1.8.2/gnu/pagemeter.cc xosview-1.8.2-gnu/gnu/pagemeter.cc
--- xosview-1.8.2/gnu/pagemeter.cc      1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/pagemeter.cc  2007-08-05 16:41:34.040097000 +0000
@@ -0,0 +1,96 @@
+//
+//  Copyright (c) 1996, 2004 by Massimiliano Ghilardi ( [EMAIL PROTECTED] )
+//  2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+//
+// $Id$
+//
+#include "pagemeter.h"
+#include "xosview.h"
+#include <fstream>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <error.h>
+
+extern "C" {
+#include <mach/mach_traps.h>
+#include <mach/mach_interface.h>
+}
+
+PageMeter::PageMeter( XOSView *parent, float max )
+  : FieldMeterGraph( parent, 3, "PAGE", "IN/OUT/IDLE" ) {
+  for ( int i = 0 ; i < 2 ; i++ )
+    for ( int j = 0 ; j < 2 ; j++ )
+      pageinfo_[j][i] = 0;
+
+  maxspeed_ = max;
+  pageindex_ = 0;
+}
+
+PageMeter::~PageMeter( void ){
+}
+
+void PageMeter::checkResources( void ){
+  FieldMeterGraph::checkResources();
+
+  setfieldcolor( 0, parent_->getResource( "pageInColor" ) );
+  setfieldcolor( 1, parent_->getResource( "pageOutColor" ) );
+  setfieldcolor( 2, parent_->getResource( "pageIdleColor" ) );
+  priority_ = atoi (parent_->getResource( "pagePriority" ) );
+  maxspeed_ *= priority_ / 10.0;
+  dodecay_ = parent_->isResourceTrue( "pageDecay" );
+  useGraph_ = parent_->isResourceTrue( "pageGraph" );
+  SetUsedFormat (parent_->getResource("pageUsedFormat"));
+}
+
+void PageMeter::checkevent( void ){
+  getpageinfo();
+  drawfields();
+}
+
+void PageMeter::updateinfo(void)
+    {
+    int oldindex = (pageindex_+1)%2;
+    for ( int i = 0; i < 2; i++ )
+        {
+        if ( pageinfo_[oldindex][i] == 0 )
+            pageinfo_[oldindex][i] = pageinfo_[pageindex_][i];
+
+        fields_[i] = pageinfo_[pageindex_][i] - pageinfo_[oldindex][i];
+        total_ += fields_[i];
+        }
+
+    if ( total_ > maxspeed_ )
+        fields_[2] = 0.0;
+    else
+        {
+        fields_[2] = maxspeed_ - total_;
+        total_ = maxspeed_;
+        }
+
+    setUsed (total_ - fields_[2], maxspeed_);
+    pageindex_ = (pageindex_ + 1) % 2;
+    }
+
+void PageMeter::getpageinfo(void) {
+  struct vm_statistics vmstats;
+
+  total_ = 0;
+  kern_return_t err;
+
+  err = vm_statistics (mach_task_self(), &vmstats);
+  if (err) {
+    error (0, err, "vm_statistics");
+    parent_->done(1);
+    return;
+  }
+
+  pageinfo_[pageindex_][0] = vmstats.pageins;
+  pageinfo_[pageindex_][1] = vmstats.pageouts;
+
+  updateinfo();
+}
diff -urN xosview-1.8.2/gnu/pagemeter.h xosview-1.8.2-gnu/gnu/pagemeter.h
--- xosview-1.8.2/gnu/pagemeter.h       1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/pagemeter.h   2007-08-05 16:41:34.556370000 +0000
@@ -0,0 +1,34 @@
+//
+//  Copyright (c) 1996 by Massimiliano Ghilardi ( [EMAIL PROTECTED] )
+//  2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+//
+// $Id$
+//
+#ifndef _PAGEMETER_H_
+#define _PAGEMETER_H_
+
+#include "fieldmetergraph.h"
+
+class PageMeter : public FieldMeterGraph {
+public:
+  PageMeter( XOSView *parent, float max );
+  ~PageMeter( void );
+
+  const char *name( void ) const { return "PageMeter"; }
+  void checkevent( void );
+
+  void checkResources( void );
+protected:
+  float pageinfo_[2][2];
+  int pageindex_;
+  float maxspeed_;
+
+  void getpageinfo( void );
+  void updateinfo(void);
+private:
+};
+
+#endif
diff -urN xosview-1.8.2/gnu/swapmeter.cc xosview-1.8.2-gnu/gnu/swapmeter.cc
--- xosview-1.8.2/gnu/swapmeter.cc      1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/swapmeter.cc  2007-08-05 20:42:02.560454000 +0000
@@ -0,0 +1,75 @@
+//
+//  Copyright (c) 1994, 1995 by Mike Romberg ( [EMAIL PROTECTED] )
+//  2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+//
+// $Id$
+//
+
+#include "swapmeter.h"
+#include "xosview.h"
+#include <fstream>
+#include <sstream>
+#include <stdlib.h>
+#include <error.h>
+
+extern "C" {
+#include <mach.h>
+#include <mach/mach_traps.h>
+#include <mach/default_pager.h>
+#include "get_def_pager.h"
+}
+
+SwapMeter::SwapMeter( XOSView *parent )
+: FieldMeterGraph( parent, 2, "SWAP", "ACTIVE/USED/FREE" ){
+  def_pager = MACH_PORT_NULL;
+}
+
+SwapMeter::~SwapMeter( void ){
+}
+
+void SwapMeter::checkResources( void ){
+  FieldMeterGraph::checkResources();
+
+  setfieldcolor( 0, parent_->getResource( "swapUsedColor" ) );
+  setfieldcolor( 1, parent_->getResource( "swapFreeColor" ) );
+  priority_ = atoi (parent_->getResource( "swapPriority" ) );
+  dodecay_ = parent_->isResourceTrue( "swapDecay" );
+  useGraph_ = parent_->isResourceTrue( "swapGraph" );
+  SetUsedFormat (parent_->getResource("swapUsedFormat"));
+}
+
+void SwapMeter::checkevent( void ){
+  getswapinfo();
+  drawfields();
+}
+
+
+void SwapMeter::getswapinfo( void ){
+  kern_return_t err;
+
+  if (def_pager == MACH_PORT_NULL)
+    def_pager = get_def_pager();
+
+  if (!MACH_PORT_VALID (def_pager)) {
+    def_pager = MACH_PORT_DEAD;
+    parent_->done(1);
+    return;
+  }
+
+  err = default_pager_info (def_pager, &def_pager_info);
+  if (err) {
+    error (0, err, "default_pager_info");
+    parent_->done(1);
+    return;
+  }
+
+  total_ = def_pager_info.dpi_total_space;
+  fields_[1] = def_pager_info.dpi_free_space;
+  fields_[0] = total_ - fields_[1];
+
+  if (total_)
+    setUsed (fields_[0], total_);
+}
diff -urN xosview-1.8.2/gnu/swapmeter.h xosview-1.8.2-gnu/gnu/swapmeter.h
--- xosview-1.8.2/gnu/swapmeter.h       1970-01-01 00:00:00.000000000 +0000
+++ xosview-1.8.2-gnu/gnu/swapmeter.h   2007-08-05 16:41:34.620523000 +0000
@@ -0,0 +1,40 @@
+//  
+//  Copyright (c) 1994, 1995 by Mike Romberg ( [EMAIL PROTECTED] )
+//  2007 by Samuel Thibault ( [EMAIL PROTECTED] )
+//
+//  This file may be distributed under terms of the GPL
+//
+//
+// $Id$
+//
+#ifndef _SWAPMETER_H_
+#define _SWAPMETER_H_
+
+
+#include "fieldmetergraph.h"
+
+extern "C" {
+#include <mach/mach_types.h>
+#include <mach/default_pager_types.h>
+}
+
+class SwapMeter : public FieldMeterGraph {
+public:
+  SwapMeter( XOSView *parent );
+  ~SwapMeter( void );
+
+  const char *name( void ) const { return "SwapMeter"; }  
+  void checkevent( void );
+
+  void checkResources( void );
+protected:
+
+  void getswapinfo( void );
+private:
+
+  struct default_pager_info def_pager_info;
+  mach_port_t def_pager;
+};
+
+
+#endif
diff -urN xosview-1.8.2/xosview.1 xosview-1.8.2-gnu/xosview.1
--- xosview-1.8.2/xosview.1     2007-08-05 17:14:27.000000000 +0000
+++ xosview-1.8.2-gnu/xosview.1 2007-08-05 16:41:34.070113000 +0000
@@ -113,8 +113,8 @@
 regions.  Each region represents a percentage of the resource which is being
 put to a particular use.  Typing a 'q' in the window will terminate xosview.
 
-At the moment \fIxosview\fP runs on seven platforms (Linux,
-NetBSD, FreeBSD, OpenBSD, some Solaris systems, IRIX 6.5 and HPUX).
+At the moment \fIxosview\fP runs on eight platforms (Linux,
+NetBSD, FreeBSD, OpenBSD, some Solaris systems, IRIX 6.5, HPUX and GNU).
 Not all of the meters described below are supported on all
 platforms.  Some of the meters may appear different depending upon the
 platform \fIxosview\fP is running on.  Note that *BSD is used as
@@ -137,6 +137,7 @@
    OpenBSD: active | inactive | wired | free
    IRIX   : kernel | fs   | user    | free
    HPUX   : text | used   | other   | free
+   GNU    : active | inactive | wired | free
 
 \fBSwap Usage\fP
    all platforms except IRIX: used | free

Reply via email to