Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-04-01 10:16:46 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-04-01 10:16:46 +0300
commit4738ae085dcfb6698c52060e3d68c83170760181 (patch)
treea54dcf390f3185eceae44ef501cb98776dd8fecf /intern/cycles/util/util_thread.h
parent314aa1767883275ecacd29ee20f590621c05c74e (diff)
Cycles: Fix for missing pthread's spin on OSX
Diffstat (limited to 'intern/cycles/util/util_thread.h')
-rw-r--r--intern/cycles/util/util_thread.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h
index d9cf452be13..59575f31c13 100644
--- a/intern/cycles/util/util_thread.h
+++ b/intern/cycles/util/util_thread.h
@@ -28,6 +28,10 @@
#include <pthread.h>
#include <queue>
+#ifdef __APPLE__
+# include <libkern/OSAtomic.h>
+#endif
+
#include "util_function.h"
CCL_NAMESPACE_BEGIN
@@ -85,6 +89,19 @@ protected:
class thread_spin_lock {
public:
+#ifdef __APPLE__
+ inline thread_spin_lock() {
+ spin_ = OS_SPINLOCK_INIT;
+ }
+
+ inline void lock() {
+ OSSpinLockLock(&spin_);
+ }
+
+ inline void unlock() {
+ OSSpinLockUnlock(&spin_);
+ }
+#else /* __APPLE__ */
inline thread_spin_lock() {
pthread_spin_init(&spin_, 0);
}
@@ -100,8 +117,13 @@ public:
inline void unlock() {
pthread_spin_unlock(&spin_);
}
+#endif /* __APPLE__ */
protected:
+#ifdef __APPLE__
+ OSSpinLock spin_;
+#else
pthread_spinlock_t spin_;
+#endif
};
CCL_NAMESPACE_END