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.24 by tdb, Sat Sep 24 13:29:23 2005 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 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