From db6cc45f1c5adeacc37f8f16a27b9d5841fb2174 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 29 Jan 2007 23:30:39 +0000 Subject: [PATCH] [SIGAR-38] Change win32 swap_get to use GlobalMemoryStatusEx --- ChangeLog | 4 ++++ src/os/win32/win32_sigar.c | 25 ++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 89b7648b..9d3a0cba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-01-29 Doug MacEachern + + * [SIGAR-38] Change win32 swap_get to use GlobalMemoryStatusEx + 2007-01-24 Doug MacEachern * Add proper thread_cpu impl for OS X diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 3de3081b..05bc6ff6 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -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) { - MEMORYSTATUS memstat; + DLLMOD_INIT(kernel, TRUE); - GlobalMemoryStatus(&memstat); + if (sigar_GlobalMemoryStatusEx) { + MEMORYSTATUSEX memstat; - swap->total = memstat.dwTotalPageFile; - swap->free = memstat.dwAvailPageFile; - swap->used = swap->total - swap->free; + memstat.dwLength = sizeof(memstat); + + 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; }