Retro68/gcc/newlib/libc/misc/ffs.c

33 lines
431 B
C
Raw Normal View History

2017-04-11 21:13:36 +00:00
/*
FUNCTION
<<ffs>>---find first bit set in a word
INDEX
ffs
2018-12-28 15:30:48 +00:00
SYNOPSIS
2017-04-11 21:13:36 +00:00
#include <strings.h>
int ffs(int <[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
2018-12-28 15:30:48 +00:00
ffs(int i)
2017-04-11 21:13:36 +00:00
{
2018-12-28 15:30:48 +00:00
return (__builtin_ffs(i));
2017-04-11 21:13:36 +00:00
}