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 |
|
|
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; |
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; |