12#ifndef ZEPHYR_INCLUDE_SYS_CBPRINTF_CXX_H_
13#define ZEPHYR_INCLUDE_SYS_CBPRINTF_CXX_H_
17static inline int z_cbprintf_cxx_is_pchar(
char *,
bool const_as_fixed)
19 ARG_UNUSED(const_as_fixed);
23static inline int z_cbprintf_cxx_is_pchar(
const char *,
bool const_as_fixed)
25 return const_as_fixed ? 0 : 1;
28static inline int z_cbprintf_cxx_is_pchar(
volatile char *,
bool const_as_fixed)
30 ARG_UNUSED(const_as_fixed);
34static inline int z_cbprintf_cxx_is_pchar(
const volatile char *,
bool const_as_fixed)
36 ARG_UNUSED(const_as_fixed);
40static inline int z_cbprintf_cxx_is_pchar(
unsigned char *,
bool const_as_fixed)
42 ARG_UNUSED(const_as_fixed);
46static inline int z_cbprintf_cxx_is_pchar(
const unsigned char *,
bool const_as_fixed)
48 return const_as_fixed ? 0 : 1;
51static inline int z_cbprintf_cxx_is_pchar(
volatile unsigned char *,
bool const_as_fixed)
53 ARG_UNUSED(const_as_fixed);
57static inline int z_cbprintf_cxx_is_pchar(
const volatile unsigned char *,
bool const_as_fixed)
59 ARG_UNUSED(const_as_fixed);
62static inline int z_cbprintf_cxx_is_pchar(
wchar_t *,
bool const_as_fixed)
64 ARG_UNUSED(const_as_fixed);
68static inline int z_cbprintf_cxx_is_pchar(
const wchar_t *,
bool const_as_fixed)
70 return const_as_fixed ? 0 : 1;
73static inline int z_cbprintf_cxx_is_pchar(
volatile wchar_t *,
bool const_as_fixed)
75 ARG_UNUSED(const_as_fixed);
79static inline int z_cbprintf_cxx_is_pchar(
const volatile wchar_t *,
bool const_as_fixed)
81 ARG_UNUSED(const_as_fixed);
85template <
typename T >
86static inline int z_cbprintf_cxx_is_pchar(T arg,
bool const_as_fixed)
90 ARG_UNUSED(const_as_fixed);
96static inline int z_cbprintf_cxx_is_word_num(
char)
101static inline int z_cbprintf_cxx_is_word_num(
unsigned char)
106static inline int z_cbprintf_cxx_is_word_num(
short)
111static inline int z_cbprintf_cxx_is_word_num(
unsigned short)
116static inline int z_cbprintf_cxx_is_word_num(
int)
121static inline int z_cbprintf_cxx_is_word_num(
unsigned int)
126static inline int z_cbprintf_cxx_is_word_num(
long)
128 return (
sizeof(
long) <=
sizeof(
uint32_t)) ? 1 : 0;
131static inline int z_cbprintf_cxx_is_word_num(
unsigned long)
133 return (
sizeof(
long) <=
sizeof(
uint32_t)) ? 1 : 0;
136template <
typename T >
137static inline int z_cbprintf_cxx_is_word_num(T arg)
146static inline int z_cbprintf_cxx_is_none_char_ptr(
char)
151static inline int z_cbprintf_cxx_is_none_char_ptr(
unsigned char)
156static inline int z_cbprintf_cxx_is_none_char_ptr(
short)
161static inline int z_cbprintf_cxx_is_none_char_ptr(
unsigned short)
166static inline int z_cbprintf_cxx_is_none_char_ptr(
int)
171static inline int z_cbprintf_cxx_is_none_char_ptr(
unsigned int)
176static inline int z_cbprintf_cxx_is_none_char_ptr(
long)
181static inline int z_cbprintf_cxx_is_none_char_ptr(
unsigned long)
186static inline int z_cbprintf_cxx_is_none_char_ptr(
long long)
191static inline int z_cbprintf_cxx_is_none_char_ptr(
unsigned long long)
196static inline int z_cbprintf_cxx_is_none_char_ptr(
float)
201static inline int z_cbprintf_cxx_is_none_char_ptr(
double)
206static inline int z_cbprintf_cxx_is_none_char_ptr(
char *)
211static inline int z_cbprintf_cxx_is_none_char_ptr(
volatile char *)
216static inline int z_cbprintf_cxx_is_none_char_ptr(
const char *)
221static inline int z_cbprintf_cxx_is_none_char_ptr(
const volatile char *)
226static inline int z_cbprintf_cxx_is_none_char_ptr(
unsigned char *)
231static inline int z_cbprintf_cxx_is_none_char_ptr(
volatile unsigned char *)
236static inline int z_cbprintf_cxx_is_none_char_ptr(
const unsigned char *)
241static inline int z_cbprintf_cxx_is_none_char_ptr(
const volatile unsigned char *)
246template <
typename T >
247static inline int z_cbprintf_cxx_is_none_char_ptr(T arg)
255static inline size_t z_cbprintf_cxx_arg_size(
float f)
259 return sizeof(double);
262template <
typename T >
263static inline size_t z_cbprintf_cxx_arg_size(T arg)
267 return MAX(
sizeof(T),
sizeof(
int));
271static inline void z_cbprintf_cxx_store_arg(
uint8_t *dst,
float arg)
273 double d = (double)arg;
276 z_cbprintf_wcpy((
int *)dst, (
int *)p,
sizeof(d) /
sizeof(
int));
279static inline void z_cbprintf_cxx_store_arg(
uint8_t *dst,
void *p)
281 z_cbprintf_wcpy((
int *)dst, (
int *)&p,
sizeof(p) /
sizeof(
int));
284static inline void z_cbprintf_cxx_store_arg(
uint8_t *dst,
char arg)
288 z_cbprintf_wcpy((
int *)dst, &tmp, 1);
291static inline void z_cbprintf_cxx_store_arg(
uint8_t *dst,
unsigned char arg)
295 z_cbprintf_wcpy((
int *)dst, &tmp, 1);
298static inline void z_cbprintf_cxx_store_arg(
uint8_t *dst,
signed char arg)
302 z_cbprintf_wcpy((
int *)dst, &tmp, 1);
305static inline void z_cbprintf_cxx_store_arg(
uint8_t *dst,
short arg)
309 z_cbprintf_wcpy((
int *)dst, &tmp, 1);
312static inline void z_cbprintf_cxx_store_arg(
uint8_t *dst,
unsigned short arg)
316 z_cbprintf_wcpy((
int *)dst, &tmp, 1);
319template <
typename T >
320static inline void z_cbprintf_cxx_store_arg(
uint8_t *dst, T arg)
322 size_t wlen = z_cbprintf_cxx_arg_size(arg) /
sizeof(int);
325 z_cbprintf_wcpy((
int *)dst, (
int *)p, wlen);
329static inline int z_cbprintf_cxx_is_longdouble(
long double arg)
335template <
typename T >
336static inline int z_cbprintf_cxx_is_longdouble(T arg)
344static inline size_t z_cbprintf_cxx_alignment(
float arg)
348 return VA_STACK_ALIGN(
double);
351static inline size_t z_cbprintf_cxx_alignment(
double arg)
355 return VA_STACK_ALIGN(
double);
358static inline size_t z_cbprintf_cxx_alignment(
long double arg)
362 return VA_STACK_ALIGN(
long double);
365static inline size_t z_cbprintf_cxx_alignment(
long long arg)
369 return VA_STACK_ALIGN(
long long);
372static inline size_t z_cbprintf_cxx_alignment(
unsigned long long arg)
376 return VA_STACK_ALIGN(
long long);
379template <
typename T >
380static inline size_t z_cbprintf_cxx_alignment(T arg)
382 return MAX(__alignof__(arg), VA_STACK_MIN_ALIGN);
386template <
typename T1,
typename T2 >
387struct z_cbprintf_cxx_is_same_type {
393template <
typename T >
394struct z_cbprintf_cxx_is_same_type < T, T > {
400template <
typename T >
401struct z_cbprintf_cxx_remove_reference {
405template <
typename T >
406struct z_cbprintf_cxx_remove_reference < T & > {
410#if __cplusplus >= 201103L
411template <
typename T >
412struct z_cbprintf_cxx_remove_reference < T && > {
417template <
typename T >
418struct z_cbprintf_cxx_remove_cv {
422template <
typename T >
423struct z_cbprintf_cxx_remove_cv < const T > {
427template <
typename T >
428struct z_cbprintf_cxx_remove_cv < volatile T > {
432template <
typename T >
433struct z_cbprintf_cxx_remove_cv < const volatile T > {
438template <
typename T >
439struct z_cbprintf_cxx_is_array {
445template <
typename T >
446struct z_cbprintf_cxx_is_array < T[] > {
452template <
typename T,
size_t N >
453struct z_cbprintf_cxx_is_array < T[N] > {
460template <
typename T >
461struct z_cbprintf_cxx_remove_extent {
465template <
typename T >
466struct z_cbprintf_cxx_remove_extent < T[] > {
470template <
typename T,
size_t N >
471struct z_cbprintf_cxx_remove_extent < T[N] > {
#define MAX(a, b)
Obtain the maximum of two values.
Definition util.h:391
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88