GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > LDT / V0-3-2
Constituent: encdec     Tag: mv2304
This graph shows which files directly or indirectly include this file:
Functions | |
static __inline int | FFS (unsigned int word) |
Finds the first set bit (MSB = bit 0) in a 32-bit word. | |
static __inline unsigned int | FFS_eliminate (unsigned int word, int bit) |
Eliminates the specified bit, bit from word. | |
static __inline unsigned int | FFS_mask (int bit) |
Converts the bit to a bit mask. |
CVS $Id
ABSTRACT
--------
This facility provides the interface and implementation of the Find First Set routines. These routines provide a machine independent interface to a machine dependent implementation to find the first set bit in a 32 bit word. On most machines, this consists of a single machine instruction
USAGE
-----
Two routines are provided, FFS() and FFS_eliminate(). These routines find and then eliminate the first set bit in a 32 bit word.
Example
-------
As example, consider counting the number of set bits in a 32-bit word.
int count_bits (unsigned int word) { int cnt = 0; while (word) { int bit; bit = FFS (word); cnt += 1; word = FFS_eliminate (word, bit); } return cnt; }
|
Finds the first set bit (MSB = bit 0) in a 32-bit word.
On the PowerPCs, this is a direct map to the PPC instruction 'cntlz', count leading zeros. The Intel implementation is an 'bsr' instruction with the bit numbers reversed to match a big endian machine. The non PPC604 implementation is a straighforward piece of C code. |
|
Eliminates the specified bit, bit from word.
|
|
Converts the bit to a bit mask.
|