--- projects/libstatgrab/src/libstatgrab/memory_stats.c 2004/11/06 14:55:53 1.31 +++ projects/libstatgrab/src/libstatgrab/memory_stats.c 2005/09/24 13:29:22 1.32 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA * - * $Id: memory_stats.c,v 1.31 2004/11/06 14:55:53 ats Exp $ + * $Id: memory_stats.c,v 1.32 2005/09/24 13:29:22 tdb Exp $ */ #ifdef HAVE_CONFIG_H @@ -50,6 +50,10 @@ #include #include #endif +#ifdef WIN32 +#include +#include "win32.h" +#endif sg_mem_stats *sg_get_mem_stats(){ @@ -84,6 +88,9 @@ sg_mem_stats *sg_get_mem_stats(){ #if defined(NETBSD) || defined(OPENBSD) struct uvmexp *uvm; #endif +#ifdef WIN32 + MEMORYSTATUSEX memstats; +#endif #ifdef HPUX if((pagesize=sysconf(_SC_PAGESIZE)) == -1){ @@ -227,5 +234,18 @@ sg_mem_stats *sg_get_mem_stats(){ mem_stat.used = mem_stat.total - mem_stat.free; #endif +#ifdef WIN32 + memstats.dwLength = sizeof(memstats); + if (!GlobalMemoryStatusEx(&memstats)) { + sg_set_error_with_errno(SG_ERROR_MEMSTATUS, NULL); + return NULL; + } + mem_stat.free = memstats.ullAvailPhys; + mem_stat.total = memstats.ullTotalPhys; + mem_stat.used = mem_stat.total - mem_stat.free; + if(read_counter_large(SG_WIN32_MEM_CACHE, &mem_stat.cache)) { + mem_stat.cache = 0; + } +#endif return &mem_stat; }