2017-11-01 15:07:57 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2017-05-31 00:38:09 +00:00
|
|
|
#ifndef __LINUX_SPINLOCK_H_
|
|
|
|
|
#define __LINUX_SPINLOCK_H_
|
|
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
2016-12-16 14:53:45 -05:00
|
|
|
#define spinlock_t pthread_mutex_t
|
2018-05-18 16:08:54 -07:00
|
|
|
#define DEFINE_SPINLOCK(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER
|
2018-04-10 16:36:52 -07:00
|
|
|
#define __SPIN_LOCK_UNLOCKED(x) (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER
|
2017-11-10 09:34:31 -05:00
|
|
|
#define spin_lock_init(x) pthread_mutex_init(x, NULL)
|
2016-12-16 14:53:45 -05:00
|
|
|
|
2017-11-10 09:34:31 -05:00
|
|
|
#define spin_lock(x) pthread_mutex_lock(x)
|
|
|
|
|
#define spin_unlock(x) pthread_mutex_unlock(x)
|
|
|
|
|
#define spin_lock_bh(x) pthread_mutex_lock(x)
|
|
|
|
|
#define spin_unlock_bh(x) pthread_mutex_unlock(x)
|
|
|
|
|
#define spin_lock_irq(x) pthread_mutex_lock(x)
|
|
|
|
|
#define spin_unlock_irq(x) pthread_mutex_unlock(x)
|
2016-12-16 14:53:45 -05:00
|
|
|
#define spin_lock_irqsave(x, f) (void)f, pthread_mutex_lock(x)
|
|
|
|
|
#define spin_unlock_irqrestore(x, f) (void)f, pthread_mutex_unlock(x)
|
2017-05-31 00:38:09 +00:00
|
|
|
|
|
|
|
|
#define arch_spinlock_t pthread_mutex_t
|
|
|
|
|
#define __ARCH_SPIN_LOCK_UNLOCKED PTHREAD_MUTEX_INITIALIZER
|
|
|
|
|
|
|
|
|
|
static inline void arch_spin_lock(arch_spinlock_t *mutex)
|
|
|
|
|
{
|
|
|
|
|
pthread_mutex_lock(mutex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void arch_spin_unlock(arch_spinlock_t *mutex)
|
|
|
|
|
{
|
|
|
|
|
pthread_mutex_unlock(mutex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline bool arch_spin_is_locked(arch_spinlock_t *mutex)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|