Closed fpistm closed 3 years ago
This allows to save space. (around 4k). Thanks to @PeeJay in this comment: https://github.com/stm32duino/STM32LowPower/issues/13#issuecomment-689512983
Note that I've added a check to 0 value because __builtin_clz with 0 produce an undefined result: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
__builtin_clz
Built-in Function: int __builtin_clz (unsigned int x) Returns the number of leading 0-bits in x, starting at the most significant bit position. If x is 0, the result is undefined.
Built-in Function: int __builtin_clz (unsigned int x)
Returns the number of leading 0-bits in x, starting at the most significant bit position. If x is 0, the result is undefined.
You beat me to it! :) I noticed my M0+ core doesn't actually have the clz instruction, so the compiler implements it instead in 84 bytes.
This allows to save space. (around 4k). Thanks to @PeeJay in this comment: https://github.com/stm32duino/STM32LowPower/issues/13#issuecomment-689512983
Note that I've added a check to 0 value because
__builtin_clz
with 0 produce an undefined result: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html