1 #ifndef _ALPHA_SPINLOCK_H
2 #define _ALPHA_SPINLOCK_H
4 #include <linux/kernel.h>
5 #include <asm/current.h>
8 * Simple spin lock operations. There are two variants, one clears IRQ's
9 * on the local processor, one does not.
11 * We make no fairness assumptions. They have a cost.
14 #define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
15 #define arch_spin_is_locked(x) ((x)->lock != 0)
16 #define arch_spin_unlock_wait(x) \
17 do { cpu_relax(); } while ((x)->lock)
19 static inline void arch_spin_unlock(arch_spinlock_t
* lock
)
25 static inline void arch_spin_lock(arch_spinlock_t
* lock
)
41 : "=&r" (tmp
), "=m" (lock
->lock
)
42 : "m"(lock
->lock
) : "memory");
45 static inline int arch_spin_trylock(arch_spinlock_t
*lock
)
47 return !test_and_set_bit(0, &lock
->lock
);
50 /***********************************************************/
52 static inline int arch_read_can_lock(arch_rwlock_t
*lock
)
54 return (lock
->lock
& 1) == 0;
57 static inline int arch_write_can_lock(arch_rwlock_t
*lock
)
59 return lock
->lock
== 0;
62 static inline void arch_read_lock(arch_rwlock_t
*lock
)
78 : "=m" (*lock
), "=&r" (regx
)
79 : "m" (*lock
) : "memory");
82 static inline void arch_write_lock(arch_rwlock_t
*lock
)
98 : "=m" (*lock
), "=&r" (regx
)
99 : "m" (*lock
) : "memory");
102 static inline int arch_read_trylock(arch_rwlock_t
* lock
)
107 __asm__
__volatile__(
118 : "=m" (*lock
), "=&r" (regx
), "=&r" (success
)
119 : "m" (*lock
) : "memory");
124 static inline int arch_write_trylock(arch_rwlock_t
* lock
)
129 __asm__
__volatile__(
140 : "=m" (*lock
), "=&r" (regx
), "=&r" (success
)
141 : "m" (*lock
) : "memory");
146 static inline void arch_read_unlock(arch_rwlock_t
* lock
)
149 __asm__
__volatile__(
158 : "=m" (*lock
), "=&r" (regx
)
159 : "m" (*lock
) : "memory");
162 static inline void arch_write_unlock(arch_rwlock_t
* lock
)
168 #define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
169 #define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
171 #define arch_spin_relax(lock) cpu_relax()
172 #define arch_read_relax(lock) cpu_relax()
173 #define arch_write_relax(lock) cpu_relax()
175 #endif /* _ALPHA_SPINLOCK_H */