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 int arch_spin_value_unlocked(arch_spinlock_t lock
)
21 return lock
.lock
== 0;
24 static inline void arch_spin_unlock(arch_spinlock_t
* lock
)
30 static inline void arch_spin_lock(arch_spinlock_t
* lock
)
46 : "=&r" (tmp
), "=m" (lock
->lock
)
47 : "m"(lock
->lock
) : "memory");
50 static inline int arch_spin_trylock(arch_spinlock_t
*lock
)
52 return !test_and_set_bit(0, &lock
->lock
);
55 /***********************************************************/
57 static inline int arch_read_can_lock(arch_rwlock_t
*lock
)
59 return (lock
->lock
& 1) == 0;
62 static inline int arch_write_can_lock(arch_rwlock_t
*lock
)
64 return lock
->lock
== 0;
67 static inline void arch_read_lock(arch_rwlock_t
*lock
)
83 : "=m" (*lock
), "=&r" (regx
)
84 : "m" (*lock
) : "memory");
87 static inline void arch_write_lock(arch_rwlock_t
*lock
)
103 : "=m" (*lock
), "=&r" (regx
)
104 : "m" (*lock
) : "memory");
107 static inline int arch_read_trylock(arch_rwlock_t
* lock
)
112 __asm__
__volatile__(
123 : "=m" (*lock
), "=&r" (regx
), "=&r" (success
)
124 : "m" (*lock
) : "memory");
129 static inline int arch_write_trylock(arch_rwlock_t
* lock
)
134 __asm__
__volatile__(
145 : "=m" (*lock
), "=&r" (regx
), "=&r" (success
)
146 : "m" (*lock
) : "memory");
151 static inline void arch_read_unlock(arch_rwlock_t
* lock
)
154 __asm__
__volatile__(
163 : "=m" (*lock
), "=&r" (regx
)
164 : "m" (*lock
) : "memory");
167 static inline void arch_write_unlock(arch_rwlock_t
* lock
)
173 #define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
174 #define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
176 #endif /* _ALPHA_SPINLOCK_H */