xref: /csrg-svn/lib/libc/string/ffs.c (revision 30423)
1*30423Smckusick /*
2*30423Smckusick  * Copyright (c) 1987 Regents of the University of California.
3*30423Smckusick  * All rights reserved.  The Berkeley software License Agreement
4*30423Smckusick  * specifies the terms and conditions for redistribution.
5*30423Smckusick  */
6*30423Smckusick 
7*30423Smckusick #if defined(LIBC_SCCS) && !defined(lint)
8*30423Smckusick static char sccsid[] = "@(#)ffs.c	5.1 (Berkeley) 01/27/87";
9*30423Smckusick #endif LIBC_SCCS and not lint
10*30423Smckusick 
11*30423Smckusick /*
12*30423Smckusick  * ffs -- vax ffs instruction
13*30423Smckusick  */
14*30423Smckusick ffs(mask)
15*30423Smckusick 	register long mask;
16*30423Smckusick {
17*30423Smckusick 	register int cnt;
18*30423Smckusick 
19*30423Smckusick 	if (mask == 0)
20*30423Smckusick 		return(0);
21*30423Smckusick 	for (cnt = 1; !(mask & 1); cnt++)
22*30423Smckusick 		mask >>= 1;
23*30423Smckusick 	return(cnt);
24*30423Smckusick }
25