Put 'void' in all function parameters for functions which take no parameters:
[comos.git] / kernel / critical.c
blob8618c69ed0cc02770f05bb8b21637b10ddd36775
1 #include "critical.h"
2 #include "general.h"
4 static volatile uint32_t spinlock = 0; /* volatile to not optimize the smp_lock loop away */
6 void critical_enter(void)
8 cli();
11 void critical_exit(void)
13 sti();
16 /* mb = memory barrier, used for code synchronization */
17 void memory_barrier(void)
19 asm volatile("mfence");
22 void smp_lock(void)
24 critical_enter(); /* disable interrupt */
25 memory_barrier(); /* syncronize */
26 asm volatile(
27 "lock_loop: "
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? */
31 ::"m"(spinlock));
34 void smp_unlock(void)
36 spinlock = 0; /* unlock */
37 critical_exit(); /* re-enable interrupts */