compat: Added support for ib_core from kernel 4.8 on RHEL7.2
[~tnikolova/compat/.git] / include / linux / printk.h
1 #ifndef _COMPAT_LINUX_PRINTK_H
2 #define _COMPAT_LINUX_PRINTK_H 1
3
4 #include <linux/version.h>
5 #include "../../compat/config.h"
6
7 #ifdef HAVE_LINUX_PRINTK_H
8 #include_next <linux/printk.h>
9 #else /* HAVE_LINUX_PRINTK_H */
10 #include <linux/kernel.h>
11
12 #define pr_emerg_once(fmt, ...)                                 \
13         printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
14 #define pr_alert_once(fmt, ...)                                 \
15         printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
16 #define pr_crit_once(fmt, ...)                                  \
17         printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
18 #define pr_err_once(fmt, ...)                                   \
19         printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
20 #define pr_warn_once(fmt, ...)                                  \
21         printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
22 #define pr_warn pr_warning
23 #define pr_notice_once(fmt, ...)                                \
24         printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
25 #define pr_info_once(fmt, ...)                                  \
26         printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
27 #define pr_cont_once(fmt, ...)                                  \
28         printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
29 #if defined(DEBUG)
30 #define pr_debug_once(fmt, ...)                                 \
31         printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
32 #else
33 #define pr_debug_once(fmt, ...)                                 \
34         no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
35 #endif
36
37 /*
38  * ratelimited messages with local ratelimit_state,
39  * no local ratelimit_state used in the !PRINTK case
40  */
41 #ifndef printk_ratelimited
42 #ifdef CONFIG_PRINTK
43 #define printk_ratelimited(fmt, ...)                                    \
44 ({                                                                      \
45         static DEFINE_RATELIMIT_STATE(_rs,                              \
46                                       DEFAULT_RATELIMIT_INTERVAL,       \
47                                       DEFAULT_RATELIMIT_BURST);         \
48                                                                         \
49         if (__ratelimit(&_rs))                                          \
50                 printk(fmt, ##__VA_ARGS__);                             \
51 })
52 #else
53 #define printk_ratelimited(fmt, ...)                                    \
54         no_printk(fmt, ##__VA_ARGS__)
55 #endif
56 #endif /* ifndef printk_ratelimited */
57
58 #ifndef printk_once
59 #define printk_once(fmt, ...)                   \
60 ({                                              \
61         static bool __print_once;               \
62                                                 \
63         if (!__print_once) {                    \
64                 __print_once = true;            \
65                 printk(fmt, ##__VA_ARGS__);     \
66         }                                       \
67 })
68 #endif
69
70 #endif /* HAVE_LINUX_PRINTK_H */
71
72 #endif  /* _COMPAT_LINUX_PRINTK_H */