source: branches/libc-0.6/src/binutils/libiberty/ffs.c

Last change on this file was 607, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 473 bytes
Line 
1/* ffs -- Find the first bit set in the parameter
2
3@deftypefn Supplemental int ffs (int @var{valu})
4
5Find the first (least significant) bit set in @var{valu}. Bits are
6numbered from right to left, starting with bit 1 (corresponding to the
7value 1). If @var{valu} is zero, zero is returned.
8
9@end deftypefn
10
11*/
12
13int
14ffs (valu)
15 register int valu;
16{
17 register int bit;
18
19 if (valu == 0)
20 return 0;
21
22 for (bit = 1; !(valu & 1); bit++)
23 valu >>= 1;
24
25 return bit;
26}
27
Note: See TracBrowser for help on using the repository browser.