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
48#define CBPRINTF_PACKAGE_ALIGNMENT 16
50#define CBPRINTF_PACKAGE_ALIGNMENT \
51 Z_POW2_CEIL(COND_CODE_1(CONFIG_CBPRINTF_PACKAGE_LONGDOUBLE, \
52 (sizeof(long double)), (MAX(sizeof(double), sizeof(long long)))))
65#define CBPRINTF_PACKAGE_CONST_CHAR_RO BIT(0)
68#define CBPRINTF_PACKAGE_ADD_RO_STR_POS BIT(1)
74#define CBPRINTF_PACKAGE_ADD_RW_STR_POS BIT(2)
76#define Z_CBPRINTF_PACKAGE_FIRST_RO_STR_BITS 3
77#define Z_CBPRINTF_PACKAGE_FIRST_RO_STR_OFFSET 3
78#define Z_CBPRINTF_PACKAGE_FIRST_RO_STR_MASK BIT_MASK(Z_CBPRINTF_PACKAGE_FIRST_RO_STR_BITS)
87#define CBPRINTF_PACKAGE_FIRST_RO_STR_CNT(n) \
88 (n << Z_CBPRINTF_PACKAGE_FIRST_RO_STR_OFFSET)
93#define Z_CBPRINTF_PACKAGE_FIRST_RO_STR_CNT_GET(flags) \
94 (((flags) >> Z_CBPRINTF_PACKAGE_FIRST_RO_STR_OFFSET) & Z_CBPRINTF_PACKAGE_FIRST_RO_STR_MASK)
102#define CBPRINTF_PACKAGE_ADD_STRING_IDXS \
103 (CBPRINTF_PACKAGE_ADD_RO_STR_POS | CBPRINTF_PACKAGE_CONST_CHAR_RO)
119#define CBPRINTF_PACKAGE_COPY_RO_STR BIT(0)
131#define CBPRINTF_PACKAGE_COPY_RW_STR BIT(1)
138#define CBPRINTF_PACKAGE_COPY_KEEP_RO_STR BIT(2)
194 const char *fmt, va_list ap);
213#define CBPRINTF_MUST_RUNTIME_PACKAGE(flags, ... ) \
214 Z_CBPRINTF_MUST_RUNTIME_PACKAGE(flags, __VA_ARGS__)
245#define CBPRINTF_STATIC_PACKAGE(packaged, inlen, outlen, align_offset, flags, \
247 Z_CBPRINTF_STATIC_PACKAGE(packaged, inlen, outlen, \
248 align_offset, flags, __VA_ARGS__)
381struct z_cbprintf_buf_desc {
388static inline int z_cbprintf_cpy(
const void *buf,
size_t len,
void *ctx)
390 struct z_cbprintf_buf_desc *desc = (
struct z_cbprintf_buf_desc *)ctx;
392 if ((desc->size - desc->off) < len) {
396 memcpy(&((
uint8_t *)desc->buf)[desc->off], (
void *)buf, len);
440 struct z_cbprintf_buf_desc buf_desc = {
446 packaged ? z_cbprintf_cpy : NULL, &buf_desc,
447 flags, strl, strl_len);
593#ifdef CONFIG_CBPRINTF_LIBC_SUBSTS
695int snprintfcb(
char *str,
size_t size, const
char *format, ...);
719int 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_COPY_RW_STR
Append read-write strings from source package to destination package.
Definition: cbprintf.h:131
#define CBPRINTF_PACKAGE_COPY_RO_STR
Append read-only strings from source package to destination package.
Definition: cbprintf.h:119
int cbpprintf_external(cbprintf_cb out, cbvprintf_exteral_formatter_func formatter, void *ctx, void *packaged)
Generate the output for a previously captured format operation using an external formatter.
int cbprintf(cbprintf_cb out, void *ctx, const char *format,...)
*printf-like output through a callback.
static int cbpprintf(cbprintf_cb out, void *ctx, void *packaged)
Generate the output for a previously captured format operation.
Definition: cbprintf.h:588
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:50
int cbvprintf(cbprintf_cb out, void *ctx, const char *format, va_list ap)
varargs-aware *printf-like output through a callback.
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:479
int(* cbprintf_convert_cb)(const void *buf, size_t len, void *ctx)
Signature for a cbprintf multibyte callback function.
Definition: cbprintf.h:173
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:432
int snprintfcb(char *str, size_t size, const char *format,...)
snprintf using Zephyrs cbprintf infrastructure.
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:162
int(* cbvprintf_exteral_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:193
int cbprintf_package(void *packaged, size_t len, uint32_t flags, const char *format,...)
Capture state required to output formatted data later.
#define ENOSPC
Definition: errno.h:67
flags
Definition: http_parser.h:131
char c
Definition: printk.c:71
__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)