Skip to content

Commit

Permalink
numbers.sh: do not (re)define ROUND_DOWN() if __ZEPHYR__
Browse files Browse the repository at this point in the history
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 a6f8dae ("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 <marc.herbert@intel.com>
  • Loading branch information
marc-hb authored and kv2019i committed Apr 17, 2023
1 parent c7e98ee commit 2512698
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/include/sof/math/numbers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) ({ \
Expand All @@ -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.
Expand Down

0 comments on commit 2512698

Please sign in to comment.