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

Subversion Repositories or1k

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
/*
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.