Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[deliverable/linux.git] / include / linux / smp_lock.h
CommitLineData
1da177e4
LT
1#ifndef __LINUX_SMPLOCK_H
2#define __LINUX_SMPLOCK_H
3
f037360f 4#ifdef CONFIG_LOCK_KERNEL
1da177e4 5#include <linux/sched.h>
1da177e4 6
1da177e4
LT
7#define kernel_locked() (current->lock_depth >= 0)
8
9extern int __lockfunc __reacquire_kernel_lock(void);
10extern void __lockfunc __release_kernel_lock(void);
11
12/*
13 * Release/re-acquire global kernel lock for the scheduler
14 */
15#define release_kernel_lock(tsk) do { \
16 if (unlikely((tsk)->lock_depth >= 0)) \
17 __release_kernel_lock(); \
18} while (0)
19
1da177e4
LT
20static inline int reacquire_kernel_lock(struct task_struct *task)
21{
22 if (unlikely(task->lock_depth >= 0))
6478d880 23 return __reacquire_kernel_lock();
1da177e4
LT
24 return 0;
25}
26
27extern void __lockfunc lock_kernel(void) __acquires(kernel_lock);
28extern void __lockfunc unlock_kernel(void) __releases(kernel_lock);
29
0b280676
JC
30/*
31 * Various legacy drivers don't really need the BKL in a specific
32 * function, but they *do* need to know that the BKL became available.
33 * This function just avoids wrapping a bunch of lock/unlock pairs
34 * around code which doesn't really need it.
35 */
36static inline void cycle_kernel_lock(void)
37{
38 lock_kernel();
39 unlock_kernel();
40}
41
1da177e4
LT
42#else
43
44#define lock_kernel() do { } while(0)
45#define unlock_kernel() do { } while(0)
46#define release_kernel_lock(task) do { } while(0)
0b280676 47#define cycle_kernel_lock() do { } while(0)
1da177e4
LT
48#define reacquire_kernel_lock(task) 0
49#define kernel_locked() 1
50
51#endif /* CONFIG_LOCK_KERNEL */
52#endif /* __LINUX_SMPLOCK_H */
This page took 0.710792 seconds and 5 git commands to generate.