From f40c5484fc4a1b52e51be267e853f902743cac98 Mon Sep 17 00:00:00 2001 From: Ken Thomases Date: Sun, 16 Feb 2014 20:43:45 -0600 Subject: [PATCH] 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 fb0b07d4c1f..cd3a7526c73 100644 --- a/dlls/kernel32/heap.c +++ b/dlls/kernel32/heap.c @@ -40,6 +40,9 @@ #ifdef HAVE_UNISTD_H # include #endif +#ifdef HAVE_MACH_MACH_H +#include +#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; -- 2.11.4.GIT