home *** CD-ROM | disk | FTP | other *** search
- /***********************************************************************
- Copyright 1991 by Apple Computer, Inc, Cupertino, California
- All Rights Reserved
-
- Permission to use, copy, modify, and distribute this software
- for any purpose and without fee is hereby granted, provided
- that the above copyright notice appear in all copies.
-
- APPLE MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS,
- OR IMPLIED, WITH RESPECT TO THIS SOFTWARE, ITS QUALITY,
- PERFORMANCE, MERCHANABILITY, OR FITNESS FOR A PARTICULAR
- PURPOSE. AS A RESULT, THIS SOFTWARE IS PROVIDED "AS IS,"
- AND YOU THE USER ARE ASSUMING THE ENTIRE RISK AS TO ITS
- QUALITY AND PERFORMANCE. IN NO EVENT WILL APPLE BE LIABLE
- FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
- DAMAGES RESULTING FROM ANY DEFECT IN THE SOFTWARE.
-
- THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE
- AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR
- IMPLIED.
-
- ***********************************************************************/
-
- /* Find the first set bit
- * i.e. least signifigant 1 bit:
- * 0 => 0
- * 1 => 1
- * 2 => 2
- * 3 => 1
- * 4 => 3
- */
-
- int
- ffs(mask)
- unsigned int mask;
- {
- register i;
-
- if ( ! mask ) return 0;
- i = 1;
- while (! (mask & 1)) {
- i++;
- mask = mask >> 1;
- }
- return i;
- }
-