5#include "mos/platform/platform_defs.hpp"
10#define barrier() MOS_PLATFORM_MEMORY_BARRIER()
16#if MOS_DEBUG_FEATURE(spinlock)
17 const char *file =
nullptr;
24#define spinlock_init(lock) \
31#define SPINLOCK_INIT { 0 }
34#define _spinlock_real_acquire(lock) \
38 while (__atomic_test_and_set(&(lock)->flag, __ATOMIC_ACQUIRE)) \
42#define _spinlock_real_release(lock) \
45 __atomic_clear(&(lock)->flag, __ATOMIC_RELEASE); \
48#if MOS_DEBUG_FEATURE(spinlock)
49#define spinlock_acquire(lock) \
52 _spinlock_real_acquire(lock); \
53 (lock)->file = __FILE__; \
54 (lock)->line = __LINE__; \
56#define spinlock_release(lock) \
59 (lock)->file = NULL; \
61 _spinlock_real_release(lock); \
64#define spinlock_acquire(lock) _spinlock_real_acquire(lock)
65#define spinlock_release(lock) _spinlock_real_release(lock)
68#define spinlock_acquire_nodebug(lock) _spinlock_real_acquire(lock)
69#define spinlock_release_nodebug(lock) _spinlock_real_release(lock)
84#define RECURSIVE_SPINLOCK_INIT { SPINLOCK_INIT, NULL, 0 }
89 if (lock->
owner == owner)
103 if (lock->
owner == owner)
106 if (lock->
count == 0)
133 other.m_lock =
nullptr;
142 other.m_lock =
nullptr;
SpinLocker & operator=(SpinLocker &&other)
SpinLocker(const SpinLocker &)=delete
SpinLocker(SpinLocker &&other)
SpinLocker(spinlock_t *lock)
SpinLocker & operator=(const SpinLocker &)=delete
should_inline bool spinlock_is_locked(const spinlock_t *lock)
should_inline void recursive_spinlock_release(recursive_spinlock_t *lock, void *owner)
#define spinlock_acquire(lock)
should_inline bool recursive_spinlock_is_locked(recursive_spinlock_t *lock)
should_inline void recursive_spinlock_acquire(recursive_spinlock_t *lock, void *owner)
#define spinlock_release(lock)