/include/linux/smp_lock.h

https://bitbucket.org/thekraven/iscream_thunderc-2.6.35 · C++ Header · 65 lines · 43 code · 13 blank · 9 comment · 7 complexity · af723df5c24229eafb5250e4e7508881 MD5 · raw file

  1. #ifndef __LINUX_SMPLOCK_H
  2. #define __LINUX_SMPLOCK_H
  3. #ifdef CONFIG_LOCK_KERNEL
  4. #include <linux/sched.h>
  5. #define kernel_locked() (current->lock_depth >= 0)
  6. extern int __lockfunc __reacquire_kernel_lock(void);
  7. extern void __lockfunc __release_kernel_lock(void);
  8. /*
  9. * Release/re-acquire global kernel lock for the scheduler
  10. */
  11. #define release_kernel_lock(tsk) do { \
  12. if (unlikely((tsk)->lock_depth >= 0)) \
  13. __release_kernel_lock(); \
  14. } while (0)
  15. static inline int reacquire_kernel_lock(struct task_struct *task)
  16. {
  17. if (unlikely(task->lock_depth >= 0))
  18. return __reacquire_kernel_lock();
  19. return 0;
  20. }
  21. extern void __lockfunc
  22. _lock_kernel(const char *func, const char *file, int line)
  23. __acquires(kernel_lock);
  24. extern void __lockfunc
  25. _unlock_kernel(const char *func, const char *file, int line)
  26. __releases(kernel_lock);
  27. #define lock_kernel() do { \
  28. _lock_kernel(__func__, __FILE__, __LINE__); \
  29. } while (0)
  30. #define unlock_kernel() do { \
  31. _unlock_kernel(__func__, __FILE__, __LINE__); \
  32. } while (0)
  33. /*
  34. * Various legacy drivers don't really need the BKL in a specific
  35. * function, but they *do* need to know that the BKL became available.
  36. * This function just avoids wrapping a bunch of lock/unlock pairs
  37. * around code which doesn't really need it.
  38. */
  39. static inline void cycle_kernel_lock(void)
  40. {
  41. lock_kernel();
  42. unlock_kernel();
  43. }
  44. #else
  45. #define lock_kernel()
  46. #define unlock_kernel()
  47. #define release_kernel_lock(task) do { } while(0)
  48. #define cycle_kernel_lock() do { } while(0)
  49. #define reacquire_kernel_lock(task) 0
  50. #define kernel_locked() 1
  51. #endif /* CONFIG_LOCK_KERNEL */
  52. #endif /* __LINUX_SMPLOCK_H */