@@ -186,31 +186,31 @@ NS_INLINE uint16_t common_read_16_bit_inverse(const uint8_t data_buf[__static 2]
186
186
/*
187
187
* Count bits in a byte
188
188
*
189
- * \param byte byte to inspect
189
+ * \param value byte to inspect
190
190
*
191
191
* \return number of 1-bits in byte
192
192
*/
193
- NS_INLINE uint_fast8_t common_count_bits (uint8_t byte );
193
+ NS_INLINE uint_fast8_t common_count_bits (uint8_t value );
194
194
195
195
/*
196
196
* Count leading zeros in a byte
197
197
*
198
198
* \deprecated Use common_count_leading_zeros_8
199
199
*
200
- * \param byte byte to inspect
200
+ * \param value byte to inspect
201
201
*
202
202
* \return number of leading zeros in byte (0-8)
203
203
*/
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 );
205
205
206
206
/*
207
207
* Count leading zeros in a byte
208
208
*
209
- * \param byte byte to inspect
209
+ * \param value byte to inspect
210
210
*
211
211
* \return number of leading zeros in byte (0-8)
212
212
*/
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 );
214
214
215
215
/*
216
216
* 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[_
490
490
return temp_16 ;
491
491
}
492
492
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 )
494
494
{
495
495
/* First step sets each bit pair to be count of bits (00,01,10) */
496
496
/* [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 );
498
498
/* Add bit pairs to make each nibble contain count of bits (0-4) */
499
499
count = (count & 0x33 ) + ((count >> 2 ) & 0x33 );
500
500
/* Final result is sum of nibbles (0-8) */
501
501
count = (count >> 4 ) + (count & 0x0F );
502
502
return count ;
503
503
}
504
504
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 )
506
506
{
507
- return common_count_leading_zeros_8 (byte );
507
+ return common_count_leading_zeros_8 (value );
508
508
}
509
509
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 )
511
511
{
512
512
#ifdef __CC_ARM
513
- return byte ? __clz ((unsigned int ) byte << 24 ) : 8 ;
513
+ return value ? __clz ((unsigned int ) value << 24 ) : 8 ;
514
514
#elif defined __GNUC__
515
- return byte ? __builtin_clz ((unsigned int ) byte << 24 ) : 8 ;
515
+ return value ? __builtin_clz ((unsigned int ) value << 24 ) : 8 ;
516
516
#else
517
517
uint_fast8_t cnt = 0 ;
518
- if (byte == 0 ) {
518
+ if (value == 0 ) {
519
519
return 8 ;
520
520
}
521
- if ((byte & 0xF0 ) == 0 ) {
522
- byte <<= 4 ;
521
+ if ((value & 0xF0 ) == 0 ) {
522
+ value <<= 4 ;
523
523
cnt += 4 ;
524
524
}
525
- if ((byte & 0xC0 ) == 0 ) {
526
- byte <<= 2 ;
525
+ if ((value & 0xC0 ) == 0 ) {
526
+ value <<= 2 ;
527
527
cnt += 2 ;
528
528
}
529
- if ((byte & 0x80 ) == 0 ) {
529
+ if ((value & 0x80 ) == 0 ) {
530
530
cnt += 1 ;
531
531
}
532
532
0 commit comments