1 #ifndef _ASM_GENERIC_SPINLOCK_H_ 2 #define _ASM_GENERIC_SPINLOCK_H_ 3 4 struct spinlock { 5 unsigned int v; 6 }; 7 spin_lock(struct spinlock * lock)8static inline void spin_lock(struct spinlock *lock) 9 { 10 while (__sync_lock_test_and_set(&lock->v, 1)); 11 } 12 spin_unlock(struct spinlock * lock)13static inline void spin_unlock(struct spinlock *lock) 14 { 15 __sync_lock_release(&lock->v); 16 } 17 18 #endif 19