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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [misc/] [ffs.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
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
#include <_ansi.h>
28
 
29
int
30
_DEFUN(ffs, (word),
31
       int word)
32
{
33
  int i;
34
 
35
  if (!word)
36
    return 0;
37
 
38
  i = 0;
39
  for (;;)
40
    {
41
      if (((1 << i++) & word) != 0)
42
        return i;
43
    }
44
}

powered by: WebSVN 2.1.0

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