From e5e4e565122d292585ea3e15d30f0a5d5c61224c Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 20 Dec 2013 13:12:36 +0100 Subject: [PATCH] OSX fixes --- src/libcore/util.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libcore/util.cpp b/src/libcore/util.cpp index 8c584c29..c6e3c405 100644 --- a/src/libcore/util.cpp +++ b/src/libcore/util.cpp @@ -165,6 +165,13 @@ size_t getTotalSystemMemory() { status.dwLength = sizeof(status); GlobalMemoryStatusEx(&status); return (size_t) status.ullTotalPhys; +#elif defined(__OSX__) + int mib[2] = { CTL_HW, HW_MEMSIZE }; + uint64_t size; + size_t len = sizeof(size); + if (sysctl(mib, 2, &size, &len, NULL, 0) < 0) + return 0; + return (size_t) size; #else size_t pages = sysconf(_SC_PHYS_PAGES); size_t page_size = sysconf(_SC_PAGE_SIZE);