4 static volatile uint32_t spinlock
= 0; /* volatile to not optimize the smp_lock loop away */
6 void critical_enter(void)
11 void critical_exit(void)
16 /* mb = memory barrier, used for code synchronization */
17 void memory_barrier(void)
19 asm volatile("mfence");
24 critical_enter(); /* disable interrupt */
25 memory_barrier(); /* syncronize */
28 " pause; " /* used to optimize loops on P4/Xeon's */
29 " lock btsl $0x00, %0; " /* if no lock is set, it will btsl (bit set long) */
30 " jc lock_loop; " /* still locked? */
36 spinlock
= 0; /* unlock */
37 critical_exit(); /* re-enable interrupts */