--- projects/libstatgrab/src/libstatgrab/swap_stats.c 2004/02/12 23:04:52 1.12 +++ projects/libstatgrab/src/libstatgrab/swap_stats.c 2004/02/13 16:46:21 1.13 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA * - * $Id: swap_stats.c,v 1.12 2004/02/12 23:04:52 tdb Exp $ + * $Id: swap_stats.c,v 1.13 2004/02/13 16:46:21 tdb Exp $ */ #ifdef HAVE_CONFIG_H @@ -41,10 +41,8 @@ #include #include #endif -#ifdef OPENBSD -#include +#if defined(NETBSD) || defined(OPENBSD) #include -#include #include #endif @@ -69,10 +67,6 @@ swap_stat_t *get_swap_stats(){ #if defined(NETBSD) || defined(OPENBSD) struct uvmexp *uvm; #endif -#ifdef OPENBSD - int mib[2]; - size_t size; -#endif #ifdef SOLARIS if((pagesize=sysconf(_SC_PAGESIZE)) == -1){ @@ -119,37 +113,14 @@ swap_stat_t *get_swap_stats(){ swap_stat.used = (long long)swapinfo.ksw_used * (long long)pagesize; swap_stat.free = swap_stat.total-swap_stat.used; #endif -#ifdef NETBSD +#if defined(NETBSD) || defined(OPENBSD) if ((uvm = get_uvmexp()) == NULL) { return NULL; } -#endif -#ifdef OPENBSD - mib[0] = CTL_VM; - mib[1] = VM_UVMEXP; - if (sysctl(mib, 2, NULL, &size, NULL, 0) < 0) { - return NULL; - } - - uvm = malloc(size); - if (uvm == NULL) { - return NULL; - } - - if (sysctl(mib, 2, uvm, &size, NULL, 0) < 0) { - return NULL; - } -#endif - -#if defined(NETBSD) || defined(OPENBSD) swap_stat.total = (long long)uvm->pagesize * (long long)uvm->swpages; swap_stat.used = (long long)uvm->pagesize * (long long)uvm->swpginuse; swap_stat.free = swap_stat.total - swap_stat.used; -#endif - -#ifdef OPENBSD - free(uvm); #endif return &swap_stat;