From 4738ae085dcfb6698c52060e3d68c83170760181 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 1 Apr 2016 09:16:46 +0200 Subject: Cycles: Fix for missing pthread's spin on OSX --- intern/cycles/util/util_thread.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'intern/cycles/util/util_thread.h') 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 #include +#ifdef __APPLE__ +# include +#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 -- cgit v1.2.3