xref: /kvm-unit-tests/lib/asm-generic/spinlock.h (revision 2c96b77ec9d3b1fcec7525174e23a6240ee05949)
1 #ifndef _ASM_GENERIC_SPINLOCK_H_
2 #define _ASM_GENERIC_SPINLOCK_H_
3 
4 struct spinlock {
5     unsigned int v;
6 };
7 
8 static inline void spin_lock(struct spinlock *lock)
9 {
10 	while (__sync_lock_test_and_set(&lock->v, 1));
11 }
12 
13 static inline void spin_unlock(struct spinlock *lock)
14 {
15 	__sync_lock_release(&lock->v);
16 }
17 
18 #endif
19