From 789fb7fec0427914dafadd1ee16a1762aada5f36 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Wed, 17 Jan 2024 23:22:09 +0000 Subject: [PATCH 1/2] Revert "common.h: Guard definition of IS_ALIGNED for Zephyr builds" This reverts commit 0a3b816c033cd2741f422d9892c952fa3e43fea6. Opportunistic, `#ifndef` definitions make macro troubleshooting even more of a nightmare than it already is. https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#rule-a-3-macro-name-collisions forbids #ifndef in Zephyr. Signed-off-by: Marc Herbert --- src/include/sof/common.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/include/sof/common.h b/src/include/sof/common.h index 343cda56c741..6a875f5a90f7 100644 --- a/src/include/sof/common.h +++ b/src/include/sof/common.h @@ -14,14 +14,8 @@ /* callers must check/use the return value */ #define __must_check __attribute__((warn_unused_result)) -#ifdef __ZEPHYR__ -#include -#endif - /* Align the number to the nearest alignment value */ -#ifndef IS_ALIGNED #define IS_ALIGNED(size, alignment) ((size) % (alignment) == 0) -#endif /* Treat zero as a special case because it wraps around */ #define is_power_of_2(x) ((x) && !((x) & ((x) - 1))) From d9cafac6265f9d101c6c99cb075d86a0c3e6d520 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Wed, 17 Jan 2024 23:26:05 +0000 Subject: [PATCH 2/2] Rename IS_ALIGN() to SOF_IS_ALIGN() This is the simplest, cheapest and safest to avoid the collision with the incoming Zephyr macro IS_ALIGN() submitted in https://github.com/zephyrproject-rtos/zephyr/pull/67243 As SOF depends on Zephyr, most SOF symbols should be prefixed SOF_ or something specific. This is compliant with: https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#rule-a-3-macro-name-collisions Signed-off-by: Marc Herbert --- src/audio/dai-zephyr.c | 2 +- src/audio/kpb.c | 6 +++--- src/include/sof/common.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index ca5488c07231..b2abf58dedbc 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -633,7 +633,7 @@ static int dai_set_sg_config(struct dai_data *dd, struct comp_dev *dev, uint32_t period_count); buf_size = period_count * period_bytes; do { - if (IS_ALIGNED(buf_size, max_block_count)) { + if (SOF_IS_ALIGNED(buf_size, max_block_count)) { period_count = max_block_count; period_bytes = buf_size / period_count; break; diff --git a/src/audio/kpb.c b/src/audio/kpb.c index 6d0507a033d1..fe321479ab2a 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -1895,7 +1895,7 @@ static void kpb_convert_24b_to_32b(const void *linear_source, int ioffset, int i = 0; ae_int24x2 d24 = AE_ZERO24(); - if (!IS_ALIGNED((uintptr_t)out_ptr, 8)) { + if (!SOF_IS_ALIGNED((uintptr_t)out_ptr, 8)) { AE_LA24_IP(d24, align_in, in); ae_int32x2 d320 = d24; int higher = AE_MOVAD32_H(d320); @@ -1996,7 +1996,7 @@ static void kpb_convert_32b_to_24b(const struct audio_stream *source, int ioffse ae_f24x2 vs = AE_ZERO24(); ae_valign align_out = AE_ZALIGN64(); - if (!IS_ALIGNED((uintptr_t)sin, 8)) { + if (!SOF_IS_ALIGNED((uintptr_t)sin, 8)) { AE_L32F24_XC(vs, (const ae_f24 *)sin, 4); AE_SA24_IP(vs, align_out, sout); n_samples--; @@ -2154,7 +2154,7 @@ static void kpb_copy_24b_in_32b(const struct audio_stream *source, uint32_t ioff ae_int32x2 *sout = (ae_int32x2 *)out; ae_int32x2 vs = AE_ZERO32(); - if (!IS_ALIGNED((uintptr_t)sin, 8)) { + if (!SOF_IS_ALIGNED((uintptr_t)sin, 8)) { AE_L32_IP(vs, (const ae_int32 *)sin, 4); AE_S32_L_IP(vs, (ae_int32 *)sout, 4); n_samples--; diff --git a/src/include/sof/common.h b/src/include/sof/common.h index 6a875f5a90f7..4c6cafd4c1d8 100644 --- a/src/include/sof/common.h +++ b/src/include/sof/common.h @@ -15,7 +15,7 @@ #define __must_check __attribute__((warn_unused_result)) /* Align the number to the nearest alignment value */ -#define IS_ALIGNED(size, alignment) ((size) % (alignment) == 0) +#define SOF_IS_ALIGNED(size, alignment) ((size) % (alignment) == 0) /* Treat zero as a special case because it wraps around */ #define is_power_of_2(x) ((x) && !((x) & ((x) - 1)))