]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/ffs.c
[libiberty] Use pipe inside pex_run
[thirdparty/gcc.git] / libiberty / ffs.c
CommitLineData
8568af22 1/* ffs -- Find the first bit set in the parameter
2
349e8276 3@deftypefn Supplemental int ffs (int @var{valu})
8568af22 4
f0ed5ac1 5Find the first (least significant) bit set in @var{valu}. Bits are
349e8276 6numbered from right to left, starting with bit 1 (corresponding to the
7value 1). If @var{valu} is zero, zero is returned.
8568af22 8
349e8276 9@end deftypefn
8568af22 10
11*/
12
13int
8858115e 14ffs (register int valu)
8568af22 15{
16 register int bit;
17
18 if (valu == 0)
19 return 0;
20
21 for (bit = 1; !(valu & 1); bit++)
22 valu >>= 1;
23
24 return bit;
25}
26