diff --git a/include/sys/cbprintf.h b/include/sys/cbprintf.h index 64a6fc74565ad7..37d3b54eb40c7e 100644 --- a/include/sys/cbprintf.h +++ b/include/sys/cbprintf.h @@ -16,17 +16,16 @@ #include #endif /* CONFIG_CBPRINTF_LIBC_SUBSTS */ -#ifdef __cplusplus -extern "C" { -#endif - /* Determine if _Generic is supported. * In general it's a C11 feature but it was added also in: * - GCC 4.9.0 https://gcc.gnu.org/gcc-4.9/changes.html * - Clang 3.0 https://releases.llvm.org/3.0/docs/ClangReleaseNotes.html + * + * @note Z_C_GENERIC is also set for C++ where functionality is implemented + * using overloading and templates. */ #ifndef Z_C_GENERIC -#if !defined(__cplusplus) && (((__STDC_VERSION__ >= 201112L) || \ +#if defined(__cplusplus) || (((__STDC_VERSION__ >= 201112L) || \ ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40900) || \ ((__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) >= 30000))) #define Z_C_GENERIC 1 @@ -38,6 +37,10 @@ extern "C" { /* Z_C_GENERIC is used there */ #include +#ifdef __cplusplus +extern "C" { +#endif + /** * @defgroup cbprintf_apis Formatted Output APIs * @ingroup support_apis diff --git a/include/sys/cbprintf_cxx.h b/include/sys/cbprintf_cxx.h new file mode 100644 index 00000000000000..40333319125c40 --- /dev/null +++ b/include/sys/cbprintf_cxx.h @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_SYS_CBPRINTF_CXX_H_ +#define ZEPHYR_INCLUDE_SYS_CBPRINTF_CXX_H_ +#ifdef __cplusplus + +/* C++ version for detecting a pointer to a string. */ +static inline int z_cbprintf_cxx_is_pchar(char *) +{ + return 1; +} + +static inline int z_cbprintf_cxx_is_pchar(const char *) +{ + return 1; +} + +static inline int z_cbprintf_cxx_is_pchar(volatile char *) +{ + return 1; +} + +static inline int z_cbprintf_cxx_is_pchar(const volatile char *) +{ + return 1; +} + +static inline int z_cbprintf_cxx_is_pchar(wchar_t *) +{ + return 1; +} + +static inline int z_cbprintf_cxx_is_pchar(const wchar_t *) +{ + return 1; +} + +static inline int z_cbprintf_cxx_is_pchar(volatile wchar_t *) +{ + return 1; +} + +static inline int z_cbprintf_cxx_is_pchar(const volatile wchar_t *) +{ + return 1; +} + +template < typename T > +static inline int z_cbprintf_cxx_is_pchar(T arg) +{ + return 0; +} + +/* C++ version for calculating argument size. */ +static inline size_t z_cbprintf_cxx_arg_size(float f) +{ + return sizeof(double); +} + +template < typename T > +static inline size_t z_cbprintf_cxx_arg_size(T arg) +{ + return sizeof(arg + 0); +} + +/* C++ version for storing arguments. */ +static inline void z_cbprintf_cxx_store_arg(uint8_t *dst, float arg) +{ + double d = (double)arg; + + z_cbprintf_wcpy((int *)dst, (int *)&d, sizeof(d) / sizeof(int)); +} + +template < typename T > +static inline void z_cbprintf_cxx_store_arg(uint8_t *dst, T arg) +{ + size_t wlen = z_cbprintf_cxx_arg_size(arg) / sizeof(int); + + z_cbprintf_wcpy((int *)dst, (int *)&arg, wlen); +} + +/* C++ version for long double detection. */ +static inline int z_cbprintf_cxx_is_longdouble(long double arg) +{ + return 1; +} + +template < typename T > +static inline int z_cbprintf_cxx_is_longdouble(T arg) +{ + return 0; +} + +/* C++ version for caluculating argument alignment. */ +static inline size_t z_cbprintf_cxx_alignment(float arg) +{ + return VA_STACK_ALIGN(double); +} + +static inline size_t z_cbprintf_cxx_alignment(double arg) +{ + return VA_STACK_ALIGN(double); +} + +static inline size_t z_cbprintf_cxx_alignment(long double arg) +{ + return VA_STACK_ALIGN(long double); +} + +static inline size_t z_cbprintf_cxx_alignment(long long arg) +{ + return VA_STACK_ALIGN(long long); +} + +static inline size_t z_cbprintf_cxx_alignment(unsigned long long arg) +{ + return VA_STACK_ALIGN(long long); +} + +template < typename T > +static inline size_t z_cbprintf_cxx_alignment(T arg) +{ + return MAX(__alignof__(arg), VA_STACK_MIN_ALIGN); +} + +#endif /* __cplusplus */ +#endif /* ZEPHYR_INCLUDE_SYS_CBPRINTF_CXX_H_ */ diff --git a/include/sys/cbprintf_internal.h b/include/sys/cbprintf_internal.h index 5082cabbf031c7..b6e9f2a0cd2001 100644 --- a/include/sys/cbprintf_internal.h +++ b/include/sys/cbprintf_internal.h @@ -15,10 +15,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif - /* * Special alignment cases */ @@ -49,6 +45,20 @@ extern "C" { #define VA_STACK_ALIGN(type) MAX(VA_STACK_MIN_ALIGN, __alignof__(type)) #endif +static inline void z_cbprintf_wcpy(int *dst, int *src, size_t len) +{ + for (size_t i = 0; i < len; i++) { + dst[i] = src[i]; + } +} + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + #if defined(__sparc__) /* The SPARC V8 ABI guarantees that the arguments of a variable argument * list function are stored on the stack at addresses which are 32-bit @@ -71,6 +81,9 @@ extern "C" { * * @return 1 if char * or wchar_t *, 0 otherwise. */ +#ifdef __cplusplus +#define Z_CBPRINTF_IS_PCHAR(x) z_cbprintf_cxx_is_pchar(x) +#else #define Z_CBPRINTF_IS_PCHAR(x) _Generic((x), \ char * : 1, \ const char * : 1, \ @@ -82,6 +95,7 @@ extern "C" { const volatile wchar_t * : 1, \ default : \ 0) +#endif /** @brief Calculate number of char * or wchar_t * arguments in the arguments. * @@ -123,6 +137,9 @@ extern "C" { * * @return Number of bytes used for storing the argument. */ +#ifdef __cplusplus +#define Z_CBPRINTF_ARG_SIZE(v) z_cbprintf_cxx_arg_size(v) +#else #define Z_CBPRINTF_ARG_SIZE(v) \ _Generic((v), \ float : sizeof(double), \ @@ -130,13 +147,7 @@ extern "C" { /* coverity[bad_sizeof] */ \ sizeof((v) + 0) \ ) - -static inline void cbprintf_wcpy(int *dst, int *src, size_t len) -{ - for (size_t i = 0; i < len; i++) { - dst[i] = src[i]; - } -} +#endif /** @brief Promote and store argument in the buffer. * @@ -144,6 +155,9 @@ static inline void cbprintf_wcpy(int *dst, int *src, size_t len) * * @param arg Argument. */ +#ifdef __cplusplus +#define Z_CBPRINTF_STORE_ARG(buf, arg) z_cbprintf_cxx_store_arg(buf, arg) +#else #define Z_CBPRINTF_STORE_ARG(buf, arg) do { \ if (Z_CBPRINTF_VA_STACK_LL_DBL_MEMCPY) { \ /* If required, copy arguments by word to avoid unaligned access.*/ \ @@ -154,7 +168,7 @@ static inline void cbprintf_wcpy(int *dst, int *src, size_t len) 0.0); \ size_t arg_size = Z_CBPRINTF_ARG_SIZE(arg); \ size_t _wsize = arg_size / sizeof(int); \ - cbprintf_wcpy((int *)buf, \ + z_cbprintf_wcpy((int *)buf, \ (int *) _Generic((arg) + 0, float : &_d, default : &_v), \ _wsize); \ } else { \ @@ -176,6 +190,7 @@ static inline void cbprintf_wcpy(int *dst, int *src, size_t len) (const void **)buf) = arg; \ } \ } while (0) +#endif /** @brief Return alignment needed for given argument. * @@ -183,6 +198,9 @@ static inline void cbprintf_wcpy(int *dst, int *src, size_t len) * * @return Alignment in bytes. */ +#ifdef __cplusplus +#define Z_CBPRINTF_ALIGNMENT(_arg) z_cbprintf_cxx_alignment(_arg) +#else #define Z_CBPRINTF_ALIGNMENT(_arg) \ MAX(_Generic((_arg) + 0, \ float : VA_STACK_ALIGN(double), \ @@ -192,6 +210,7 @@ static inline void cbprintf_wcpy(int *dst, int *src, size_t len) unsigned long long : VA_STACK_ALIGN(long long), \ default : \ __alignof__((_arg) + 0)), VA_STACK_MIN_ALIGN) +#endif /** @brief Detect long double variable. * @@ -199,8 +218,12 @@ static inline void cbprintf_wcpy(int *dst, int *src, size_t len) * * @return 1 if @p x is a long double, 0 otherwise. */ +#ifdef __cplusplus +#define Z_CBPRINTF_IS_LONGDOUBLE(x) z_cbprintf_cxx_is_longdouble(x) +#else #define Z_CBPRINTF_IS_LONGDOUBLE(x) \ _Generic((x) + 0, long double : 1, default : 0) +#endif /** @brief Safely package arguments to a buffer. * @@ -227,7 +250,7 @@ static inline void cbprintf_wcpy(int *dst, int *src, size_t len) _align_offset += sizeof(int); \ } \ uint32_t _arg_size = Z_CBPRINTF_ARG_SIZE(_arg); \ - if (_buf && _idx < _max) { \ + if (_buf && _idx < (int)_max) { \ Z_CBPRINTF_STORE_ARG(&_buf[_idx], _arg); \ } \ _idx += _arg_size; \ @@ -302,7 +325,7 @@ do { \ "Buffer must be aligned."); \ } \ uint8_t *_pbuf = buf; \ - size_t _pmax = (buf != NULL) ? _inlen : SIZE_MAX; \ + size_t _pmax = (buf != NULL) ? _inlen : INT32_MAX; \ int _pkg_len = 0; \ int _pkg_offset = _align_offset; \ union z_cbprintf_hdr *_len_loc; \ @@ -317,11 +340,11 @@ do { \ /* Pack remaining arguments */\ FOR_EACH(Z_CBPRINTF_PACK_ARG, (;), __VA_ARGS__);\ /* Store length */ \ - _outlen = (_pkg_len > _pmax) ? -ENOSPC : _pkg_len; \ + _outlen = (_pkg_len > (int)_pmax) ? -ENOSPC : _pkg_len; \ /* Store length in the header, set number of dumped strings to 0 */ \ if (_pbuf) { \ union z_cbprintf_hdr hdr = { \ - .desc = {.len = _pkg_len / sizeof(int) } \ + .desc = {.len = (uint8_t)(_pkg_len / sizeof(int)) } \ }; \ *_len_loc = hdr; \ } \ diff --git a/tests/lib/cbprintf_package/CMakeLists.txt b/tests/lib/cbprintf_package/CMakeLists.txt index 9573ca54376b12..ef886a126f50cd 100644 --- a/tests/lib/cbprintf_package/CMakeLists.txt +++ b/tests/lib/cbprintf_package/CMakeLists.txt @@ -4,5 +4,4 @@ cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(cbprintf_package) -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) +target_sources(app PRIVATE src/main.c src/maincxx.cxx) diff --git a/tests/lib/cbprintf_package/src/main.c b/tests/lib/cbprintf_package/src/main.c index 56be5881720598..8dfea7d4f960f3 100644 --- a/tests/lib/cbprintf_package/src/main.c +++ b/tests/lib/cbprintf_package/src/main.c @@ -3,147 +3,16 @@ * * SPDX-License-Identifier: Apache-2.0 */ - #include -#include - -#define CBPRINTF_DEBUG 1 - -#ifndef CBPRINTF_PACKAGE_ALIGN_OFFSET -#define CBPRINTF_PACKAGE_ALIGN_OFFSET 0 -#endif - -#define ALIGN_OFFSET (sizeof(void *) * CBPRINTF_PACKAGE_ALIGN_OFFSET) - -struct out_buffer { - char *buf; - size_t idx; - size_t size; -}; - -static int out(int c, void *dest) -{ - int rv = EOF; - struct out_buffer *buf = dest; - - if (buf->idx < buf->size) { - buf->buf[buf->idx++] = (char)(unsigned char)c; - rv = (int)(unsigned char)c; - } - return rv; -} +#include -static char static_buf[512]; -static char runtime_buf[512]; -static char compare_buf[128]; +#include "test.inc" -void dump(const char *desc, uint8_t *package, size_t len) -{ - printk("%s package %p:\n", desc, package); - for (size_t i = 0; i < len; i++) { - printk("%02x ", package[i]); - } - printk("\n"); -} - -void unpack(const char *desc, struct out_buffer *buf, - uint8_t *package, size_t len) -{ - cbpprintf(out, buf, package); - buf->buf[buf->idx] = 0; - zassert_equal(strcmp(buf->buf, compare_buf), 0, - "Strings differ\nexp: |%s|\ngot: |%s|\n", - compare_buf, buf->buf); -} - -#define TEST_PACKAGING(fmt, ...) do { \ - snprintf(compare_buf, sizeof(compare_buf), fmt, __VA_ARGS__); \ - printk("-----------------------------------------\n"); \ - printk("%s\n", compare_buf); \ - uint8_t *pkg; \ - struct out_buffer rt_buf = { \ - .buf = runtime_buf, .idx = 0, .size = sizeof(runtime_buf) \ - }; \ - int rc = cbprintf_package(NULL, ALIGN_OFFSET, fmt, __VA_ARGS__); \ - zassert_true(rc > 0, "cbprintf_package() returned %d", rc); \ - int len = rc; \ - /* Aligned so the package is similar to the static one. */ \ - uint8_t __aligned(CBPRINTF_PACKAGE_ALIGNMENT) \ - rt_package[len + ALIGN_OFFSET]; \ - memset(rt_package, 0, len + ALIGN_OFFSET); \ - pkg = &rt_package[ALIGN_OFFSET]; \ - rc = cbprintf_package(pkg, len, fmt, __VA_ARGS__); \ - zassert_equal(rc, len, "cbprintf_package() returned %d, expected %d", \ - rc, len); \ - dump("runtime", pkg, len); \ - unpack("runtime", &rt_buf, pkg, len); \ - \ - struct out_buffer st_buf = { \ - .buf = static_buf, .idx = 0, .size = sizeof(static_buf) \ - }; \ - CBPRINTF_STATIC_PACKAGE(NULL, 0, len, ALIGN_OFFSET, fmt, __VA_ARGS__); \ - zassert_true(len > 0, "CBPRINTF_STATIC_PACKAGE() returned %d", len); \ - uint8_t __aligned(CBPRINTF_PACKAGE_ALIGNMENT) \ - package[len + ALIGN_OFFSET];\ - int outlen; \ - pkg = &package[ALIGN_OFFSET]; \ - CBPRINTF_STATIC_PACKAGE(pkg, len, outlen, ALIGN_OFFSET, fmt, __VA_ARGS__);\ - zassert_equal(len, outlen, NULL); \ - dump("static", pkg, len); \ - unpack("static", &st_buf, pkg, len); \ -} while (0) - -void test_cbprintf_package(void) -{ - volatile signed char sc = -11; - int i = 100; - char c = 'a'; - static const short s = -300; - long li = -1111111111; - long long lli = 0x1122334455667788; - unsigned char uc = 100; - unsigned int ui = 0x12345; - unsigned short us = 0x1234; - unsigned long ul = 0xaabbaabb; - unsigned long long ull = 0xaabbaabbaabb; - float f = -1.234; - double d = 1.2333; - - /* tests to exercize different element alignments */ - TEST_PACKAGING("test long %x %lx %x", 0xb1b2b3b4, li, 0xe4e3e2e1); - TEST_PACKAGING("test long long %x %llx %x", 0xb1b2b3b4, lli, 0xe4e3e2e1); - if (IS_ENABLED(CONFIG_CBPRINTF_FP_SUPPORT)) { - TEST_PACKAGING("test double %x %f %x", 0xb1b2b3b4, d, 0xe4e3e2e1); - } - - /* tests with varied elements */ - TEST_PACKAGING("test %d %hd %hhd", i, s, sc); - TEST_PACKAGING("test %ld %llx %hhu %hu %u", li, lli, uc, us, ui); - TEST_PACKAGING("test %lu %llu", ul, ull); - TEST_PACKAGING("test %c %p", c, &c); - if (IS_ENABLED(CONFIG_CBPRINTF_FP_SUPPORT)) { - TEST_PACKAGING("test %f %a", f, d); -#if CONFIG_CBPRINTF_PACKAGE_LONGDOUBLE - long double ld = 1.2333; - - TEST_PACKAGING("test %Lf", ld); -#endif - } -} +void test_cxx(void); +void test_cc(void); void test_main(void) { - printk("sizeof: int=%zu long=%zu ptr=%zu long long=%zu double=%zu long double=%zu\n", - sizeof(int), sizeof(long), sizeof(void *), sizeof(long long), - sizeof(double), sizeof(long double)); - printk("alignof: int=%zu long=%zu ptr=%zu long long=%zu double=%zu long double=%zu\n", - __alignof__(int), __alignof__(long), __alignof__(void *), - __alignof__(long long), __alignof__(double), __alignof__(long double)); - printk("%s C11 _Generic\n", Z_C_GENERIC ? "With" : "Without"); - - ztest_test_suite(cbprintf_package, - ztest_unit_test(test_cbprintf_package) - ); - - ztest_run_test_suite(cbprintf_package); + test_cc(); + test_cxx(); } diff --git a/tests/lib/cbprintf_package/src/maincxx.cxx b/tests/lib/cbprintf_package/src/maincxx.cxx new file mode 100644 index 00000000000000..2b9fe8c576063d --- /dev/null +++ b/tests/lib/cbprintf_package/src/maincxx.cxx @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include + +#include "test.inc" diff --git a/tests/lib/cbprintf_package/src/test.inc b/tests/lib/cbprintf_package/src/test.inc new file mode 100644 index 00000000000000..73cad50e9a2f9c --- /dev/null +++ b/tests/lib/cbprintf_package/src/test.inc @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +#define CBPRINTF_DEBUG 1 + +#ifndef CBPRINTF_PACKAGE_ALIGN_OFFSET +#define CBPRINTF_PACKAGE_ALIGN_OFFSET 0 +#endif + +#define ALIGN_OFFSET (sizeof(void *) * CBPRINTF_PACKAGE_ALIGN_OFFSET) + +struct out_buffer { + char *buf; + size_t idx; + size_t size; +}; + +static int out(int c, void *dest) +{ + int rv = EOF; + struct out_buffer *buf = (struct out_buffer *)dest; + + if (buf->idx < buf->size) { + buf->buf[buf->idx++] = (char)(unsigned char)c; + rv = (int)(unsigned char)c; + } + return rv; +} + +static char static_buf[512]; +static char runtime_buf[512]; +static char compare_buf[128]; + +void dump(const char *desc, uint8_t *package, size_t len) +{ + printk("%s package %p:\n", desc, package); + for (size_t i = 0; i < len; i++) { + printk("%02x ", package[i]); + } + printk("\n"); +} + +void unpack(const char *desc, struct out_buffer *buf, + uint8_t *package, size_t len) +{ + cbpprintf((cbprintf_cb)out, buf, package); + buf->buf[buf->idx] = 0; + zassert_equal(strcmp(buf->buf, compare_buf), 0, + "Strings differ\nexp: |%s|\ngot: |%s|\n", + compare_buf, buf->buf); +} + +#define TEST_PACKAGING(fmt, ...) do { \ + snprintf(compare_buf, sizeof(compare_buf), fmt, __VA_ARGS__); \ + printk("-----------------------------------------\n"); \ + printk("%s\n", compare_buf); \ + uint8_t *pkg; \ + struct out_buffer rt_buf = { \ + .buf = runtime_buf, .idx = 0, .size = sizeof(runtime_buf) \ + }; \ + int rc = cbprintf_package(NULL, ALIGN_OFFSET, fmt, __VA_ARGS__); \ + zassert_true(rc > 0, "cbprintf_package() returned %d", rc); \ + int len = rc; \ + /* Aligned so the package is similar to the static one. */ \ + uint8_t __aligned(CBPRINTF_PACKAGE_ALIGNMENT) \ + rt_package[len + ALIGN_OFFSET]; \ + memset(rt_package, 0, len + ALIGN_OFFSET); \ + pkg = &rt_package[ALIGN_OFFSET]; \ + rc = cbprintf_package(pkg, len, fmt, __VA_ARGS__); \ + zassert_equal(rc, len, "cbprintf_package() returned %d, expected %d", \ + rc, len); \ + dump("runtime", pkg, len); \ + unpack("runtime", &rt_buf, pkg, len); \ + struct out_buffer st_buf = { \ + .buf = static_buf, .idx = 0, .size = sizeof(static_buf) \ + }; \ + CBPRINTF_STATIC_PACKAGE(NULL, 0, len, ALIGN_OFFSET, fmt, __VA_ARGS__); \ + zassert_true(len > 0, "CBPRINTF_STATIC_PACKAGE() returned %d", len); \ + uint8_t __aligned(CBPRINTF_PACKAGE_ALIGNMENT) \ + package[len + ALIGN_OFFSET];\ + int outlen; \ + pkg = &package[ALIGN_OFFSET]; \ + CBPRINTF_STATIC_PACKAGE(pkg, len, outlen, ALIGN_OFFSET, fmt, __VA_ARGS__);\ + zassert_equal(len, outlen, NULL); \ + dump("static", pkg, len); \ + unpack("static", &st_buf, pkg, len); \ +} while (0) + +void test_cbprintf_package(void) +{ + volatile signed char sc = -11; + int i = 100; + char c = 'a'; + static const short s = -300; + long li = -1111111111; + long long lli = 0x1122334455667788; + unsigned char uc = 100; + unsigned int ui = 0x12345; + unsigned short us = 0x1234; + unsigned long ul = 0xaabbaabb; + unsigned long long ull = 0xaabbaabbaabb; + + + /* tests to exercize different element alignments */ + TEST_PACKAGING("test long %x %lx %x", 0xb1b2b3b4, li, 0xe4e3e2e1); + TEST_PACKAGING("test long long %x %llx %x", 0xb1b2b3b4, lli, 0xe4e3e2e1); + + /* tests with varied elements */ + TEST_PACKAGING("test %d %hd %hhd", i, s, sc); + TEST_PACKAGING("test %ld %llx %hhu %hu %u", li, lli, uc, us, ui); + TEST_PACKAGING("test %lu %llu", ul, ull); + TEST_PACKAGING("test %c %p", c, &c); + + if (IS_ENABLED(CONFIG_CBPRINTF_FP_SUPPORT)) { + float f = -1.234; + double d = 1.2333; + + TEST_PACKAGING("test double %x %f %x", 0xb1b2b3b4, d, 0xe4e3e2e1); + TEST_PACKAGING("test %f %a", f, d); +#if CONFIG_CBPRINTF_PACKAGE_LONGDOUBLE + long double ld = 1.2333; + + TEST_PACKAGING("test %Lf", ld); +#endif + } +} + +#if __cplusplus +extern "C" void test_cxx(void); +void test_cxx(void) +#else +void test_cc(void) +#endif +{ +#ifdef __cplusplus + printk("C++\n"); +#else + printk("sizeof: int=%zu long=%zu ptr=%zu long long=%zu double=%zu long double=%zu\n", + sizeof(int), sizeof(long), sizeof(void *), sizeof(long long), + sizeof(double), sizeof(long double)); + printk("alignof: int=%zu long=%zu ptr=%zu long long=%zu double=%zu long double=%zu\n", + __alignof__(int), __alignof__(long), __alignof__(void *), + __alignof__(long long), __alignof__(double), __alignof__(long double)); + printk("%s C11 _Generic\n", Z_C_GENERIC ? "With" : "Without"); +#endif + + ztest_test_suite(cbprintf_package, + ztest_unit_test(test_cbprintf_package) + ); + + ztest_run_test_suite(cbprintf_package); +}