From 0cc0ab6061917f96b7744f59f6bf2cb685f3c0c9 Mon Sep 17 00:00:00 2001 From: Lech Betlej Date: Wed, 21 Nov 2018 19:23:55 +0100 Subject: [PATCH] Fixes for macros used for bit masks creation. Bit mask setting macros for for specific parameters were expanded in a way that was causing unexpected compiler behaviour. Specifically: literal 1 was treated as 32bit integer ((1 << ((b_hi)-(b_lo) + 1)) -1) was expanded to shift the 32bit integer by 32. ((1 << (31 - 0 + 1)) -1) Macro MASK() was was missing left shift. Signed-off-by: Lech Betlej --- src/include/sof/bit.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/include/sof/bit.h b/src/include/sof/bit.h index 9f393539d..a082462d8 100644 --- a/src/include/sof/bit.h +++ b/src/include/sof/bit.h @@ -32,9 +32,10 @@ #define __INCLUDE_BIT__ #define BIT(b) (1 << (b)) -#define MASK(b_hi, b_lo) ((1 << ((b_hi) - (b_lo) + 1)) - 1) +#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) & ((1 << ((b_hi) - (b_lo) + 1)) - 1)) << (b_lo)) + (((x) & ((1ULL << ((b_hi) - (b_lo) + 1ULL)) - 1ULL)) << (b_lo)) #endif