summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/ffsl.c
blob: 182318c3d65074af1a9a1697716c2f1305251df0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*	$OpenBSD: ffsl.c,v 1.1 2025/10/24 11:30:06 claudio Exp $	*/

/*
 * Public domain.
 * Written by Claudio Jeker.
 */

#include <strings.h>

/*
 * ffs -- find the first (least significant) bit set
 */
int
ffsl(long mask)
{
	return (mask ? __builtin_ctzl(mask) + 1 : 0);
}