Ken Thomases : kernel32: Use the Mach host_info(HOST_BASIC_INFO) API to obtain total RAM after trying sysctl(HW_MEMSIZE) and before HW_PHYSMEM.

Alexandre Julliard julliard at winehq.org
Mon Feb 17 13:45:14 CST 2014


Module: wine
Branch: master
Commit: f40c5484fc4a1b52e51be267e853f902743cac98
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f40c5484fc4a1b52e51be267e853f902743cac98

Author: Ken Thomases <ken at codeweavers.com>
Date:   Sun Feb 16 20:43:45 2014 -0600

kernel32: Use the Mach host_info(HOST_BASIC_INFO) API to obtain total RAM after trying sysctl(HW_MEMSIZE) and before HW_PHYSMEM.

---

 dlls/kernel32/heap.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/dlls/kernel32/heap.c b/dlls/kernel32/heap.c
index fb0b07d..cd3a752 100644
--- a/dlls/kernel32/heap.c
+++ b/dlls/kernel32/heap.c
@@ -40,6 +40,9 @@
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
+#ifdef HAVE_MACH_MACH_H
+#include <mach/mach.h>
+#endif
 
 #ifdef sun
 /* FIXME:  Unfortunately swapctl can't be used with largefile.... */
@@ -1236,6 +1239,25 @@ BOOL WINAPI GlobalMemoryStatusEx( LPMEMORYSTATUSEX lpmemex )
         total = val64;
 #endif
 
+#ifdef HAVE_MACH_MACH_H
+    if (!total)
+    {
+        host_name_port_t host;
+        mach_msg_type_number_t count;
+        kern_return_t kr;
+        host_basic_info_data_t info;
+
+        host = mach_host_self();
+
+        count = HOST_BASIC_INFO_COUNT;
+        kr = host_info(host, HOST_BASIC_INFO, (host_info_t)&info, &count);
+        if (kr == KERN_SUCCESS)
+            total = info.max_mem;
+
+        mach_port_deallocate(mach_task_self(), host);
+    }
+#endif
+
     if (!total)
     {
         mib[1] = HW_PHYSMEM;




More information about the wine-cvs mailing list