1 #include <isl_config.h>
3 #if !HAVE_DECL_FFS && !HAVE_DECL___BUILTIN_FFS && HAVE_DECL__BITSCANFORWARD
6 /* Implementation of ffs in terms of _BitScanForward.
8 * ffs returns the position of the least significant bit set in i,
9 * with the least significant bit is position 1, or 0 if not bits are set.
11 * _BitScanForward returns 1 if mask is non-zero and sets index
12 * to the position of the least significant bit set in i,
13 * with the least significant bit is position 0.
17 unsigned char non_zero
;
18 unsigned long index
, mask
= i
;
20 non_zero
= _BitScanForward(&index
, mask
);
22 return non_zero
? 1 + index
: 0;