xref: /csrg-svn/lib/libc/string/ffs.c (revision 56416)
141946Sbostic /*-
241946Sbostic  * Copyright (c) 1990 The Regents of the University of California.
334828Sbostic  * All rights reserved.
434828Sbostic  *
541946Sbostic  * %sccs.include.redist.c%
630423Smckusick  */
730423Smckusick 
830423Smckusick #if defined(LIBC_SCCS) && !defined(lint)
9*56416Sbostic static char sccsid[] = "@(#)ffs.c	5.5 (Berkeley) 10/04/92";
1034828Sbostic #endif /* LIBC_SCCS and not lint */
1130423Smckusick 
1242181Sbostic #include <string.h>
1342181Sbostic 
1430423Smckusick /*
1530423Smckusick  * ffs -- vax ffs instruction
1630423Smckusick  */
17*56416Sbostic int
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