[SIGAR-38] Change win32 swap_get to use GlobalMemoryStatusEx

This commit is contained in:
Doug MacEachern 2007-01-29 23:30:39 +00:00
parent 8802b3929b
commit db6cc45f1c
2 changed files with 24 additions and 5 deletions

View File

@ -1,3 +1,7 @@
2007-01-29 Doug MacEachern <dougm@hyperic.com>
* [SIGAR-38] Change win32 swap_get to use GlobalMemoryStatusEx
2007-01-24 Doug MacEachern <dougm@hyperic.com> 2007-01-24 Doug MacEachern <dougm@hyperic.com>
* Add proper thread_cpu impl for OS X * Add proper thread_cpu impl for OS X

View File

@ -521,13 +521,28 @@ SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
SIGAR_DECLARE(int) sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap) SIGAR_DECLARE(int) sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
{ {
MEMORYSTATUS memstat; DLLMOD_INIT(kernel, TRUE);
GlobalMemoryStatus(&memstat); if (sigar_GlobalMemoryStatusEx) {
MEMORYSTATUSEX memstat;
swap->total = memstat.dwTotalPageFile; memstat.dwLength = sizeof(memstat);
swap->free = memstat.dwAvailPageFile;
swap->used = swap->total - swap->free; if (!sigar_GlobalMemoryStatusEx(&memstat)) {
return GetLastError();
}
swap->total = memstat.ullTotalPageFile;
swap->free = memstat.ullAvailPageFile;
}
else {
MEMORYSTATUS memstat;
GlobalMemoryStatus(&memstat);
swap->total = memstat.dwTotalPageFile;
swap->free = memstat.dwAvailPageFile;
}
swap->used = swap->total - swap->free;
return SIGAR_OK; return SIGAR_OK;
} }