7#ifndef ZEPHYR_INCLUDE_SYS_CBPRINTF_H_
8#define ZEPHYR_INCLUDE_SYS_CBPRINTF_H_
16#ifdef CONFIG_CBPRINTF_LIBC_SUBSTS
26#if defined(__cplusplus) || TOOLCHAIN_HAS_C_GENERIC
34#define Z_PKG_HDR_EXT_XTENSA_ALIGNMENT 8
35#ifdef CONFIG_CBPRINTF_PACKAGE_HEADER_STORE_CREATION_FLAGS
36#define Z_PKG_DESC_XTENSA_PADDING 1
38#define Z_PKG_DESC_XTENSA_PADDING 0
58#ifdef CONFIG_CBPRINTF_PACKAGE_HEADER_STORE_CREATION_FLAGS
69 uint32_t xtensa_padding[Z_PKG_DESC_XTENSA_PADDING];
84#if defined(CONFIG_CBPRINTF_PACKAGE_HEADER_STORE_CREATION_FLAGS) && !defined(CONFIG_64BIT)
117 "Package header size on Xtensa must be aligned");
138#define CBPRINTF_PACKAGE_ALIGNMENT 16
140#define CBPRINTF_PACKAGE_ALIGNMENT \
141 Z_POW2_CEIL(COND_CODE_1(CONFIG_CBPRINTF_PACKAGE_LONGDOUBLE, \
142 (sizeof(long double)), (MAX(sizeof(double), sizeof(long long)))))
156#define CBPRINTF_PACKAGE_CONST_CHAR_RO BIT(0)
159#define CBPRINTF_PACKAGE_ADD_RO_STR_POS BIT(1)
165#define CBPRINTF_PACKAGE_ADD_RW_STR_POS BIT(2)
167#define Z_CBPRINTF_PACKAGE_FIRST_RO_STR_BITS 3
168#define Z_CBPRINTF_PACKAGE_FIRST_RO_STR_OFFSET 3
169#define Z_CBPRINTF_PACKAGE_FIRST_RO_STR_MASK BIT_MASK(Z_CBPRINTF_PACKAGE_FIRST_RO_STR_BITS)
178#define CBPRINTF_PACKAGE_FIRST_RO_STR_CNT(n) \
179 (n << Z_CBPRINTF_PACKAGE_FIRST_RO_STR_OFFSET)
184#define Z_CBPRINTF_PACKAGE_FIRST_RO_STR_CNT_GET(flags) \
185 (((flags) >> Z_CBPRINTF_PACKAGE_FIRST_RO_STR_OFFSET) & Z_CBPRINTF_PACKAGE_FIRST_RO_STR_MASK)
193#define CBPRINTF_PACKAGE_ADD_STRING_IDXS \
194 (CBPRINTF_PACKAGE_ADD_RO_STR_POS | CBPRINTF_PACKAGE_CONST_CHAR_RO)
201#define CBPRINTF_PACKAGE_ARGS_ARE_TAGGED BIT(6)
217#define CBPRINTF_PACKAGE_CONVERT_RO_STR BIT(0)
218#define CBPRINTF_PACKAGE_COPY_RO_STR CBPRINTF_PACKAGE_CONVERT_RO_STR __DEPRECATED_MACRO
230#define CBPRINTF_PACKAGE_CONVERT_RW_STR BIT(1)
231#define CBPRINTF_PACKAGE_COPY_RW_STR CBPRINTF_PACKAGE_CONVERT_RW_STR __DEPRECATED_MACRO
238#define CBPRINTF_PACKAGE_CONVERT_KEEP_RO_STR BIT(2)
239#define CBPRINTF_PACKAGE_COPY_KEEP_RO_STR CBPRINTF_PACKAGE_CONVERT_KEEP_RO_STR __DEPRECATED_MACRO
258#define CBPRINTF_PACKAGE_CONVERT_PTR_CHECK BIT(3)
271#define Z_CBVPRINTF_PROCESS_FLAG_TAGGED_ARGS BIT(0)
329 const char *fmt, va_list ap);
348#define CBPRINTF_MUST_RUNTIME_PACKAGE(flags, ... ) \
349 Z_CBPRINTF_MUST_RUNTIME_PACKAGE(flags, __VA_ARGS__)
380#define CBPRINTF_STATIC_PACKAGE(packaged, inlen, outlen, align_offset, flags, \
382 Z_CBPRINTF_STATIC_PACKAGE(packaged, inlen, outlen, \
383 align_offset, flags, __VA_ARGS__)
516struct z_cbprintf_buf_desc {
523static inline int z_cbprintf_cpy(
const void *buf,
size_t len,
void *ctx)
525 struct z_cbprintf_buf_desc *desc = (
struct z_cbprintf_buf_desc *)ctx;
527 if ((desc->size - desc->off) < len) {
575 struct z_cbprintf_buf_desc buf_desc = {
582 packaged ? z_cbprintf_cpy : NULL, &buf_desc,
583 flags, strl, strl_len);
707int z_cbvprintf_impl(
cbprintf_cb out,
void *ctx, const
char *format,
735#ifdef CONFIG_PICOLIBC
741 return z_cbvprintf_impl(out, ctx, format, ap, 0);
774 const char *format, va_list ap)
776 return z_cbvprintf_impl(out, ctx, format, ap,
777 Z_CBVPRINTF_PROCESS_FLAG_TAGGED_ARGS);
800#if defined(CONFIG_CBPRINTF_PACKAGE_SUPPORT_TAGGED_ARGUMENTS)
814#ifdef CONFIG_CBPRINTF_LIBC_SUBSTS
816#ifdef CONFIG_PICOLIBC
818#define fprintfcb(stream, ...) fprintf(stream, __VA_ARGS__)
819#define vfprintfcb(stream, format, ap) vfprintf(stream, format, ap)
820#define printfcb(format, ...) printf(format, __VA_ARGS__)
821#define vprintfcb(format, ap) vprintf(format, ap)
822#define snprintfcb(str, size, ...) snprintf(str, size, __VA_ARGS__)
823#define vsnprintfcb(str, size, format, ap) vsnprintf(str, size, format, ap)
927int snprintfcb(
char *str,
size_t size, const
char *format, ...);
951int vsnprintfcb(
char *str,
size_t size, const
char *format, va_list ap);
irp nz macro MOVR cc s mov cc s endm endr irp aw macro LDR aa off
Definition: asm-macro-32-bit-gnu.h:17
#define CBPRINTF_PACKAGE_CONVERT_RO_STR
Append read-only strings from source package to destination package.
Definition: cbprintf.h:217
#define CBPRINTF_PACKAGE_CONVERT_RW_STR
Append read-write strings from source package to destination package.
Definition: cbprintf.h:230
#define CBPRINTF_PACKAGE_ARGS_ARE_TAGGED
Indicate the incoming arguments are tagged.
Definition: cbprintf.h:201
int cbprintf(cbprintf_cb out, void *ctx, const char *format,...)
*printf-like output through a callback.
int(* cbvprintf_external_formatter_func)(cbprintf_cb out, void *ctx, const char *fmt, va_list ap)
Signature for a external formatter function identical to cbvprintf.
Definition: cbprintf.h:328
static int cbpprintf(cbprintf_cb out, void *ctx, void *packaged)
Generate the output for a previously captured format operation.
Definition: cbprintf.h:798
int printfcb(const char *format,...)
printf using Zephyrs cbprintf infrastructure.
int vfprintfcb(FILE *stream, const char *format, va_list ap)
vfprintf using Zephyrs cbprintf infrastructure.
int fprintfcb(FILE *stream, const char *format,...)
fprintf using Zephyrs cbprintf infrastructure.
int vsnprintfcb(char *str, size_t size, const char *format, va_list ap)
vsnprintf using Zephyrs cbprintf infrastructure.
#define CBPRINTF_PACKAGE_ALIGNMENT
Required alignment of the buffer used for packaging.
Definition: cbprintf.h:140
int cbprintf_package_convert(void *in_packaged, size_t in_len, cbprintf_convert_cb cb, void *ctx, uint32_t flags, uint16_t *strl, size_t strl_len)
Convert a package.
static int cbprintf_fsc_package(void *in_packaged, size_t in_len, void *packaged, size_t len)
Convert package to fully self-contained (fsc) package.
Definition: cbprintf.h:615
int(* cbprintf_convert_cb)(const void *buf, size_t len, void *ctx)
Signature for a cbprintf multibyte callback function.
Definition: cbprintf.h:308
static int cbprintf_package_copy(void *in_packaged, size_t in_len, void *packaged, size_t len, uint32_t flags, uint16_t *strl, size_t strl_len)
Copy package with optional appending of strings.
Definition: cbprintf.h:567
static int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
varargs-aware *printf-like output through a callback.
Definition: cbprintf.h:739
int snprintfcb(char *str, size_t size, const char *format,...)
snprintf using Zephyrs cbprintf infrastructure.
int cbpprintf_external(cbprintf_cb out, cbvprintf_external_formatter_func formatter, void *ctx, void *packaged)
Generate the output for a previously captured format operation using an external formatter.
int vprintfcb(const char *format, va_list ap)
vprintf using Zephyrs cbprintf infrastructure.
int cbvprintf_package(void *packaged, size_t len, uint32_t flags, const char *format, va_list ap)
Capture state required to output formatted data later.
int(* cbprintf_cb)()
Signature for a cbprintf callback function.
Definition: cbprintf.h:297
int cbprintf_package(void *packaged, size_t len, uint32_t flags, const char *format,...)
Capture state required to output formatted data later.
static int cbvprintf_tagged_args(cbprintf_cb out, void *ctx, const char *format, va_list ap)
varargs-aware *printf-like output through a callback with tagged arguments.
Definition: cbprintf.h:773
#define ENOSPC
Definition: errno.h:67
flags
Definition: parser.h:96
char c
Definition: printk.c:112
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
int FILE
Definition: stdio.h:22
void * memcpy(void *ZRESTRICT d, const void *ZRESTRICT s, size_t n)
cbprintf package descriptor.
Definition: cbprintf.h:45
uint8_t len
Definition: cbprintf.h:47
uint8_t str_cnt
Definition: cbprintf.h:50
uint8_t ro_str_cnt
Definition: cbprintf.h:53
uint8_t rw_str_cnt
Definition: cbprintf.h:56
cbprintf package header with format string pointer.
Definition: cbprintf.h:96
union cbprintf_package_hdr hdr
Definition: cbprintf.h:98
char * fmt
Definition: cbprintf.h:101
cbprintf package header
Definition: cbprintf.h:78
void * raw
Definition: cbprintf.h:82
struct cbprintf_package_desc desc
Definition: cbprintf.h:80