diff options
| author | Petteri.Aimonen <Petteri.Aimonen@gmail.com> | 2012-08-31 10:16:09 +0000 |
|---|---|---|
| committer | Petteri.Aimonen <Petteri.Aimonen@gmail.com> | 2012-08-31 10:16:09 +0000 |
| commit | a3ad27ed1033f79ee906f361345a3057c82bca2c (patch) | |
| tree | 31206e37421fad8b3447a04dc0565b9aaf51c5a2 | |
| parent | 10af3a6c608432e9f51562f6a67e873cc111ea50 (diff) | |
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.
| -rw-r--r-- | libfixmath/fix16.c | 2 |
1 files changed, 1 insertions, 1 deletions
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)
{
|
