xref: /csrg-svn/lib/libc/string/ffs.c (revision 41946)
1*41946Sbostic /*-
2*41946Sbostic  * Copyright (c) 1990 The Regents of the University of California.
334828Sbostic  * All rights reserved.
434828Sbostic  *
5*41946Sbostic  * %sccs.include.redist.c%
630423Smckusick  */
730423Smckusick 
830423Smckusick #if defined(LIBC_SCCS) && !defined(lint)
9*41946Sbostic static char sccsid[] = "@(#)ffs.c	5.3 (Berkeley) 05/15/90";
1034828Sbostic #endif /* LIBC_SCCS and not lint */
1130423Smckusick 
1230423Smckusick /*
1330423Smckusick  * ffs -- vax ffs instruction
1430423Smckusick  */
1530423Smckusick ffs(mask)
16*41946Sbostic 	register int mask;
1730423Smckusick {
18*41946Sbostic 	register int bit;
1930423Smckusick 
2030423Smckusick 	if (mask == 0)
2130423Smckusick 		return(0);
22*41946Sbostic 	for (bit = 1; !(mask & 1); bit++)
2330423Smckusick 		mask >>= 1;
24*41946Sbostic 	return(bit);
2530423Smckusick }
26