From ef68dc9482896acf0c8a80c64768154a748154a3 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Mon, 15 Aug 2022 12:34:22 -0700 Subject: [PATCH] zephyr: macros: Avoid macros redefinition Some macros defined in SoF are also being defined in Zephyr. Just avoiding redefinition including Zephyr's header when building with Zephyr. Signed-off-by: Flavio Ceolin --- src/include/sof/bit.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/include/sof/bit.h b/src/include/sof/bit.h index 9d7c0b45e11d..fea5d49e1c14 100644 --- a/src/include/sof/bit.h +++ b/src/include/sof/bit.h @@ -8,10 +8,9 @@ #ifndef __SOF_BIT_H__ #define __SOF_BIT_H__ -/* Zephyr defines this - remove local copy once Zephyr integration complete */ -#ifdef BIT -#undef BIT -#endif +#ifdef __ZEPHYR__ +#include +#else #if ASSEMBLY #define BIT(b) (1 << (b)) @@ -19,14 +18,18 @@ #define BIT(b) (1UL << (b)) #endif -#define MASK(b_hi, b_lo) \ - (((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL) << (b_lo)) -#define SET_BIT(b, x) (((x) & 1) << (b)) #define SET_BITS(b_hi, b_lo, x) \ (((x) & ((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL)) << (b_lo)) #define GET_BIT(b, x) \ (((x) & (1ULL << (b))) >> (b)) + +#endif /* __ZEPHYR__ */ + #define GET_BITS(b_hi, b_lo, x) \ (((x) & MASK(b_hi, b_lo)) >> (b_lo)) +#define MASK(b_hi, b_lo) \ + (((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL) << (b_lo)) +#define SET_BIT(b, x) (((x) & 1) << (b)) + #endif /* __SOF_BIT_H__ */