Automatic merge of rsync://rsync.kernel.org/pub/scm/linux/kernel/git/gregkh/driver...
[linux-2.6/verdex.git] / include / linux / smp_lock.h
blobb63ce70140931e4f07079f50447b08de8bd63fcd
1 #ifndef __LINUX_SMPLOCK_H
2 #define __LINUX_SMPLOCK_H
4 #include <linux/config.h>
5 #include <linux/sched.h>
6 #include <linux/spinlock.h>
8 #ifdef CONFIG_LOCK_KERNEL
10 #define kernel_locked() (current->lock_depth >= 0)
12 extern int __lockfunc __reacquire_kernel_lock(void);
13 extern void __lockfunc __release_kernel_lock(void);
16 * Release/re-acquire global kernel lock for the scheduler
18 #define release_kernel_lock(tsk) do { \
19 if (unlikely((tsk)->lock_depth >= 0)) \
20 __release_kernel_lock(); \
21 } while (0)
24 * Non-SMP kernels will never block on the kernel lock,
25 * so we are better off returning a constant zero from
26 * reacquire_kernel_lock() so that the compiler can see
27 * it at compile-time.
29 #if defined(CONFIG_SMP) && !defined(CONFIG_PREEMPT_BKL)
30 # define return_value_on_smp return
31 #else
32 # define return_value_on_smp
33 #endif
35 static inline int reacquire_kernel_lock(struct task_struct *task)
37 if (unlikely(task->lock_depth >= 0))
38 return_value_on_smp __reacquire_kernel_lock();
39 return 0;
42 extern void __lockfunc lock_kernel(void) __acquires(kernel_lock);
43 extern void __lockfunc unlock_kernel(void) __releases(kernel_lock);
45 #else
47 #define lock_kernel() do { } while(0)
48 #define unlock_kernel() do { } while(0)
49 #define release_kernel_lock(task) do { } while(0)
50 #define reacquire_kernel_lock(task) 0
51 #define kernel_locked() 1
53 #endif /* CONFIG_LOCK_KERNEL */
54 #endif /* __LINUX_SMPLOCK_H */