4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-15 02:09:19 +08:00
Ralf Corsepius da344d0ea9 2011-08-23 Ralf Corsépius <ralf.corsepius@rtems.org>
* libc/misc/ffs.c, libc/string/bcmp.c, libc/string/bcopy.c,
	libc/string/bzero.c, libc/string/index.c, libc/string/rindex.c,
	libc/string/strcasecmp.c, libc/string/strncasecmp.c:
	Let synopsis reference "#include <strings.h>".
2011-08-23 12:01:51 +00:00

47 lines
607 B
C

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