[Bf-blender-cvs] [04133ee863b] master: Revert "macOS: Replaced OSSpinLock with os_unfair_lock."

Stefan Werner noreply at git.blender.org
Mon Sep 30 08:29:43 CEST 2019


Commit: 04133ee863b43d1a595ce049685c6a2347ffd3ad
Author: Stefan Werner
Date:   Mon Sep 30 08:28:56 2019 +0200
Branches: master
https://developer.blender.org/rB04133ee863b43d1a595ce049685c6a2347ffd3ad

Revert "macOS: Replaced OSSpinLock with os_unfair_lock."

This reverts commit 9d282d7a8d689a17ae58e94453ae99a41e91b701.
os_unfair_lock requires macOS 10.12 or newer.

===================================================================

M	intern/cycles/util/util_thread.h
M	source/blender/blenlib/BLI_threads.h
M	source/blender/blenlib/intern/threads.c

===================================================================

diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h
index a9cfc309e0d..18ec5b32144 100644
--- a/intern/cycles/util/util_thread.h
+++ b/intern/cycles/util/util_thread.h
@@ -30,7 +30,7 @@
 #endif
 
 #ifdef __APPLE__
-#  include <os/lock.h>
+#  include <libkern/OSAtomic.h>
 #endif
 
 #include "util/util_function.h"
@@ -72,17 +72,17 @@ class thread_spin_lock {
 #ifdef __APPLE__
   inline thread_spin_lock()
   {
-    spin_ = OS_UNFAIR_LOCK_INIT;
+    spin_ = OS_SPINLOCK_INIT;
   }
 
   inline void lock()
   {
-    os_unfair_lock_lock(&spin_);
+    OSSpinLockLock(&spin_);
   }
 
   inline void unlock()
   {
-    os_unfair_lock_unlock(&spin_);
+    OSSpinLockUnlock(&spin_);
   }
 #elif defined(_WIN32)
   inline thread_spin_lock()
@@ -128,7 +128,7 @@ class thread_spin_lock {
 #endif
  protected:
 #ifdef __APPLE__
-  os_unfair_lock spin_;
+  OSSpinLock spin_;
 #elif defined(_WIN32)
   CRITICAL_SECTION cs_;
 #else
diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index b7ad6e543f1..32b7f219605 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -30,7 +30,7 @@ extern "C" {
 #include <pthread.h>
 
 #ifdef __APPLE__
-#  include <os/lock.h>
+#  include <libkern/OSAtomic.h>
 #endif
 
 /* for tables, button in UI, etc */
@@ -103,7 +103,7 @@ void BLI_mutex_unlock(ThreadMutex *mutex);
 /* Spin Lock */
 
 #if defined(__APPLE__)
-typedef os_unfair_lock SpinLock;
+typedef OSSpinLock SpinLock;
 #elif defined(_MSC_VER)
 typedef volatile int SpinLock;
 #else
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 18893ad1445..3c87df55b2b 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -480,7 +480,7 @@ void BLI_mutex_free(ThreadMutex *mutex)
 void BLI_spin_init(SpinLock *spin)
 {
 #if defined(__APPLE__)
-  *spin = OS_UNFAIR_LOCK_INIT;
+  *spin = OS_SPINLOCK_INIT;
 #elif defined(_MSC_VER)
   *spin = 0;
 #else
@@ -491,7 +491,7 @@ void BLI_spin_init(SpinLock *spin)
 void BLI_spin_lock(SpinLock *spin)
 {
 #if defined(__APPLE__)
-  os_unfair_lock_lock(spin);
+  OSSpinLockLock(spin);
 #elif defined(_MSC_VER)
   while (InterlockedExchangeAcquire(spin, 1)) {
     while (*spin) {
@@ -507,7 +507,7 @@ void BLI_spin_lock(SpinLock *spin)
 void BLI_spin_unlock(SpinLock *spin)
 {
 #if defined(__APPLE__)
-  os_unfair_lock_unlock(spin);
+  OSSpinLockUnlock(spin);
 #elif defined(_MSC_VER)
   _ReadWriteBarrier();
   *spin = 0;



More information about the Bf-blender-cvs mailing list