1 #ifndef __KERNEL_H_WRAPPER
2 #define __KERNEL_H_WRAPPER 1
4 #include_next <linux/kernel.h>
6 #include <linux/log2.h>
9 #include <linux/version.h>
10 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
12 #define pr_emerg(fmt, ...) \
13 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
15 #define pr_alert(fmt, ...) \
16 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
18 #define pr_crit(fmt, ...) \
19 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
21 #define pr_err(fmt, ...) \
22 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
24 #define pr_warning(fmt, ...) \
25 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
27 #define pr_notice(fmt, ...) \
28 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
30 #define pr_info(fmt, ...) \
31 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
33 #define pr_cont(fmt, ...) \
34 printk(KERN_CONT fmt, ##__VA_ARGS__)
37 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
38 #define pr_warn pr_warning
41 #ifndef BUILD_BUG_ON_NOT_POWER_OF_2
42 /* Force a compilation error if a constant expression is not a power of 2 */
43 #define BUILD_BUG_ON_NOT_POWER_OF_2(n) \
44 BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
47 #if defined(CONFIG_PREEMPT) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
48 #error "CONFIG_PREEMPT is broken before 2.6.21--see commit 4498121ca3, \"[NET]: Handle disabled preemption in gfp_any()\""
52 #define USHRT_MAX ((u16)(~0U))
53 #define SHRT_MAX ((s16)(USHRT_MAX>>1))
54 #define SHRT_MIN ((s16)(-SHRT_MAX - 1))
58 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
61 #endif /* linux/kernel.h */