re PR c++/52269 ([C++11] Body of constexpr function templates instantiated too eagerl...
[official-gcc.git] / libiberty / ffs.c
blob603cbe8ed994536776e2031b7afa6ca521e54ecc
1 /* ffs -- Find the first bit set in the parameter
3 @deftypefn Supplemental int ffs (int @var{valu})
5 Find the first (least significant) bit set in @var{valu}. Bits are
6 numbered from right to left, starting with bit 1 (corresponding to the
7 value 1). If @var{valu} is zero, zero is returned.
9 @end deftypefn
13 int
14 ffs (register int valu)
16 register int bit;
18 if (valu == 0)
19 return 0;
21 for (bit = 1; !(valu & 1); bit++)
22 valu >>= 1;
24 return bit;