[riot-notifications] [RIOT] Use GCC/Clang builtins for bit arithmetics (#294)

René Kijewski notifications at github.com
Sun Nov 3 15:22:43 CET 2013


> @@ -39,29 +40,3 @@
>  
>      return r;
>  }
> -/*---------------------------------------------------------------------------*/
> -unsigned
> -number_of_lowest_bit(register unsigned v)
> -{

Maybe it would be better to keep the `__buildin` calls in this function instead of converting them to #defines?
The generated code could be rather long if the compiler uses bit magic in order to speed up the evaluation.

Maybe someone could check the .text size using the `#define`s, and using
```c
signed number_of_lowest_bit(unsigned v)
{
    return __builtin_ffs(v) - 1;
}

unsigned number_of_bits_set(unsigned v)
{
    return __builtin_popcount(v);
}
```

---
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/294/files#r7390784
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20131103/1eae9336/attachment-0001.html>


More information about the notifications mailing list