summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authorJeffrey Pfau <jeffrey@endrift.com>2015-06-10 22:15:11 -0700
committerJeffrey Pfau <jeffrey@endrift.com>2015-06-13 21:52:47 -0700
commit7085fcc8d66267429fc6734be4ff0c563b9ff50a (patch)
treebff7cd87fe9b9e1f156154b9057dfba057a875f1 /Source/Core/Common
parent0ca955a14c9a23a12deabb62502a4d2703f9c47b (diff)
Fix FreeBSD build
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/FileUtil.cpp2
-rw-r--r--Source/Core/Common/MemoryUtil.cpp8
-rw-r--r--Source/Core/Common/Thread.cpp10
3 files changed, 15 insertions, 5 deletions
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp
index 925e3f1ed3..4709c011b2 100644
--- a/Source/Core/Common/FileUtil.cpp
+++ b/Source/Core/Common/FileUtil.cpp
@@ -42,7 +42,7 @@
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
#endif
-#ifdef BSD4_4
+#if defined BSD4_4 || defined __FreeBSD__
#define stat64 stat
#define fstat64 fstat
#endif
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;
diff --git a/Source/Core/Common/Thread.cpp b/Source/Core/Common/Thread.cpp
index fb091ee2a7..1e60fbb29f 100644
--- a/Source/Core/Common/Thread.cpp
+++ b/Source/Core/Common/Thread.cpp
@@ -8,7 +8,7 @@
#ifdef __APPLE__
#include <mach/mach.h>
-#elif defined BSD4_4
+#elif defined BSD4_4 || defined __FreeBSD__
#include <pthread_np.h>
#endif
@@ -94,8 +94,12 @@ void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)
#ifdef __APPLE__
thread_policy_set(pthread_mach_thread_np(thread),
THREAD_AFFINITY_POLICY, (integer_t *)&mask, 1);
-#elif (defined __linux__ || defined BSD4_4) && !(defined ANDROID)
+#elif (defined __linux__ || defined BSD4_4 || defined __FreeBSD__) && !(defined ANDROID)
+#ifdef __FreeBSD__
+ cpuset_t cpu_set;
+#else
cpu_set_t cpu_set;
+#endif
CPU_ZERO(&cpu_set);
for (int i = 0; i != sizeof(mask) * 8; ++i)
@@ -125,6 +129,8 @@ void SetCurrentThreadName(const char* szThreadName)
{
#ifdef __APPLE__
pthread_setname_np(szThreadName);
+#elif defined __FreeBSD__
+ pthread_set_name_np(pthread_self(), szThreadName);
#else
pthread_setname_np(pthread_self(), szThreadName);
#endif