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