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