summaryrefslogtreecommitdiffstats
path: root/newlib/libc/misc/ffs.c
blob: ba57009207f3738ab5aa687f6bc378c5e1f43085 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
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
ffs(int i)
{

	return (__builtin_ffs(i));
}