1 #ifndef _ASM_X86_SPINLOCK_H
2 #define _ASM_X86_SPINLOCK_H
6 #include <asm/processor.h>
7 #include <linux/compiler.h>
8 #include <asm/paravirt.h>
21 # define LOCK_PTR_REG "a"
23 # define LOCK_PTR_REG "D"
26 #if defined(CONFIG_X86_32) && \
27 (defined(CONFIG_X86_OOSTORE) || defined(CONFIG_X86_PPRO_FENCE))
32 # define UNLOCK_LOCK_PREFIX LOCK_PREFIX
34 # define UNLOCK_LOCK_PREFIX
52 register struct __raw_tickets inc = { .tail = 1 };
57 if (inc.head == inc.tail)
76 return cmpxchg(&lock->head_tail, old.head_tail,
new.head_tail) == old.head_tail;
88 return tmp.tail != tmp.head;
98 #ifndef CONFIG_PARAVIRT_SPINLOCKS
102 return __ticket_spin_is_locked(lock);
107 return __ticket_spin_is_contended(lock);
109 #define arch_spin_is_contended arch_spin_is_contended
113 __ticket_spin_lock(lock);
118 return __ticket_spin_trylock(lock);
123 __ticket_spin_unlock(lock);
160 return lock->
lock > 0;
176 "call __read_lock_failed\n\t"
185 "call __write_lock_failed\n\t"
214 :
"+m" (rw->
lock) : :
"memory");
223 #define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
224 #define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
226 #undef READ_LOCK_SIZE
227 #undef READ_LOCK_ATOMIC
228 #undef WRITE_LOCK_ADD
229 #undef WRITE_LOCK_SUB
230 #undef WRITE_LOCK_CMP
232 #define arch_spin_relax(lock) cpu_relax()
233 #define arch_read_relax(lock) cpu_relax()
234 #define arch_write_relax(lock) cpu_relax()
237 static inline void smp_mb__after_lock(
void) { }
238 #define ARCH_HAS_SMP_MB_AFTER_LOCK