From: Ken Thomases Subject: [PATCH 6/7] kernel32: Use the Mach host_info(HOST_BASIC_INFO) API to obtain total RAM after trying sysctl(HW_MEMSIZE) and before HW_PHYSMEM. Message-Id: Date: Sun, 16 Feb 2014 20:43:45 -0600 For . --- dlls/kernel32/heap.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) 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 #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;