OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [misc/] [ffs.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/*
2
FUNCTION
3
        <<ffs>>---find first bit set in a word
4
 
5
INDEX
6
        ffs
7
 
8
ANSI_SYNOPSIS
9
        int ffs(int <[word]>);
10
 
11
TRAD_SYNOPSIS
12
        int ffs(<[word]>);
13
 
14
DESCRIPTION
15
 
16
<<ffs>> returns the first bit set in a word.
17
 
18
RETURNS
19
<<ffs>> returns 0 if <[c]> is 0, 1 if <[c]> is odd, 2 if <[c]> is a multiple of
20
2, etc.
21
 
22
PORTABILITY
23
<<ffs>> is not ANSI C.
24
 
25
No supporting OS subroutines are required.  */
26
 
27
int
28
ffs (word)
29
     int word;
30
{
31
  int i;
32
 
33
  if (!word)
34
    return 0;
35
 
36
  i = 0;
37
  for (;;)
38
    {
39
      if (((1 << i++) & word) != 0)
40
        return i;
41
    }
42
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.