xref: /original-bsd/lib/libc/string/ffs.c (revision c3e32dec)
1 /*-
2  * Copyright (c) 1990, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)ffs.c	8.1 (Berkeley) 06/04/93";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <string.h>
13 
14 /*
15  * ffs -- vax ffs instruction
16  */
17 int
18 ffs(mask)
19 	register int mask;
20 {
21 	register int bit;
22 
23 	if (mask == 0)
24 		return(0);
25 	for (bit = 1; !(mask & 1); bit++)
26 		mask >>= 1;
27 	return(bit);
28 }
29