From cf6722af17d8d1a0dec0d8200a20c40ab9d9223c Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sat, 10 Nov 2018 16:36:15 +0100 Subject: [PATCH] Enable function GetProcessMemoryInfo() to get reliable memory usage data for MINGW and MSVC console, WinGui and MSVC shared ngspice. MINGW shared ngspice does not link to psapi.dll, so cannot apply GetProcessMemoryInfo(), but sticks to unreliable function GlobalMemoryStatusEx(). --- src/Makefile.am | 9 +++++++++ src/frontend/resource.c | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index 8db960473..9d893f68f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -334,6 +334,15 @@ if WINGUI LIBS += -lpsapi endif +if WINCONSOLE +LIBS += -lpsapi +endif + +## FIXME: Should be allwed, but fails within MSYS2 +#if SHWIN +#LIBS += -lpsapi +#endif + CLEANFILES = ngspice.idx spinit tclspinit pkgIndex.tcl MAINTAINERCLEANFILES = Makefile.in diff --git a/src/frontend/resource.c b/src/frontend/resource.c index bda68d1e7..1d1dd47a1 100644 --- a/src/frontend/resource.c +++ b/src/frontend/resource.c @@ -479,7 +479,8 @@ fprintmem(FILE *stream, unsigned long long memory) { static int get_procm(struct proc_mem *memall) { #if defined(_MSC_VER) || defined(__MINGW32__) -#if (_WIN32_WINNT >= 0x0500) && defined(HAS_WINGUI) + /* FIXME: shared module should be allowed, but currently does not link to psapi within MINGW/MSYS2 */ +#if (_WIN32_WINNT >= 0x0500) && (!defined(SHARED_MODULE) || _MSC_VER) /* Use Windows API function to obtain size of memory - more accurate */ HANDLE hProcess; PROCESS_MEMORY_COUNTERS pmc;