macOS: Replaced OSSpinLock with os_unfair_lock.
OSSplinLock is a deprecated API, os_unfair_lock is its successor. This reduces the number of warnings when building on macOS.
This commit is contained in:
parent
ea70bd2abf
commit
9d282d7a8d
Notes:
blender-bot
2023-02-14 00:44:02 +01:00
Referenced by commit 04133ee863
, Revert "macOS: Replaced OSSpinLock with os_unfair_lock."
|
@ -30,7 +30,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <libkern/OSAtomic.h>
|
||||
# include <os/lock.h>
|
||||
#endif
|
||||
|
||||
#include "util/util_function.h"
|
||||
|
@ -72,17 +72,17 @@ class thread_spin_lock {
|
|||
#ifdef __APPLE__
|
||||
inline thread_spin_lock()
|
||||
{
|
||||
spin_ = OS_SPINLOCK_INIT;
|
||||
spin_ = OS_UNFAIR_LOCK_INIT;
|
||||
}
|
||||
|
||||
inline void lock()
|
||||
{
|
||||
OSSpinLockLock(&spin_);
|
||||
os_unfair_lock_lock(&spin_);
|
||||
}
|
||||
|
||||
inline void unlock()
|
||||
{
|
||||
OSSpinLockUnlock(&spin_);
|
||||
os_unfair_lock_unlock(&spin_);
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
inline thread_spin_lock()
|
||||
|
@ -128,7 +128,7 @@ class thread_spin_lock {
|
|||
#endif
|
||||
protected:
|
||||
#ifdef __APPLE__
|
||||
OSSpinLock spin_;
|
||||
os_unfair_lock spin_;
|
||||
#elif defined(_WIN32)
|
||||
CRITICAL_SECTION cs_;
|
||||
#else
|
||||
|
|
|
@ -30,7 +30,7 @@ extern "C" {
|
|||
#include <pthread.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <libkern/OSAtomic.h>
|
||||
# include <os/lock.h>
|
||||
#endif
|
||||
|
||||
/* for tables, button in UI, etc */
|
||||
|
@ -103,7 +103,7 @@ void BLI_mutex_unlock(ThreadMutex *mutex);
|
|||
/* Spin Lock */
|
||||
|
||||
#if defined(__APPLE__)
|
||||
typedef OSSpinLock SpinLock;
|
||||
typedef os_unfair_lock SpinLock;
|
||||
#elif defined(_MSC_VER)
|
||||
typedef volatile int SpinLock;
|
||||
#else
|
||||
|
|
|
@ -480,7 +480,7 @@ void BLI_mutex_free(ThreadMutex *mutex)
|
|||
void BLI_spin_init(SpinLock *spin)
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
*spin = OS_SPINLOCK_INIT;
|
||||
*spin = OS_UNFAIR_LOCK_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__)
|
||||
OSSpinLockLock(spin);
|
||||
os_unfair_lock_lock(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__)
|
||||
OSSpinLockUnlock(spin);
|
||||
os_unfair_lock_unlock(spin);
|
||||
#elif defined(_MSC_VER)
|
||||
_ReadWriteBarrier();
|
||||
*spin = 0;
|
||||
|
|
Loading…
Reference in New Issue