cleanup
[linux-2.4.21-pre4.git] / include / asm-alpha / smplock.h
1 /*
2  * <asm/smplock.h>
3  *
4  * Default SMP lock implementation
5  */
6
7 #include <linux/sched.h>
8 #include <linux/interrupt.h>
9 #include <linux/spinlock.h>
10
11 extern spinlock_t kernel_flag;
12
13 #define kernel_locked()         spin_is_locked(&kernel_flag)
14
15 /*
16  * Release global kernel lock and global interrupt lock
17  */
18 static __inline__ void release_kernel_lock(struct task_struct *task, int cpu)
19 {
20         if (task->lock_depth >= 0)
21                 spin_unlock(&kernel_flag);
22         release_irqlock(cpu);
23         __sti();
24 }
25
26 /*
27  * Re-acquire the kernel lock
28  */
29 static __inline__ void reacquire_kernel_lock(struct task_struct *task)
30 {
31         if (task->lock_depth >= 0)
32                 spin_lock(&kernel_flag);
33 }
34
35 /*
36  * Getting the big kernel lock.
37  *
38  * This cannot happen asynchronously,
39  * so we only need to worry about other
40  * CPU's.
41  */
42 static __inline__ void lock_kernel(void)
43 {
44         if (!++current->lock_depth)
45                 spin_lock(&kernel_flag);
46 }
47
48 static __inline__ void unlock_kernel(void)
49 {
50         if (--current->lock_depth < 0)
51                 spin_unlock(&kernel_flag);
52 }