Changeset: 29c7db0aa321 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=29c7db0aa321 Modified Files: NT/monetdb_config.h.in clients/mapiclient/mclient.c configure.ag gdk/Makefile.ag gdk/gdk_posix.c gdk/gdk_system.c gdk/gdk_utils.mx Branch: Apr2012 Log Message:
Fix getrss implementation on Windows, get rid of some configure checks. We don't need to do configure checks for functions that only exist on Windows. Just use _MSC_VER for those. Also, we only support Windows >= XP. diffs (186 lines): diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in --- a/NT/monetdb_config.h.in +++ b/NT/monetdb_config.h.in @@ -168,27 +168,15 @@ /* Define to 1 if you have the `getopt_long' function. */ /* #undef HAVE_GETOPT_LONG */ -/* Define to 1 if you have the `GetProcessMemoryInfo' function. */ -#define HAVE_GETPROCESSMEMORYINFO 1 - /* Define to 1 if you have the `getrlimit' function. */ /* #undef HAVE_GETRLIMIT */ -/* Define to 1 if you have the `GetSystemInfo' function. */ -#define HAVE_GETSYSTEMINFO 1 - /* Define to 1 if you have the `gettimeofday' function. */ /* #undef HAVE_GETTIMEOFDAY */ /* Define to 1 if you have the `getuid' function. */ /* #undef HAVE_GETUID */ -/* Define to 1 if you have the `GlobalMemoryStatus' function. */ -#define HAVE_GLOBALMEMORYSTATUS 1 - -/* Define to 1 if you have the `GlobalMemoryStatusEx' function. */ -#define HAVE_GLOBALMEMORYSTATUSEX 1 /* only on >= NT 5 */ - /* Define if you have the iconv() function and it works. */ /* #undef HAVE_ICONV */ /* optionally defined in rules.msc */ @@ -380,9 +368,6 @@ /* Define to 1 if you have the <pwd.h> header file. */ /* #undef HAVE_PWD_H */ -/* Define to 1 if you have the `QueryPerformanceCounter' function. */ -#define HAVE_QUERYPERFORMANCECOUNTER 1 - /* Define if you have the raptor library */ /* #undef HAVE_RAPTOR */ diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -205,7 +205,7 @@ gettime(void) { /* Return the time in milliseconds since an epoch. The epoch is roughly the time this program started. */ -#ifdef HAVE_QUERYPERFORMANCECOUNTER +#ifdef _MSC_VER static LARGE_INTEGER freq, start; /* automatically initialized to 0 */ LARGE_INTEGER ctr; diff --git a/configure.ag b/configure.ag --- a/configure.ag +++ b/configure.ag @@ -1464,7 +1464,6 @@ mac*) QDIRSEP='\\' PATHSEP=';' SOEXT='-0.dll' - AC_DEFINE([HAVE_GLOBALMEMORYSTATUS], 1, [Define to 1 if you have the `GlobalMemoryStatus' function.]) ;; *cygwin*) DIRSEP='/' @@ -2575,8 +2574,6 @@ AC_CHECK_FUNCS([\ GetSystemInfo \ gettimeofday \ getuid \ - GlobalMemoryStatus \ - GlobalMemoryStatusEx \ isinf \ kill \ localtime_r \ @@ -2589,7 +2586,6 @@ AC_CHECK_FUNCS([\ posix_fadvise \ posix_madvise \ putenv \ - QueryPerformanceCounter \ round \ sbrk \ setenv \ diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag --- a/gdk/Makefile.ag +++ b/gdk/Makefile.ag @@ -49,5 +49,5 @@ lib_gdk = { ../common/stream/libstream \ ../common/utils/libmutils \ $(MATH_LIBS) $(SOCKET_LIBS) $(zlib_LIBS) $(BZ_LIBS) \ - $(MALLOC_LIBS) $(PTHREAD_LIBS) $(DL_LIBS) + $(MALLOC_LIBS) $(PTHREAD_LIBS) $(DL_LIBS) $(PSAPILIB) } diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c --- a/gdk/gdk_posix.c +++ b/gdk/gdk_posix.c @@ -742,12 +742,7 @@ MT_init_posix(void) size_t MT_getrss(void) { -#ifdef HAVE_GETPROCESSMEMORYINFO - PROCESS_MEMORY_COUNTERS ctr; - - if (GetProcessMemoryInfo(GetCurrentProcess(), &ctr, sizeof(ctr))) - return ctr.WorkingSetSize; -#elif defined(HAVE_PROCFS_H) && defined(__sun__) +#if defined(HAVE_PROCFS_H) && defined(__sun__) /* retrieve RSS the Solaris way (2.6+) */ static char MT_mmap_procfile[128] = { 0 }; int fd; @@ -966,6 +961,7 @@ mdlopen(const char *library, int mode) #ifdef _MSC_VER #include <io.h> #endif /* _MSC_VER */ +#include <Psapi.h> #define MT_SMALLBLOCK 256 @@ -987,18 +983,11 @@ MT_init_posix(void) size_t MT_getrss() { -#if (_WIN32_WINNT >= 0x0500) - MEMORYSTATUSEX state; + PROCESS_MEMORY_COUNTERS ctr; - state.dwLength = sizeof(state); - GlobalMemoryStatusEx(&state); - return (size_t) (state.ullTotalPhys - state.ullAvailPhys); -#else - MEMORYSTATUS state; - - GlobalMemoryStatus(&state); - return state.dwTotalPhys - state.dwAvailPhys; -#endif + if (GetProcessMemoryInfo(GetCurrentProcess(), &ctr, sizeof(ctr))) + return ctr.WorkingSetSize; + return 0; } char * diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c --- a/gdk/gdk_system.c +++ b/gdk/gdk_system.c @@ -691,7 +691,7 @@ GDKusec(void) { /* Return the time in milliseconds since an epoch. The epoch is roughly the time this program started. */ -#ifdef HAVE_QUERYPERFORMANCECOUNTER +#ifdef _MSC_VER static LARGE_INTEGER freq, start; /* automatically initialized to 0 */ LARGE_INTEGER ctr; diff --git a/gdk/gdk_utils.mx b/gdk/gdk_utils.mx --- a/gdk/gdk_utils.mx +++ b/gdk/gdk_utils.mx @@ -433,7 +433,7 @@ size_t _MT_npages = 0; /* variable hold void MT_init(void) { -#ifdef HAVE_GETSYSTEMINFO +#ifdef _MSC_VER { SYSTEM_INFO sysInfo; @@ -459,7 +459,7 @@ MT_init(void) if (_MT_pagesize <= 0) _MT_pagesize = 4096; /* default */ -#ifdef HAVE_GLOBALMEMORYSTATUSEX +#ifdef _MSC_VER { MEMORYSTATUSEX memStatEx; @@ -467,13 +467,6 @@ MT_init(void) if (GlobalMemoryStatusEx(&memStatEx)) _MT_npages = (size_t) (memStatEx.ullTotalPhys / _MT_pagesize); } -#elif defined(HAVE_GLOBALMEMORYSTATUS) - if (_MT_npages <= 0) { - MEMORYSTATUS memStat; - - GlobalMemoryStatus(&memStat); - _MT_npages = memStat.dwTotalPhys / _MT_pagesize; - } #elif defined(HAVE_SYS_SYSCTL_H) && defined(HW_MEMSIZE) && SIZEOF_SIZE_T == SIZEOF_LNG /* Darwin, 64-bits */ { _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list