OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [misc/] [ffs.c] - Diff between revs 207 and 345

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
/*
/*
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.  */
 
 
#include <_ansi.h>
#include <_ansi.h>
 
 
int
int
_DEFUN(ffs, (word),
_DEFUN(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.