mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-28 10:00:23 +08:00
f3e873f250
* libc/string/index.c: Include <strings.h> for "index". * libc/string/rindex.c: Include <strings.h> for "rindex". * libc/string/strcasecmp.c: Include <strings.h> for "strcasecmp". Don't include <string.h>. * libc/string/strncasecmp.c: Include <strings.h> for "strncasecmp". Don't include <string.h>. * libc/string/bzero.c: Include <strings.h> for "bzero". Don't include <string.h> * libc/misc/ffs.c: Include <strings.h> for "ffs". Don't include <_ansi.h>.
45 lines
563 B
C
45 lines
563 B
C
/*
|
|
FUNCTION
|
|
<<ffs>>---find first bit set in a word
|
|
|
|
INDEX
|
|
ffs
|
|
|
|
ANSI_SYNOPSIS
|
|
int ffs(int <[word]>);
|
|
|
|
TRAD_SYNOPSIS
|
|
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;
|
|
}
|
|
}
|