1 /* printk.h - low-level debug output */
2 
3 /*
4  * Copyright (c) 2010-2012, 2014 Wind River Systems, Inc.
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 #ifndef _PRINTK_H_
9 #define _PRINTK_H_
10 
11 #include <stddef.h>
12 #include <stdarg.h>
13 #include <stdio.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #ifndef ARG_UNUSED
20 #define ARG_UNUSED(x) (void)(x)
21 #endif
22 
23 /**
24  *
25  * @brief Print kernel debugging message.
26  *
27  * This routine prints a kernel debugging message to the system console.
28  * Output is send immediately, without any mutual exclusion or buffering.
29  *
30  * A basic set of conversion specifier characters are supported:
31  *   - signed decimal: \%d, \%i
32  *   - unsigned decimal: \%u
33  *   - unsigned hexadecimal: \%x (\%X is treated as \%x)
34  *   - pointer: \%p
35  *   - string: \%s
36  *   - character: \%c
37  *   - percent: \%\%
38  *
39  * Field width (with or without leading zeroes) is supported.
40  * Length attributes h, hh, l, ll and z are supported. However, integral
41  * values with %lld and %lli are only printed if they fit in a long
42  * otherwise 'ERR' is printed. Full 64-bit values may be printed with %llx.
43  * Flags and precision attributes are not supported.
44  *
45  * @param fmt Format string.
46  * @param ... Optional list of format arguments.
47  *
48  * @return N/A
49  */
50 #ifdef CONFIG_PRINTK
51 extern __printf_like(1, 2) int printk(const char *fmt, ...);
52 extern __printf_like(1, 0) int vprintk(const char *fmt, va_list ap);
53 extern __printf_like(3, 4) int snprintk(char *str, size_t size,
54 					const char *fmt, ...);
55 extern __printf_like(3, 0) int vsnprintk(char *str, size_t size,
56 					  const char *fmt, va_list ap);
57 
58 extern __printf_like(3, 0) void _vprintk(int (*out)(int, void *), void *ctx,
59 					 const char *fmt, va_list ap);
60 #else
61 static inline int printk(const char *fmt, ...)
62 {
63 	ARG_UNUSED(fmt);
64 	return 0;
65 }
66 
67 static inline int vprintk(const char *fmt, va_list ap)
68 {
69 	ARG_UNUSED(fmt);
70 	ARG_UNUSED(ap);
71 	return 0;
72 }
73 
74 #define snprintk snprintf
75 
76 static inline int vsnprintk(char *str, size_t size,
77 						const char *fmt, va_list ap)
78 {
79 	ARG_UNUSED(str);
80 	ARG_UNUSED(size);
81 	ARG_UNUSED(fmt);
82 	ARG_UNUSED(ap);
83 
84 	return 0;
85 }
86 #endif
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif
93