Setting tag sliver-openvswitch-2.2.90-1
[sliver-openvswitch.git] / datapath / linux / compat / include / linux / kernel.h
1 #ifndef __KERNEL_H_WRAPPER
2 #define __KERNEL_H_WRAPPER 1
3
4 #include_next <linux/kernel.h>
5 #ifndef HAVE_LOG2_H
6 #include <linux/log2.h>
7 #endif
8
9 #include <linux/version.h>
10
11 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
12 #define pr_warn pr_warning
13 #endif
14
15 /*
16  * Print a one-time message (analogous to WARN_ONCE() et al):
17  */
18 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 38)
19 #undef printk_once
20 #define printk_once(fmt, ...)                   \
21 ({                                              \
22         static bool __print_once;               \
23                                                 \
24         if (!__print_once) {                    \
25                 __print_once = true;            \
26                 printk(fmt, ##__VA_ARGS__);     \
27         }                                       \
28 })
29
30 #define pr_emerg_once(fmt, ...)                                 \
31         printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
32 #define pr_alert_once(fmt, ...)                                 \
33         printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
34 #define pr_crit_once(fmt, ...)                                  \
35         printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
36 #define pr_err_once(fmt, ...)                                   \
37         printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
38 #define pr_warn_once(fmt, ...)                                  \
39         printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
40 #define pr_notice_once(fmt, ...)                                \
41         printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
42 #define pr_info_once(fmt, ...)                                  \
43         printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
44 #define pr_cont_once(fmt, ...)                                  \
45         printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
46
47 #endif
48
49 #ifndef USHRT_MAX
50 #define USHRT_MAX       ((u16)(~0U))
51 #define SHRT_MAX        ((s16)(USHRT_MAX>>1))
52 #define SHRT_MIN        ((s16)(-SHRT_MAX - 1))
53 #endif
54
55 #ifndef DIV_ROUND_UP
56 #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
57 #endif
58
59 #ifndef rounddown
60 #define rounddown(x, y) (                               \
61 {                                                       \
62         typeof(x) __x = (x);                            \
63         __x - (__x % (y));                              \
64 }                                                       \
65 )
66 #endif
67
68 #endif /* linux/kernel.h */