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.23 by ats, Sat Nov 6 15:41:30 2004 UTC vs.
Revision 1.25 by tdb, Thu Jul 5 16:46:06 2007 UTC

# Line 59 | Line 59
59   #include <unistd.h>
60   #define SWAP_BATCH 5
61   #endif
62 + #ifdef WIN32
63 + #include <windows.h>
64 + #endif
65  
66   sg_swap_stats *sg_get_swap_stats(){
67  
# Line 92 | Line 95 | sg_swap_stats *sg_get_swap_stats(){
95   #if defined(NETBSD) || defined(OPENBSD)
96          struct uvmexp *uvm;
97   #endif
98 + #ifdef WIN32
99 +        MEMORYSTATUSEX memstats;
100 + #endif
101  
102   #ifdef HPUX
103          swap_stat.total = 0;
# Line 181 | Line 187 | sg_swap_stats *sg_get_swap_stats(){
187          for (n = 0; ; ++n) {
188                  mib[mibsize] = n;
189                  size = sizeof xsw;
190 <                if (sysctl(mib, mibsize + 1, &xsw, &size, NULL, NULL) < 0) {
190 >                if (sysctl(mib, mibsize + 1, &xsw, &size, NULL, 0) < 0) {
191                          break;
192                  }
193                  if (xsw.xsw_version != XSWDEV_VERSION) {
# Line 219 | Line 225 | sg_swap_stats *sg_get_swap_stats(){
225          swap_stat.total = (long long)uvm->pagesize * (long long)uvm->swpages;
226          swap_stat.used = (long long)uvm->pagesize * (long long)uvm->swpginuse;
227          swap_stat.free = swap_stat.total - swap_stat.used;
228 + #endif
229 + #ifdef WIN32
230 +        memstats.dwLength = sizeof(memstats);
231 +        if (!GlobalMemoryStatusEx(&memstats)) {
232 +                sg_set_error_with_errno(SG_ERROR_MEMSTATUS,
233 +                        "GloblaMemoryStatusEx");
234 +                return NULL;
235 +        }
236 +        /* the PageFile stats include Phys memory "minus an overhead".
237 +         * Due to this unknown "overhead" there's no way to extract just page
238 +         * file use from these numbers */
239 +        swap_stat.total = memstats.ullTotalPageFile;
240 +        swap_stat.free = memstats.ullAvailPageFile;
241 +        swap_stat.used = swap_stat.total - swap_stat.free;
242   #endif
243  
244          return &swap_stat;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines