1 /* 2 * Copyright 2008 Google Inc. All Rights Reserved. 3 * Author: md@google.com (Michael Davidson) 4 * 5 * Based on time-warp-test.c, which is: 6 * Copyright (C) 2005, Ingo Molnar 7 */ 8 9 #ifndef SPINLOCK_H_ 10 #define SPINLOCK_H_ 11 12 typedef unsigned long spinlock_t; 13 spin_lock(spinlock_t * lock)14static inline void spin_lock(spinlock_t *lock) 15 { 16 __asm__ __volatile__( 17 "1: rep; nop\n" 18 " lock; btsl $0,%0\n" 19 "jc 1b\n" 20 : "=g"(*lock) : : "memory"); 21 } 22 spin_unlock(spinlock_t * lock)23static inline void spin_unlock(spinlock_t *lock) 24 { 25 __asm__ __volatile__("movl $0,%0; rep; nop" : "=g"(*lock) :: "memory"); 26 } 27 28 #endif /* SPINLOCK_H_ */ 29