5 * lock.h - Hardware level spinlocks
11 struct sShortSpinlock {
16 static inline int IS_LOCKED(struct sShortSpinlock *Lock)
21 static inline int CPU_HAS_LOCK(struct sShortSpinlock *Lock)
23 // TODO: Handle multiple CPUs
27 static inline int SHORTLOCK(struct sShortSpinlock *Lock)
30 while( __sync_lock_test_and_set( &Lock->Lock, 1 ) == 1 );
38 __asm__ __volatile__ ("swp [%0], %1" : "=r" (v) : "r" (&lock));
41 // Shamelessly copied from linux (/arch/arm/include/asm/spinlock.h) until I can fix stuff
43 __asm__ __volatile__ (
46 " strexeq %0, %2, [%1]\n" // Magic? TODO: Look up
50 : "r" (&Lock->Lock), "r" (1)
51 : "cc" // Condition codes clobbered
57 static inline void SHORTREL(struct sShortSpinlock *Lock)