Andrew Jones | 3df0ccc | 2014-04-04 14:25:37 +0200 | [diff] [blame] | 1 | #ifndef _ASM_GENERIC_SPINLOCK_H_ |
2 | #define _ASM_GENERIC_SPINLOCK_H_ | ||||
David Hildenbrand | f98bf90 | 2017-05-15 13:03:46 +0200 | [diff] [blame] | 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 | |||||
Andrew Jones | 3df0ccc | 2014-04-04 14:25:37 +0200 | [diff] [blame] | 18 | #endif |