ffs: rename find_[first|last]_set to find_[lsb|msb]_set

The new names reflect better what the functions do: they find the first
bit set starting from the least or most significant bit, i.e. they find
the least or most significant bit set, in a 32-bit word.

Change-Id: I6f0ee4b543f6f37c2f08f7067e14e039c92a6f6a
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
Benjamin Walsh 2015-08-14 17:16:16 -04:00 committed by Anas Nashif
parent 910970ed0f
commit 1bab46dca1
7 changed files with 62 additions and 62 deletions

View file

@ -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;

View file

@ -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)) {

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;