1169695Skan/* ffs -- Find the first bit set in the parameter 2169695Skan 3169695Skan@deftypefn Supplemental int ffs (int @var{valu}) 4169695Skan 5169695SkanFind the first (least significant) bit set in @var{valu}. Bits are 6169695Skannumbered from right to left, starting with bit 1 (corresponding to the 7169695Skanvalue 1). If @var{valu} is zero, zero is returned. 8169695Skan 9169695Skan@end deftypefn 10169695Skan 11169695Skan*/ 12169695Skan 13169695Skanint 14169695Skanffs (register int valu) 15169695Skan{ 16169695Skan register int bit; 17169695Skan 18169695Skan if (valu == 0) 19169695Skan return 0; 20169695Skan 21169695Skan for (bit = 1; !(valu & 1); bit++) 22169695Skan valu >>= 1; 23169695Skan 24169695Skan return bit; 25169695Skan} 26169695Skan 27