kernel.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef _LIBLOCKDEP_LINUX_KERNEL_H_
  2. #define _LIBLOCKDEP_LINUX_KERNEL_H_
  3. #include <linux/export.h>
  4. #include <linux/types.h>
  5. #include <linux/rcu.h>
  6. #include <linux/hardirq.h>
  7. #include <linux/kern_levels.h>
  8. #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
  9. #ifndef container_of
  10. #define container_of(ptr, type, member) ({ \
  11. const typeof(((type *)0)->member) * __mptr = (ptr); \
  12. (type *)((char *)__mptr - offsetof(type, member)); })
  13. #endif
  14. #define max(x, y) ({ \
  15. typeof(x) _max1 = (x); \
  16. typeof(y) _max2 = (y); \
  17. (void) (&_max1 == &_max2); \
  18. _max1 > _max2 ? _max1 : _max2; })
  19. #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
  20. static inline int lockdep_warn(int condition)
  21. {
  22. return condition;
  23. }
  24. #define WARN_ON(x) lockdep_warn(x)
  25. #define WARN_ON_ONCE(x) WARN_ON(x)
  26. #define WARN(x, y...) WARN_ON(x)
  27. #define likely(x) (x)
  28. #define uninitialized_var(x) x
  29. #define __init
  30. #define noinline
  31. #define list_add_tail_rcu list_add_tail
  32. #define list_for_each_entry_rcu list_for_each_entry
  33. #define barrier()
  34. #define synchronize_sched()
  35. #ifndef CALLER_ADDR0
  36. #define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  37. #endif
  38. #ifndef _RET_IP_
  39. #define _RET_IP_ CALLER_ADDR0
  40. #endif
  41. #ifndef _THIS_IP_
  42. #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
  43. #endif
  44. #endif