Merge with Linux 2.3.40.
[linux-2.6/linux-mips.git] / include / asm-i386 / smplock.h
blob2c4b307911441760606493f4d936af6bbe595d2a
1 /*
2 * <asm/smplock.h>
4 * i386 SMP lock implementation
5 */
6 #include <linux/interrupt.h>
7 #include <linux/spinlock.h>
8 #include <linux/sched.h>
9 #include <asm/current.h>
11 extern spinlock_t kernel_flag;
14 * Release global kernel lock and global interrupt lock
16 #define release_kernel_lock(task, cpu) \
17 do { \
18 if (task->lock_depth >= 0) \
19 spin_unlock(&kernel_flag); \
20 release_irqlock(cpu); \
21 __sti(); \
22 } while (0)
25 * Re-acquire the kernel lock
27 #define reacquire_kernel_lock(task) \
28 do { \
29 if (task->lock_depth >= 0) \
30 spin_lock(&kernel_flag); \
31 } while (0)
35 * Getting the big kernel lock.
37 * This cannot happen asynchronously,
38 * so we only need to worry about other
39 * CPU's.
41 extern __inline__ void lock_kernel(void)
43 #if 1
44 if (!++current->lock_depth)
45 spin_lock(&kernel_flag);
46 #else
47 __asm__ __volatile__(
48 "incl %1\n\t"
49 "jne 9f"
50 spin_lock_string
51 "\n9:"
52 :"=m" (__dummy_lock(&kernel_flag)),
53 "=m" (current->lock_depth));
54 #endif
57 extern __inline__ void unlock_kernel(void)
59 if (current->lock_depth < 0)
60 BUG();
61 #if 1
62 if (--current->lock_depth < 0)
63 spin_unlock(&kernel_flag);
64 #else
65 __asm__ __volatile__(
66 "decl %1\n\t"
67 "jns 9f\n\t"
68 spin_unlock_string
69 "\n9:"
70 :"=m" (__dummy_lock(&kernel_flag)),
71 "=m" (current->lock_depth));
72 #endif