xref: /csrg-svn/lib/libc/string/ffs.c (revision 42181)
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*42181Sbostic static char sccsid[] = "@(#)ffs.c	5.4 (Berkeley) 05/17/90";
1034828Sbostic #endif /* LIBC_SCCS and not lint */
1130423Smckusick 
12*42181Sbostic #include <string.h>
13*42181Sbostic 
1430423Smckusick /*
1530423Smckusick  * ffs -- vax ffs instruction
1630423Smckusick  */
1730423Smckusick ffs(mask)
1841946Sbostic 	register int mask;
1930423Smckusick {
2041946Sbostic 	register int bit;
2130423Smckusick 
2230423Smckusick 	if (mask == 0)
2330423Smckusick 		return(0);
2441946Sbostic 	for (bit = 1; !(mask & 1); bit++)
2530423Smckusick 		mask >>= 1;
2641946Sbostic 	return(bit);
2730423Smckusick }
28