1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2e58e871bSLevin, Alexander (Sasha Levin) #ifndef __LINUX_SPINLOCK_H_
3e58e871bSLevin, Alexander (Sasha Levin) #define __LINUX_SPINLOCK_H_
4e58e871bSLevin, Alexander (Sasha Levin)
5e58e871bSLevin, Alexander (Sasha Levin) #include <pthread.h>
6e58e871bSLevin, Alexander (Sasha Levin) #include <stdbool.h>
7e58e871bSLevin, Alexander (Sasha Levin)
812ea6539SMatthew Wilcox #define spinlock_t pthread_mutex_t
9dcbbf25aSRoss Zwisler #define DEFINE_SPINLOCK(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER
10f6bb2a2cSMatthew Wilcox #define __SPIN_LOCK_UNLOCKED(x) (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER
11dcbbf25aSRoss Zwisler #define spin_lock_init(x) pthread_mutex_init(x, NULL)
1212ea6539SMatthew Wilcox
139b89a035SMatthew Wilcox #define spin_lock(x) pthread_mutex_lock(x)
14*b2472efeSPeng Zhang #define spin_lock_nested(x, subclass) pthread_mutex_lock(x)
159b89a035SMatthew Wilcox #define spin_unlock(x) pthread_mutex_unlock(x)
169b89a035SMatthew Wilcox #define spin_lock_bh(x) pthread_mutex_lock(x)
179b89a035SMatthew Wilcox #define spin_unlock_bh(x) pthread_mutex_unlock(x)
189b89a035SMatthew Wilcox #define spin_lock_irq(x) pthread_mutex_lock(x)
199b89a035SMatthew Wilcox #define spin_unlock_irq(x) pthread_mutex_unlock(x)
2012ea6539SMatthew Wilcox #define spin_lock_irqsave(x, f) (void)f, pthread_mutex_lock(x)
2112ea6539SMatthew Wilcox #define spin_unlock_irqrestore(x, f) (void)f, pthread_mutex_unlock(x)
22e58e871bSLevin, Alexander (Sasha Levin)
23e58e871bSLevin, Alexander (Sasha Levin) #define arch_spinlock_t pthread_mutex_t
24e58e871bSLevin, Alexander (Sasha Levin) #define __ARCH_SPIN_LOCK_UNLOCKED PTHREAD_MUTEX_INITIALIZER
25e58e871bSLevin, Alexander (Sasha Levin)
arch_spin_lock(arch_spinlock_t * mutex)26e58e871bSLevin, Alexander (Sasha Levin) static inline void arch_spin_lock(arch_spinlock_t *mutex)
27e58e871bSLevin, Alexander (Sasha Levin) {
28e58e871bSLevin, Alexander (Sasha Levin) pthread_mutex_lock(mutex);
29e58e871bSLevin, Alexander (Sasha Levin) }
30e58e871bSLevin, Alexander (Sasha Levin)
arch_spin_unlock(arch_spinlock_t * mutex)31e58e871bSLevin, Alexander (Sasha Levin) static inline void arch_spin_unlock(arch_spinlock_t *mutex)
32e58e871bSLevin, Alexander (Sasha Levin) {
33e58e871bSLevin, Alexander (Sasha Levin) pthread_mutex_unlock(mutex);
34e58e871bSLevin, Alexander (Sasha Levin) }
35e58e871bSLevin, Alexander (Sasha Levin)
arch_spin_is_locked(arch_spinlock_t * mutex)36e58e871bSLevin, Alexander (Sasha Levin) static inline bool arch_spin_is_locked(arch_spinlock_t *mutex)
37e58e871bSLevin, Alexander (Sasha Levin) {
38e58e871bSLevin, Alexander (Sasha Levin) return true;
39e58e871bSLevin, Alexander (Sasha Levin) }
40e58e871bSLevin, Alexander (Sasha Levin)
41e58e871bSLevin, Alexander (Sasha Levin) #endif
42