2 * Copyright (c) 2015 François Tigeot
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef _LINUX_PRINTK_H_
28 #define _LINUX_PRINTK_H_
30 #include <linux/cache.h>
32 #include <sys/types.h>
33 #include <sys/systm.h>
35 #define printk(X...) kprintf(X)
38 #define KERN_EMERG "<0>"
39 #define KERN_ALERT "<1>"
40 #define KERN_CRIT "<2>"
41 #define KERN_ERR "<3>"
42 #define KERN_WARNING "<4>"
43 #define KERN_NOTICE "<5>"
44 #define KERN_INFO "<6>"
45 #define KERN_DEBUG "<7>"
48 #define pr_fmt(fmt) fmt
51 #define pr_emerg(fmt, ...) \
52 printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
53 #define pr_alert(fmt, ...) \
54 printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
55 #define pr_crit(fmt, ...) \
56 printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
57 #define pr_err(fmt, ...) \
58 printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
59 #define pr_warning(fmt, ...) \
60 printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
61 #define pr_warn pr_warning
62 #define pr_notice(fmt, ...) \
63 printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
64 #define pr_info(fmt, ...) \
65 printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
66 #define pr_cont(fmt, ...) \
67 printk(KERN_CONT fmt, ##__VA_ARGS__)
69 /* pr_devel() should produce zero code unless DEBUG is defined */
71 #define pr_devel(fmt, ...) \
72 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
74 #define pr_devel(fmt, ...) \
75 ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
78 #define pr_debug(fmt, ...) printk(KERN_DEBUG # fmt, ##__VA_ARGS__)
81 * Print a one-time message (analogous to WARN_ONCE() et al):
83 #define printk_once(x...) \
85 static bool __print_once; \
87 if (!__print_once) { \
88 __print_once = true; \
93 #define pr_info_once(fmt, ...) do { \
94 static bool __printed_once; \
96 if (!__printed_once) { \
97 __printed_once = true; \
98 kprintf(fmt, ##__VA_ARGS__); \
108 #endif /* _LINUX_PRINTK_H_ */