Skip to content

Commit 0ca91df

Browse files
author
Arto Kinnunen
committed
Squashed 'features/frameworks/nanostack-libservice/' changes from 5eb2f3f..bb56e37
bb56e37 Merge pull request #76 from ARMmbed/compiler_warning_fixes a7b0de2 common_functions: remove use of "byte" as variable name fb84db0 ns_types.h: fix the GCC warning with "-Wundef" and missing __STDC_VER git-subtree-dir: features/frameworks/nanostack-libservice git-subtree-split: bb56e375bab77aa49dbddd4abb53b6832043aa99
1 parent 7d2f0ca commit 0ca91df

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

mbed-client-libservice/common_functions.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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

mbed-client-libservice/ns_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ typedef int_fast32_t int_fast24_t;
120120
#if defined __CC_ARM || defined __TASKING__
121121
#define alignas(n) __align(n)
122122
#define __alignas_is_defined 1
123-
#elif (__STDC_VERSION__ >= 201112L) || (defined __cplusplus && __cplusplus >= 201103L)
123+
#elif (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) || (defined __cplusplus && __cplusplus >= 201103L)
124124
#include <stdalign.h>
125125
#elif defined __GNUC__
126126
#define alignas(n) __attribute__((__aligned__(n)))

0 commit comments

Comments
 (0)