1
0
mirror of https://github.com/bluekitchen/btstack.git synced 2025-04-01 13:20:50 +00:00

mesh_node: use btstack_clz

This commit is contained in:
Matthias Ringwald 2022-04-30 21:29:12 +02:00
parent ec08441f2c
commit b8fd168e43

@ -42,6 +42,8 @@
#include "mesh/mesh_node.h" #include "mesh/mesh_node.h"
#include "btstack_util.h"
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
@ -275,12 +277,12 @@ uint8_t mesh_heartbeat_count_log(uint16_t value){
if (value == 0xffff) return 0xff; if (value == 0xffff) return 0xff;
// count leading zeros, supported by clang and gcc // count leading zeros, supported by clang and gcc
// note: CountLog(8) == CountLog(7) = 3 // note: CountLog(8) == CountLog(7) = 3
return 33 - __builtin_clz(value - 1); return 33 - btstack_clz(value - 1);
} }
uint8_t mesh_heartbeat_period_log(uint16_t value){ uint8_t mesh_heartbeat_period_log(uint16_t value){
if (value == 0) return 0x00; if (value == 0) return 0x00;
// count leading zeros, supported by clang and gcc // count leading zeros, supported by clang and gcc
// note: PeriodLog(8) == PeriodLog(7) = 3 // note: PeriodLog(8) == PeriodLog(7) = 3
return 33 - __builtin_clz(value - 1); return 33 - btstack_clz(value - 1);
} }