--- projects/libstatgrab/src/libstatgrab/swap_stats.c 2004/11/06 15:41:30 1.23 +++ projects/libstatgrab/src/libstatgrab/swap_stats.c 2005/09/24 13:29:23 1.24 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA * - * $Id: swap_stats.c,v 1.23 2004/11/06 15:41:30 ats Exp $ + * $Id: swap_stats.c,v 1.24 2005/09/24 13:29:23 tdb Exp $ */ #ifdef HAVE_CONFIG_H @@ -59,6 +59,9 @@ #include #define SWAP_BATCH 5 #endif +#ifdef WIN32 +#include +#endif sg_swap_stats *sg_get_swap_stats(){ @@ -92,6 +95,9 @@ sg_swap_stats *sg_get_swap_stats(){ #if defined(NETBSD) || defined(OPENBSD) struct uvmexp *uvm; #endif +#ifdef WIN32 + MEMORYSTATUSEX memstats; +#endif #ifdef HPUX swap_stat.total = 0; @@ -219,6 +225,20 @@ sg_swap_stats *sg_get_swap_stats(){ swap_stat.total = (long long)uvm->pagesize * (long long)uvm->swpages; swap_stat.used = (long long)uvm->pagesize * (long long)uvm->swpginuse; swap_stat.free = swap_stat.total - swap_stat.used; +#endif +#ifdef WIN32 + memstats.dwLength = sizeof(memstats); + if (!GlobalMemoryStatusEx(&memstats)) { + sg_set_error_with_errno(SG_ERROR_MEMSTATUS, + "GloblaMemoryStatusEx"); + return NULL; + } + /* the PageFile stats include Phys memory "minus an overhead". + * Due to this unknown "overhead" there's no way to extract just page + * file use from these numbers */ + swap_stat.total = memstats.ullTotalPageFile; + swap_stat.free = memstats.ullAvailPageFile; + swap_stat.used = swap_stat.total - swap_stat.free; #endif return &swap_stat;