Add an fls() inline function which does the opposite operation to

ffs().  (That is to say, it searches in the opposite direction.)
This commit is contained in:
Garrett Wollman 1996-08-01 20:29:28 +00:00
parent a076b72573
commit 13f588f83e
2 changed files with 24 additions and 2 deletions

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: cpufunc.h,v 1.52 1996/07/01 20:16:09 bde Exp $
* $Id: cpufunc.h,v 1.53 1996/07/23 07:45:19 asami Exp $
*/
/*
@ -84,6 +84,17 @@ ffs(int mask)
return (result);
}
#define HAVE_INLINE_FLS
static __inline int
fls(int mask)
{
int result;
__asm __volatile("testl %0,%0; je 1f; bsrl %0,%0; incl %0; 1:"
: "=r" (result) : "0" (mask));
return (result);
}
#if __GNUC__ < 2
#define inb(port) inbv(port)

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: cpufunc.h,v 1.52 1996/07/01 20:16:09 bde Exp $
* $Id: cpufunc.h,v 1.53 1996/07/23 07:45:19 asami Exp $
*/
/*
@ -84,6 +84,17 @@ ffs(int mask)
return (result);
}
#define HAVE_INLINE_FLS
static __inline int
fls(int mask)
{
int result;
__asm __volatile("testl %0,%0; je 1f; bsrl %0,%0; incl %0; 1:"
: "=r" (result) : "0" (mask));
return (result);
}
#if __GNUC__ < 2
#define inb(port) inbv(port)