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.11 by tdb, Mon Jan 19 16:49:21 2004 UTC vs.
Revision 1.12 by tdb, Thu Feb 12 23:04:52 2004 UTC

# Line 41 | Line 41
41   #include <sys/types.h>
42   #include <kvm.h>
43   #endif
44 + #ifdef OPENBSD
45 + #include <stdlib.h>
46 + #include <sys/param.h>
47 + #include <sys/sysctl.h>
48 + #include <uvm/uvm.h>
49 + #endif
50  
51   swap_stat_t *get_swap_stats(){
52  
# Line 60 | Line 66 | swap_stat_t *get_swap_stats(){
66          int pagesize;
67          kvm_t *kvmd;
68   #endif
69 < #ifdef NETBSD
69 > #if defined(NETBSD) || defined(OPENBSD)
70          struct uvmexp *uvm;
71   #endif
72 + #ifdef OPENBSD
73 +        int mib[2];
74 +        size_t size;
75 + #endif
76  
77   #ifdef SOLARIS
78          if((pagesize=sysconf(_SC_PAGESIZE)) == -1){
# Line 113 | Line 123 | swap_stat_t *get_swap_stats(){
123          if ((uvm = get_uvmexp()) == NULL) {
124                  return NULL;
125          }
126 + #endif
127 + #ifdef OPENBSD
128 +        mib[0] = CTL_VM;
129 +        mib[1] = VM_UVMEXP;
130  
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)
146          swap_stat.total = (long long)uvm->pagesize * (long long)uvm->swpages;
147          swap_stat.used = (long long)uvm->pagesize * (long long)uvm->swpginuse;
148          swap_stat.free = swap_stat.total - swap_stat.used;
149   #endif
150 +
151 + #ifdef OPENBSD
152 +        free(uvm);
153 + #endif
154 +
155          return &swap_stat;
156  
157   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines