summaryrefslogtreecommitdiff
path: root/lib/libc/strings/ffsl.c
blob: c84a2905f4ce7da1c38ddb52a349879e14fc7345 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
int ffsl(long i)
{
	int pos;
	unsigned long u;

	if (i == 0) {
		return 0;
	}

	pos = 1;
	u = (unsigned long)i;
	while ((u & 1UL) == 0UL) {
		u >>= 1;
		pos++;
	}

	return pos;
}