~pac72/ubuntu/lucid/ddd/devel

« back to all changes in this revision

Viewing changes to libiberty/ffs.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Schepler
  • Date: 2004-07-22 03:49:37 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040722034937-cysl08t1jvba4jrx
Tags: 1:3.3.9-3
USERINFO has been renamed to USERINFO.txt; adjust debian/rules code
to match, to get correct information on the About DDD dialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ffs -- Find the first bit set in the parameter
 
2
 
 
3
@deftypefn Supplemental int ffs (int @var{valu})
 
4
 
 
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.
 
8
 
 
9
@end deftypefn
 
10
 
 
11
*/
 
12
 
 
13
int
 
14
ffs (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