diff options
author | Wan-Teh Chang <wtc@google.com> | 2013-03-29 14:37:05 -0700 |
---|---|---|
committer | Wan-Teh Chang <wtc@google.com> | 2013-03-29 14:37:05 -0700 |
commit | 696bc2e26af1006df50029820bb982e72cc58e42 (patch) | |
tree | e85439b752b437902663dbaf2c638f18bcdd6709 | |
parent | a2c755f9dfc2e5a67943fa6aa5ffb7e7ed7fcd4e (diff) | |
download | nspr-hg-696bc2e26af1006df50029820bb982e72cc58e42.tar.gz |
Bug 687033: assume GlobalMemoryStatusEx is available (true for Windows
2000 and later). r=m_kato.
-rw-r--r-- | pr/src/misc/prsystem.c | 45 |
1 files changed, 4 insertions, 41 deletions
diff --git a/pr/src/misc/prsystem.c b/pr/src/misc/prsystem.c index f79d5884..9579fcc9 100644 --- a/pr/src/misc/prsystem.c +++ b/pr/src/misc/prsystem.c @@ -56,24 +56,6 @@ #include <sys/cfgodm.h> #endif -#if defined(WIN32) -/* This struct is not present in VC6 headers, so declare it here */ -typedef struct { - DWORD dwLength; - DWORD dwMemoryLoad; - DWORDLONG ullTotalPhys; - DWORDLONG ullAvailPhys; - DWORDLONG ullToalPageFile; - DWORDLONG ullAvailPageFile; - DWORDLONG ullTotalVirtual; - DWORDLONG ullAvailVirtual; - DWORDLONG ullAvailExtendedVirtual; -} PR_MEMORYSTATUSEX; - -/* Typedef for dynamic lookup of GlobalMemoryStatusEx(). */ -typedef BOOL (WINAPI *GlobalMemoryStatusExFn)(PR_MEMORYSTATUSEX *); -#endif - PR_IMPLEMENT(char) PR_GetDirectorySeparator(void) { return PR_DIRECTORY_SEPARATOR; @@ -327,29 +309,10 @@ PR_IMPLEMENT(PRUint64) PR_GetPhysicalMemorySize(void) #elif defined(WIN32) - /* Try to use the newer GlobalMemoryStatusEx API for Windows 2000+. */ - GlobalMemoryStatusExFn globalMemory = (GlobalMemoryStatusExFn) NULL; - HMODULE module = GetModuleHandleW(L"kernel32.dll"); - - if (module) { - globalMemory = (GlobalMemoryStatusExFn)GetProcAddress(module, "GlobalMemoryStatusEx"); - - if (globalMemory) { - PR_MEMORYSTATUSEX memStat; - memStat.dwLength = sizeof(memStat); - - if (globalMemory(&memStat)) - bytes = memStat.ullTotalPhys; - } - } - - if (!bytes) { - /* Fall back to the older API. */ - MEMORYSTATUS memStat; - memset(&memStat, 0, sizeof(memStat)); - GlobalMemoryStatus(&memStat); - bytes = memStat.dwTotalPhys; - } + MEMORYSTATUSEX memStat; + memStat.dwLength = sizeof(memStat); + if (GlobalMemoryStatusEx(&memStat)) + bytes = memStat.ullTotalPhys; #elif defined(OS2) |