xref: /original-bsd/lib/libc/string/ffs.c (revision a043e977)
1 /*-
2  * Copyright (c) 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)ffs.c	5.5 (Berkeley) 10/04/92";
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