summaryrefslogtreecommitdiff
path: root/Source/Core/Common/MemoryUtil.cpp
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2015-07-13 19:51:18 +1200
committerScott Mansell <phiren@gmail.com>2015-07-13 19:51:18 +1200
commitda38e3a8ae7be05ca783e72f0bce821dc23646bd (patch)
treed9522fbe017dfe00fe2bd5cde44d3554c3e6ab00 /Source/Core/Common/MemoryUtil.cpp
parent87e19f1c190719bd1280eb94bcdf372caca5287b (diff)
parentfff113b64ffbb673d803d18c28f833c7d2b6c02d (diff)
Merge pull request #2741 from endrift/fix-freebsd-build-stable
Fix FreeBSD (stable)
Diffstat (limited to 'Source/Core/Common/MemoryUtil.cpp')
-rw-r--r--Source/Core/Common/MemoryUtil.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Source/Core/Common/MemoryUtil.cpp b/Source/Core/Common/MemoryUtil.cpp
index 510b258b09..c2befe56a6 100644
--- a/Source/Core/Common/MemoryUtil.cpp
+++ b/Source/Core/Common/MemoryUtil.cpp
@@ -20,7 +20,7 @@
#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
-#ifdef __APPLE__
+#if defined __APPLE__ || defined __FreeBSD__
#include <sys/sysctl.h>
#else
#include <sys/sysinfo.h>
@@ -256,11 +256,15 @@ size_t MemPhysical()
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&memInfo);
return memInfo.ullTotalPhys;
-#elif defined(__APPLE__)
+#elif defined __APPLE__ || defined __FreeBSD__
int mib[2];
size_t physical_memory;
mib[0] = CTL_HW;
+#ifdef __APPLE__
mib[1] = HW_MEMSIZE;
+#elif defined __FreeBSD__
+ mib[1] = HW_REALMEM;
+#endif
size_t length = sizeof(size_t);
sysctl(mib, 2, &physical_memory, &length, NULL, 0);
return physical_memory;