Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
printk.h
Go to the documentation of this file.
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 CONFIG_LOG_PRINTK_STATIC
18#endif
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
49#if defined(CONFIG_PRINTK) || defined(__DOXYGEN__)
50
51#ifdef CONFIG_LOG_PRINTK_STATIC
52/* If printk is redirected to the logging use the macro which allow build time
53 * logging message creation which is faster and allows format string stripping in
54 * case of dictionary based logging.
55 */
56#define printk(...) Z_LOG_PRINTK(0, __VA_ARGS__)
57#else
58__printf_like(1, 2) void printk(const char *fmt, ...);
59#endif /* CONFIG_LOG_PRINTK_STATIC */
60
69__printf_like(1, 0) void vprintk(const char *fmt, va_list ap);
70
88__printf_like(1, 2) void printk_unlocked(const char *fmt, ...);
89
98__printf_like(1, 0) void vprintk_unlocked(const char *fmt, va_list ap);
99
113void printk_panic(void);
114
115#else
116static inline __printf_like(1, 2) void printk(const char *fmt, ...)
117{
118 ARG_UNUSED(fmt);
119}
120
121static inline __printf_like(1, 0) void vprintk(const char *fmt, va_list ap)
122{
123 ARG_UNUSED(fmt);
124 ARG_UNUSED(ap);
125}
126
127static inline __printf_like(1, 2) void printk_unlocked(const char *fmt, ...)
128{
129 ARG_UNUSED(fmt);
130}
131
132static inline __printf_like(1, 0) void vprintk_unlocked(const char *fmt, va_list ap)
133{
134 ARG_UNUSED(fmt);
135 ARG_UNUSED(ap);
136}
137
138static inline void printk_panic(void)
139{
140}
141#endif /* defined(CONFIG_PRINTK) || defined(__DOXYGEN__) */
142
143#ifdef CONFIG_PICOLIBC
144
145#include <stdio.h>
146
147#define snprintk(...) snprintf(__VA_ARGS__)
148#define vsnprintk(str, size, fmt, ap) vsnprintf(str, size, fmt, ap)
149
150#else
151
168__printf_like(3, 4) int snprintk(char *str, size_t size,
169 const char *fmt, ...);
170
184__printf_like(3, 0) int vsnprintk(char *str, size_t size,
185 const char *fmt, va_list ap);
186
187#endif
188
189#ifdef __cplusplus
190}
191#endif
192
193#endif
Header file for the logging core.
int snprintk(char *str, size_t size, const char *fmt,...)
Print a kernel debugging message to a buffer.
void printk(const char *fmt,...)
Print kernel debugging message.
void printk_unlocked(const char *fmt,...)
Output a string without taking the printk lock.
void printk_panic(void)
Stop printk() taking its lock, for crash reporting.
void vprintk(const char *fmt, va_list ap)
Print kernel debugging message, va_list version.
int vsnprintk(char *str, size_t size, const char *fmt, va_list ap)
Print a kernel debugging message to a buffer, va_list version.
void vprintk_unlocked(const char *fmt, va_list ap)
Output a string without any locking, va_list version.
Macros to abstract toolchain specific capabilities.