diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2011-09-23 21:08:04 +0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2011-09-23 21:08:04 +0400 |
commit | 1ee139bca076a1a3606a8a924a698d356d40cbb8 (patch) | |
tree | 84496f0f25c53b14e2791646466d276cf9185006 /silk/SigProc_FIX.h | |
parent | 44ce46dc129f136c93da492299562c1f0fcd519d (diff) |
Making the left shift macros use unsigned to avoid undefined behaviour
Result should be bit-identical on most machines/compilers, minus the undefined
behaviour
Diffstat (limited to 'silk/SigProc_FIX.h')
-rw-r--r-- | silk/SigProc_FIX.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/silk/SigProc_FIX.h b/silk/SigProc_FIX.h index 070ed715..edb307f8 100644 --- a/silk/SigProc_FIX.h +++ b/silk/SigProc_FIX.h @@ -494,10 +494,10 @@ static inline opus_int32 silk_ROR32( opus_int32 a32, opus_int rot ) #define silk_ADD_POS_SAT32(a, b) ((((a)+(b)) & 0x80000000) ? silk_int32_MAX : ((a)+(b))) #define silk_ADD_POS_SAT64(a, b) ((((a)+(b)) & 0x8000000000000000LL) ? silk_int64_MAX : ((a)+(b))) -#define silk_LSHIFT8(a, shift) ((a)<<(shift)) /* shift >= 0, shift < 8 */ -#define silk_LSHIFT16(a, shift) ((a)<<(shift)) /* shift >= 0, shift < 16 */ -#define silk_LSHIFT32(a, shift) ((a)<<(shift)) /* shift >= 0, shift < 32 */ -#define silk_LSHIFT64(a, shift) ((a)<<(shift)) /* shift >= 0, shift < 64 */ +#define silk_LSHIFT8(a, shift) ((opus_int8)((opus_uint8)(a)<<(shift))) /* shift >= 0, shift < 8 */ +#define silk_LSHIFT16(a, shift) ((opus_int16)((opus_uint16)(a)<<(shift))) /* shift >= 0, shift < 16 */ +#define silk_LSHIFT32(a, shift) ((opus_int32)((opus_uint32)(a)<<(shift))) /* shift >= 0, shift < 32 */ +#define silk_LSHIFT64(a, shift) ((opus_int64)((opus_uint64)(a)<<(shift))) /* shift >= 0, shift < 64 */ #define silk_LSHIFT(a, shift) silk_LSHIFT32(a, shift) /* shift >= 0, shift < 32 */ #define silk_RSHIFT8(a, shift) ((a)>>(shift)) /* shift >= 0, shift < 8 */ @@ -512,7 +512,6 @@ static inline opus_int32 silk_ROR32( opus_int32 a32, opus_int rot ) #define silk_LSHIFT_SAT32(a, shift) (silk_LSHIFT32( silk_LIMIT( (a), silk_RSHIFT32( silk_int32_MIN, (shift) ), \ silk_RSHIFT32( silk_int32_MAX, (shift) ) ), (shift) )) -#define silk_LSHIFT_ovflw(a, shift) ((a)<<(shift)) /* shift >= 0, allowed to overflow */ #define silk_LSHIFT_uint(a, shift) ((a)<<(shift)) /* shift >= 0 */ #define silk_RSHIFT_uint(a, shift) ((a)>>(shift)) /* shift >= 0 */ |