ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/swap_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/swap_stats.c (file contents):
Revision 1.12 by tdb, Thu Feb 12 23:04:52 2004 UTC vs.
Revision 1.13 by tdb, Fri Feb 13 16:46:21 2004 UTC

# Line 41 | Line 41
41   #include <sys/types.h>
42   #include <kvm.h>
43   #endif
44 < #ifdef OPENBSD
45 < #include <stdlib.h>
44 > #if defined(NETBSD) || defined(OPENBSD)
45   #include <sys/param.h>
47 #include <sys/sysctl.h>
46   #include <uvm/uvm.h>
47   #endif
48  
# Line 69 | Line 67 | swap_stat_t *get_swap_stats(){
67   #if defined(NETBSD) || defined(OPENBSD)
68          struct uvmexp *uvm;
69   #endif
72 #ifdef OPENBSD
73        int mib[2];
74        size_t size;
75 #endif
70  
71   #ifdef SOLARIS
72          if((pagesize=sysconf(_SC_PAGESIZE)) == -1){
# Line 119 | Line 113 | swap_stat_t *get_swap_stats(){
113          swap_stat.used = (long long)swapinfo.ksw_used * (long long)pagesize;
114          swap_stat.free = swap_stat.total-swap_stat.used;
115   #endif
116 < #ifdef NETBSD
116 > #if defined(NETBSD) || defined(OPENBSD)
117          if ((uvm = get_uvmexp()) == NULL) {
118                  return NULL;
119          }
126 #endif
127 #ifdef OPENBSD
128        mib[0] = CTL_VM;
129        mib[1] = VM_UVMEXP;
120  
131        if (sysctl(mib, 2, NULL, &size, NULL, 0) < 0) {
132                return NULL;
133        }
134
135        uvm = malloc(size);
136        if (uvm == NULL) {
137                return NULL;
138        }
139
140        if (sysctl(mib, 2, uvm, &size, NULL, 0) < 0) {
141                return NULL;
142        }
143 #endif
144
145 #if defined(NETBSD) || defined(OPENBSD)
121          swap_stat.total = (long long)uvm->pagesize * (long long)uvm->swpages;
122          swap_stat.used = (long long)uvm->pagesize * (long long)uvm->swpginuse;
123          swap_stat.free = swap_stat.total - swap_stat.used;
149 #endif
150
151 #ifdef OPENBSD
152        free(uvm);
124   #endif
125  
126          return &swap_stat;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines