xref: /csrg-svn/lib/libc/string/ffs.c (revision 61193)
141946Sbostic /*-
2*61193Sbostic  * Copyright (c) 1990, 1993
3*61193Sbostic  *	The Regents of the University of California.  All rights reserved.
434828Sbostic  *
541946Sbostic  * %sccs.include.redist.c%
630423Smckusick  */
730423Smckusick 
830423Smckusick #if defined(LIBC_SCCS) && !defined(lint)
9*61193Sbostic static char sccsid[] = "@(#)ffs.c	8.1 (Berkeley) 06/04/93";
1034828Sbostic #endif /* LIBC_SCCS and not lint */
1130423Smckusick 
1242181Sbostic #include <string.h>
1342181Sbostic 
1430423Smckusick /*
1530423Smckusick  * ffs -- vax ffs instruction
1630423Smckusick  */
1756416Sbostic int
ffs(mask)1830423Smckusick ffs(mask)
1941946Sbostic 	register int mask;
2030423Smckusick {
2141946Sbostic 	register int bit;
2230423Smckusick 
2330423Smckusick 	if (mask == 0)
2430423Smckusick 		return(0);
2541946Sbostic 	for (bit = 1; !(mask & 1); bit++)
2630423Smckusick 		mask >>= 1;
2741946Sbostic 	return(bit);
2830423Smckusick }
29