mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-21 08:03:41 +08:00
29650b2b2f
* Makefile.in: Add ffs.c dependency. * configure.in: Add ffs.c. * ffs.c: New file. From-SVN: r43784
30 lines
414 B
C
30 lines
414 B
C
/* ffs -- Find the first bit set in the parameter
|
|
|
|
NAME
|
|
ffs -- Find the first bit set in the parameter
|
|
|
|
SYNOPSIS
|
|
int ffs (int valu)
|
|
|
|
DESCRIPTION
|
|
Find the first bit set in the parameter. Bits are numbered from
|
|
right to left, starting with bit 1.
|
|
|
|
*/
|
|
|
|
int
|
|
ffs (valu)
|
|
register int valu;
|
|
{
|
|
register int bit;
|
|
|
|
if (valu == 0)
|
|
return 0;
|
|
|
|
for (bit = 1; !(valu & 1); bit++)
|
|
valu >>= 1;
|
|
|
|
return bit;
|
|
}
|
|
|