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