1
0

spinlock.h 312 B

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