130423Smckusick /* 230423Smckusick * Copyright (c) 1987 Regents of the University of California. 3*34828Sbostic * All rights reserved. 4*34828Sbostic * 5*34828Sbostic * Redistribution and use in source and binary forms are permitted 6*34828Sbostic * provided that the above copyright notice and this paragraph are 7*34828Sbostic * duplicated in all such forms and that any documentation, 8*34828Sbostic * advertising materials, and other materials related to such 9*34828Sbostic * distribution and use acknowledge that the software was developed 10*34828Sbostic * by the University of California, Berkeley. The name of the 11*34828Sbostic * University may not be used to endorse or promote products derived 12*34828Sbostic * from this software without specific prior written permission. 13*34828Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14*34828Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15*34828Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1630423Smckusick */ 1730423Smckusick 1830423Smckusick #if defined(LIBC_SCCS) && !defined(lint) 19*34828Sbostic static char sccsid[] = "@(#)ffs.c 5.2 (Berkeley) 06/27/88"; 20*34828Sbostic #endif /* LIBC_SCCS and not lint */ 2130423Smckusick 2230423Smckusick /* 2330423Smckusick * ffs -- vax ffs instruction 2430423Smckusick */ 2530423Smckusick ffs(mask) 2630423Smckusick register long mask; 2730423Smckusick { 2830423Smckusick register int cnt; 2930423Smckusick 3030423Smckusick if (mask == 0) 3130423Smckusick return(0); 3230423Smckusick for (cnt = 1; !(mask & 1); cnt++) 3330423Smckusick mask >>= 1; 3430423Smckusick return(cnt); 3530423Smckusick } 36