From 16f5249b2600e49834e057cc1fc1daa40dd4bd49 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Mon, 3 May 2021 14:40:25 -0700 Subject: [PATCH] lib: os: cbprintf_packaged: update alignment for x86-32 The size of long double on x86-32 is 12 which is not a power of 2, and this results in build error when it is being used for alignment of buf32 in log_core.c. So manually set it to 16. Signed-off-by: Daniel Leung --- include/sys/cbprintf.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/sys/cbprintf.h b/include/sys/cbprintf.h index 64a6fc74565..e366829add4 100644 --- a/include/sys/cbprintf.h +++ b/include/sys/cbprintf.h @@ -47,6 +47,13 @@ extern "C" { /** @brief Required alignment of the buffer used for packaging. */ #ifdef __xtensa__ #define CBPRINTF_PACKAGE_ALIGNMENT 16 +#elif defined(CONFIG_X86) && !defined(CONFIG_64BIT) +/* sizeof(long double) is 12 on x86-32, which is not power of 2. + * So set it manually. + */ +#define CBPRINTF_PACKAGE_ALIGNMENT \ + (IS_ENABLED(CONFIG_CBPRINTF_PACKAGE_LONGDOUBLE) ? \ + 16 : MAX(sizeof(double), sizeof(long long))) #else #define CBPRINTF_PACKAGE_ALIGNMENT \ (IS_ENABLED(CONFIG_CBPRINTF_PACKAGE_LONGDOUBLE) ? \