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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [misc/] [ffs.c] - Diff between revs 1010 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 1010 Rev 1765
/*
/*
FUNCTION
FUNCTION
        <<ffs>>---find first bit set in a word
        <<ffs>>---find first bit set in a word
 
 
INDEX
INDEX
        ffs
        ffs
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        int ffs(int <[word]>);
        int ffs(int <[word]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        int ffs(<[word]>);
        int ffs(<[word]>);
 
 
DESCRIPTION
DESCRIPTION
 
 
<<ffs>> returns the first bit set in a word.
<<ffs>> returns the first bit set in a word.
 
 
RETURNS
RETURNS
<<ffs>> returns 0 if <[c]> is 0, 1 if <[c]> is odd, 2 if <[c]> is a multiple of
<<ffs>> returns 0 if <[c]> is 0, 1 if <[c]> is odd, 2 if <[c]> is a multiple of
2, etc.
2, etc.
 
 
PORTABILITY
PORTABILITY
<<ffs>> is not ANSI C.
<<ffs>> is not ANSI C.
 
 
No supporting OS subroutines are required.  */
No supporting OS subroutines are required.  */
 
 
int
int
ffs (word)
ffs (word)
     int word;
     int word;
{
{
  int i;
  int i;
 
 
  if (!word)
  if (!word)
    return 0;
    return 0;
 
 
  i = 0;
  i = 0;
  for (;;)
  for (;;)
    {
    {
      if (((1 << i++) & word) != 0)
      if (((1 << i++) & word) != 0)
        return i;
        return i;
    }
    }
}
}
 
 

powered by: WebSVN 2.1.0

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