From a3ad27ed1033f79ee906f361345a3057c82bca2c Mon Sep 17 00:00:00 2001 From: "Petteri.Aimonen" Date: Fri, 31 Aug 2012 10:16:09 +0000 Subject: Fix a division bug on 64-bit platforms. The GCC builtin clzl depends on the sizeof(long), which caused an error if it was other than 32 bits. Fixes issue #17. --- libfixmath/fix16.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfixmath/fix16.c b/libfixmath/fix16.c index 0299151..05a8d93 100644 --- a/libfixmath/fix16.c +++ b/libfixmath/fix16.c @@ -275,7 +275,7 @@ fix16_t fix16_smul(fix16_t inArg0, fix16_t inArg1) #if !defined(FIXMATH_OPTIMIZE_8BIT) #ifdef __GNUC__ // Count leading zeros, using processor-specific instruction if available. -#define clz(x) __builtin_clzl(x) +#define clz(x) (__builtin_clzl(x) - (8 * sizeof(long) - 32)) #else static uint8_t clz(uint32_t x) { -- cgit v1.2.3