@@ -186,31 +186,31 @@ NS_INLINE uint16_t common_read_16_bit_inverse(const uint8_t data_buf[__static 2]
186186/*
187187 * Count bits in a byte
188188 *
189- * \param byte byte to inspect
189+ * \param value byte to inspect
190190 *
191191 * \return number of 1-bits in byte
192192 */
193- NS_INLINE uint_fast8_t common_count_bits (uint8_t byte );
193+ NS_INLINE uint_fast8_t common_count_bits (uint8_t value );
194194
195195/*
196196 * Count leading zeros in a byte
197197 *
198198 * \deprecated Use common_count_leading_zeros_8
199199 *
200- * \param byte byte to inspect
200+ * \param value byte to inspect
201201 *
202202 * \return number of leading zeros in byte (0-8)
203203 */
204- NS_INLINE uint_fast8_t common_count_leading_zeros (uint8_t byte );
204+ NS_INLINE uint_fast8_t common_count_leading_zeros (uint8_t value );
205205
206206/*
207207 * Count leading zeros in a byte
208208 *
209- * \param byte byte to inspect
209+ * \param value byte to inspect
210210 *
211211 * \return number of leading zeros in byte (0-8)
212212 */
213- NS_INLINE uint_fast8_t common_count_leading_zeros_8 (uint8_t byte );
213+ NS_INLINE uint_fast8_t common_count_leading_zeros_8 (uint8_t value );
214214
215215/*
216216 * Count leading zeros in a 16-bit value
@@ -490,43 +490,43 @@ COMMON_FUNCTIONS_FN uint16_t common_read_16_bit_inverse(const uint8_t data_buf[_
490490 return temp_16 ;
491491}
492492
493- COMMON_FUNCTIONS_FN uint_fast8_t common_count_bits (uint8_t byte )
493+ COMMON_FUNCTIONS_FN uint_fast8_t common_count_bits (uint8_t value )
494494{
495495 /* First step sets each bit pair to be count of bits (00,01,10) */
496496 /* [00-00 = 00, 01-00 = 01, 10-01 = 01, 11-01 = 10] */
497- uint_fast8_t count = byte - ((byte >> 1 ) & 0x55 );
497+ uint_fast8_t count = value - ((value >> 1 ) & 0x55 );
498498 /* Add bit pairs to make each nibble contain count of bits (0-4) */
499499 count = (count & 0x33 ) + ((count >> 2 ) & 0x33 );
500500 /* Final result is sum of nibbles (0-8) */
501501 count = (count >> 4 ) + (count & 0x0F );
502502 return count ;
503503}
504504
505- COMMON_FUNCTIONS_FN uint_fast8_t common_count_leading_zeros (uint8_t byte )
505+ COMMON_FUNCTIONS_FN uint_fast8_t common_count_leading_zeros (uint8_t value )
506506{
507- return common_count_leading_zeros_8 (byte );
507+ return common_count_leading_zeros_8 (value );
508508}
509509
510- COMMON_FUNCTIONS_FN uint_fast8_t common_count_leading_zeros_8 (uint8_t byte )
510+ COMMON_FUNCTIONS_FN uint_fast8_t common_count_leading_zeros_8 (uint8_t value )
511511{
512512#ifdef __CC_ARM
513- return byte ? __clz ((unsigned int ) byte << 24 ) : 8 ;
513+ return value ? __clz ((unsigned int ) value << 24 ) : 8 ;
514514#elif defined __GNUC__
515- return byte ? __builtin_clz ((unsigned int ) byte << 24 ) : 8 ;
515+ return value ? __builtin_clz ((unsigned int ) value << 24 ) : 8 ;
516516#else
517517 uint_fast8_t cnt = 0 ;
518- if (byte == 0 ) {
518+ if (value == 0 ) {
519519 return 8 ;
520520 }
521- if ((byte & 0xF0 ) == 0 ) {
522- byte <<= 4 ;
521+ if ((value & 0xF0 ) == 0 ) {
522+ value <<= 4 ;
523523 cnt += 4 ;
524524 }
525- if ((byte & 0xC0 ) == 0 ) {
526- byte <<= 2 ;
525+ if ((value & 0xC0 ) == 0 ) {
526+ value <<= 2 ;
527527 cnt += 2 ;
528528 }
529- if ((byte & 0x80 ) == 0 ) {
529+ if ((value & 0x80 ) == 0 ) {
530530 cnt += 1 ;
531531 }
532532
0 commit comments