diff --git a/arch/arm/core/cortex_m/scb.c b/arch/arm/core/cortex_m/scb.c index 8deb9f3792..04c71e268d 100644 --- a/arch/arm/core/cortex_m/scb.c +++ b/arch/arm/core/cortex_m/scb.c @@ -86,7 +86,7 @@ void _ScbNumPriGroupSet(unsigned int n /* number of priorities */ __ASSERT(_IsPowerOfTwo(n) && (n <= 128), "invalid number of priorities"); - set = find_first_set(n); + set = find_lsb_set(n); reg.val = __scs.scb.aircr.val; diff --git a/arch/x86/core/intconnect.c b/arch/x86/core/intconnect.c index e192347a9a..4bb056e67b 100644 --- a/arch/x86/core/intconnect.c +++ b/arch/x86/core/intconnect.c @@ -538,11 +538,11 @@ int _IntVecAlloc(unsigned int priority) * The interrupt_vectors_allocated[] entry specified by 'entryToScan' is a 32-bit * quantity and thus represents the vectors for a pair of priority *levels. - * Use find_last_set() to scan for the upper of the 2, and find_first_set() to + * Use find_msb_set() to scan for the upper of the 2, and find_lsb_set() to *scan * for the lower of the 2 priorities. * - * Note that find_first_set/find_last_set returns bit position from 1 to 32, + * Note that find_lsb_set/find_msb_set returns bit position from 1 to 32, * or 0 if the argument is zero. */ @@ -551,7 +551,7 @@ int _IntVecAlloc(unsigned int priority) if ((priority % 2) == 0) { /* scan from the LSB for even priorities */ - fsb = find_first_set(interrupt_vectors_allocated[entryToScan]); + fsb = find_lsb_set(interrupt_vectors_allocated[entryToScan]); #if defined(DEBUG) if ((fsb == 0) || (fsb > 16)) { @@ -568,7 +568,7 @@ int _IntVecAlloc(unsigned int priority) } else { /* scan from the MSB for odd priorities */ - fsb = find_last_set(interrupt_vectors_allocated[entryToScan]); + fsb = find_msb_set(interrupt_vectors_allocated[entryToScan]); #if defined(DEBUG) if ((fsb == 0) || (fsb < 17)) { diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 07fd2c21ae..48113f11c9 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -257,7 +257,7 @@ static inline int pci_bar_params_get(union pci_addr_reg pci_ctrl_addr, addr = bar_config & mask; if (addr != 0) { /* calculate the size of the BAR memory required */ - dev_info->size = 1 << (find_first_set(addr) - 1); + dev_info->size = 1 << (find_lsb_set(addr) - 1); } return 0; diff --git a/include/arch/arc/v2/ffs.h b/include/arch/arc/v2/ffs.h index 0273459d86..265f08a5fa 100644 --- a/include/arch/arc/v2/ffs.h +++ b/include/arch/arc/v2/ffs.h @@ -42,18 +42,18 @@ ARC-specific nanokernel ffs interface. Included by ARC/arch.h. /** * - * @brief Find First Set bit (searching from most significant bit) + * @brief find most significant bit set in a 32-bit word * - * This routine finds the last bit set in the argument passed it and returns - * the index of that bit. Bits are numbered starting at 1 from the least - * significant bit. A return value of zero indicates that the value passed - * is zero. + * This routine finds the first bit set starting from the most significant bit + * in the argument passed in and returns the index of that bit. Bits are + * numbered starting at 1 from the least significant bit. A return value of + * zero indicates that the value passed is zero. * - * @return most significant bit set + * @return most significant bit set, 0 if @a op is 0 */ #if defined(__GNUC__) -static ALWAYS_INLINE unsigned int find_last_set(unsigned int op) +static ALWAYS_INLINE unsigned int find_msb_set(unsigned int op) { unsigned int bit; @@ -71,18 +71,18 @@ static ALWAYS_INLINE unsigned int find_last_set(unsigned int op) /** * - * @brief Find first set bit (searching from the least significant bit) + * @brief find least significant bit set in a 32-bit word * - * This routine finds the first bit set in the argument passed it and - * returns the index of that bit. Bits are numbered starting - * at 1 from the least significant bit. A return value of zero indicates that - * the value passed is zero. + * This routine finds the first bit set starting from the least significant bit + * in the argument passed in and returns the index of that bit. Bits are + * numbered starting at 1 from the least significant bit. A return value of + * zero indicates that the value passed is zero. * - * @return least significant bit set + * @return least significant bit set, 0 if @a op is 0 */ #if defined(__GNUC__) -static ALWAYS_INLINE unsigned int find_first_set(unsigned int op) +static ALWAYS_INLINE unsigned int find_lsb_set(unsigned int op) { unsigned int bit; diff --git a/include/arch/arm/CortexM/asm_inline_gcc.h b/include/arch/arm/CortexM/asm_inline_gcc.h index e9184910cb..7b59a6347f 100644 --- a/include/arch/arm/CortexM/asm_inline_gcc.h +++ b/include/arch/arm/CortexM/asm_inline_gcc.h @@ -54,17 +54,17 @@ /** * - * @brief Find first set bit (searching from most significant bit) + * @brief find most significant bit set in a 32-bit word * - * This routine finds the last bit set in the argument passed it and returns - * the index of that bit. Bits are numbered starting at 1 from the least - * significant bit. A return value of zero indicates that the value passed - * is zero. + * This routine finds the first bit set starting from the most significant bit + * in the argument passed in and returns the index of that bit. Bits are + * numbered starting at 1 from the least significant bit. A return value of + * zero indicates that the value passed is zero. * - * @return most significant bit set + * @return most significant bit set, 0 if @a op is 0 */ -static ALWAYS_INLINE unsigned int find_last_set(unsigned int op) +static ALWAYS_INLINE unsigned int find_msb_set(unsigned int op) { unsigned int bit; @@ -82,17 +82,17 @@ static ALWAYS_INLINE unsigned int find_last_set(unsigned int op) /** * - * @brief Find first set bit (from the least significant bit) + * @brief find least significant bit set in a 32-bit word * - * This routine finds the first bit set in the argument passed it and - * returns the index of that bit. Bits are numbered starting - * at 1 from the least significant bit. A return value of zero indicates that - * the value passed is zero. + * This routine finds the first bit set starting from the least significant bit + * in the argument passed in and returns the index of that bit. Bits are + * numbered starting at 1 from the least significant bit. A return value of + * zero indicates that the value passed is zero. * - * @return least significant bit set + * @return least significant bit set, 0 if @a op is 0 */ -static ALWAYS_INLINE unsigned int find_first_set(unsigned int op) +static ALWAYS_INLINE unsigned int find_lsb_set(unsigned int op) { unsigned int bit; diff --git a/include/arch/x86/asm_inline_gcc.h b/include/arch/x86/asm_inline_gcc.h index a2541b0832..5b92ae63fc 100644 --- a/include/arch/x86/asm_inline_gcc.h +++ b/include/arch/x86/asm_inline_gcc.h @@ -97,24 +97,24 @@ static inline __attribute__((always_inline)) void _do_irq_unlock(void) /** * - * @brief Find first set bit searching from the LSB (inline) + * @brief find least significant bit set in a 32-bit word * - * This routine finds the first bit set in the argument passed it and - * returns the index of that bit. Bits are numbered starting - * at 1 from the least significant bit to 32 for the most significant bit. - * A return value of zero indicates that the value passed is zero. + * This routine finds the first bit set starting from the least significant bit + * in the argument passed in and returns the index of that bit. Bits are + * numbered starting at 1 from the least significant bit. A return value of + * zero indicates that the value passed is zero. * - * @return bit position from 1 to 32, or 0 if the argument is zero. + * @return least significant bit set, 0 if @a op is 0 * - * INTERNAL - * For Intel64 (x86_64) architectures, the 'cmovzl' can be removed - * and leverage the fact that the 'bsfl' doesn't modify the destination operand - * when the source operand is zero. The "bitpos" variable can be preloaded - * into the destination register, and given the unconditional ++bitpos that - * is performed after the 'cmovzl', the correct results are yielded. + * @internal + * For Intel64 (x86_64) architectures, the 'cmovzl' can be removed and leverage + * the fact that the 'bsfl' doesn't modify the destination operand when the + * source operand is zero. The "bitpos" variable can be preloaded into the + * destination register, and given the unconditional ++bitpos that is performed + * after the 'cmovzl', the correct results are yielded. */ -static ALWAYS_INLINE unsigned int find_first_set(unsigned int op) +static ALWAYS_INLINE unsigned int find_lsb_set(unsigned int op) { int bitpos; @@ -147,24 +147,24 @@ static ALWAYS_INLINE unsigned int find_first_set(unsigned int op) /** * - * @brief Find first set bit searching from the MSB (inline) + * @brief find most significant bit set in a 32-bit word * - * This routine finds the first bit set in the argument passed it and - * returns the index of that bit. Bits are numbered starting - * at 1 from the least significant bit to 32 for the most significant bit. - * A return value of zero indicates that the value passed is zero. + * This routine finds the first bit set starting from the most significant bit + * in the argument passed in and returns the index of that bit. Bits are + * numbered starting at 1 from the least significant bit. A return value of + * zero indicates that the value passed is zero. * - * @return bit position from 1 to 32, or 0 if the argument is zero. + * @return most significant bit set, 0 if @a op is 0 * - * INTERNAL - * For Intel64 (x86_64) architectures, the 'cmovzl' can be removed - * and leverage the fact that the 'bsfl' doesn't modify the destination operand - * when the source operand is zero. The "bitpos" variable can be preloaded - * into the destination register, and given the unconditional ++bitpos that - * is performed after the 'cmovzl', the correct results are yielded. + * @internal + * For Intel64 (x86_64) architectures, the 'cmovzl' can be removed and leverage + * the fact that the 'bsfl' doesn't modify the destination operand when the + * source operand is zero. The "bitpos" variable can be preloaded into the + * destination register, and given the unconditional ++bitpos that is performed + * after the 'cmovzl', the correct results are yielded. */ -static ALWAYS_INLINE unsigned int find_last_set(unsigned int op) +static ALWAYS_INLINE unsigned int find_msb_set(unsigned int op) { int bitpos; diff --git a/kernel/microkernel/k_server.c b/kernel/microkernel/k_server.c index d7e71d90ad..b0da40cd0e 100644 --- a/kernel/microkernel/k_server.c +++ b/kernel/microkernel/k_server.c @@ -66,14 +66,14 @@ static struct k_proc *next_task_select(void) int K_PrioListIdx; #if (CONFIG_NUM_TASK_PRIORITIES <= 32) - K_PrioListIdx = find_first_set(_k_task_priority_bitmap[0]) - 1; + K_PrioListIdx = find_lsb_set(_k_task_priority_bitmap[0]) - 1; #else int bit_map; int set_bit_pos; K_PrioListIdx = -1; for (bit_map = 0; ; bit_map++) { - set_bit_pos = find_first_set(_k_task_priority_bitmap[bit_map]); + set_bit_pos = find_lsb_set(_k_task_priority_bitmap[bit_map]); if (set_bit_pos) { K_PrioListIdx += set_bit_pos; break;