From 2512698098ed2e2cdd671404f39380e4d50a7883 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 14 Apr 2023 18:57:58 +0000 Subject: [PATCH] numbers.sh: do not (re)define ROUND_DOWN() if __ZEPHYR__ Move the ROUND_DOWN() definition to the nearby #ifndef __ZEPHYR__ block. The previous `#ifndef ROUND_DOWN` logic depends on the #include order, so it fails sometimes. Fixes commit a6f8daec2acb ("kpb: add micselection function") Fixes XCC compilation failure with ``` ./scripts/xtensa-build-zephyr.py mtl --cmake-args='-DEXTRA_CFLAGS=-Werror' - In file included from sof/src/audio/src/src_hifi4.c:22: zephyr/include/zephyr/sys/util.h:238:9: warning: 'ROUND_DOWN' macro redefined [-Wmacro-redefined] ^ sof/zephyr/../src/include/sof/math/numbers.h:33:9: note: previous definition is here ``` Signed-off-by: Marc Herbert --- src/include/sof/math/numbers.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/include/sof/math/numbers.h b/src/include/sof/math/numbers.h index 5e314aa2c..6ecfc9024 100644 --- a/src/include/sof/math/numbers.h +++ b/src/include/sof/math/numbers.h @@ -18,6 +18,12 @@ */ #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) < (b) ? (b) : (a)) + +#define ROUND_DOWN(size, alignment) ({ \ + typeof(size) __size = (size); \ + typeof(alignment) __alignment = (alignment); \ + __size - (__size % __alignment); \ +}) #endif /* ! __ZEPHYR__ */ #define ABS(a) ({ \ @@ -29,13 +35,7 @@ __a < 0 ? -1 : \ __a > 0 ? 1 : 0; \ }) -#ifndef ROUND_DOWN -#define ROUND_DOWN(size, alignment) ({ \ - typeof(size) __size = (size); \ - typeof(alignment) __alignment = (alignment); \ - __size - (__size % __alignment); \ -}) -#endif /* !ROUND_DOWN */ + int gcd(int a, int b); /* Calculate greatest common divisor for a and b */ /* This is a divide function that returns ceil of the quotient.