summaryrefslogtreecommitdiff
path: root/rts/win32/OSMem.c
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2013-09-12 23:04:10 -0400
committerAustin Seipp <austin@well-typed.com>2013-10-25 09:14:29 -0500
commit72f8b8d694362890a424f5fa21fef37cee921ecf (patch)
treedf0af2a39e3472d22a0c7b261b40b68adf9412cf /rts/win32/OSMem.c
parent453a092e5f2b7abf35e7b0baa642658e0d545e9d (diff)
downloadhaskell-72f8b8d694362890a424f5fa21fef37cee921ecf.tar.gz
rts: Add getPhysicalMemorySize
Diffstat (limited to 'rts/win32/OSMem.c')
-rw-r--r--rts/win32/OSMem.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/rts/win32/OSMem.c b/rts/win32/OSMem.c
index 218b25df13..f350076c94 100644
--- a/rts/win32/OSMem.c
+++ b/rts/win32/OSMem.c
@@ -378,6 +378,24 @@ W_ getPageSize (void)
}
}
+/* Returns 0 if physical memory size cannot be identified */
+StgWord64 getPhysicalMemorySize (void)
+{
+ static StgWord64 physMemSize = 0;
+ if (!physMemSize) {
+ MEMORYSTATUSEX status;
+ status.dwLength = sizeof(status);
+ if (!GlobalMemoryStatusEx(&status)) {
+#if defined(DEBUG)
+ errorBelch("warning: getPhysicalMemorySize: cannot get physical memory size");
+#endif
+ return 0;
+ }
+ physMemSize = status.ullTotalPhys;
+ }
+ return physMemSize;
+}
+
void setExecutable (void *p, W_ len, rtsBool exec)
{
DWORD dwOldProtect = 0;