xref: /original-bsd/lib/libc/string/ffs.c (revision e59fb703)
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.4 (Berkeley) 05/17/90";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <string.h>
13 
14 /*
15  * ffs -- vax ffs instruction
16  */
17 ffs(mask)
18 	register int mask;
19 {
20 	register int bit;
21 
22 	if (mask == 0)
23 		return(0);
24 	for (bit = 1; !(mask & 1); bit++)
25 		mask >>= 1;
26 	return(bit);
27 }
28