diff options
author | wollman <wollman@FreeBSD.org> | 1996-08-01 20:29:28 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1996-08-01 20:29:28 +0000 |
commit | 6480d29561746e2826a73d11bb0b3ccf2c13e944 (patch) | |
tree | 877cb85154b2bd7ccd90da0b990be7daee82bc16 /sys/i386 | |
parent | 253c83930ab918d503074a3fe89c0152dd34cede (diff) | |
download | FreeBSD-src-6480d29561746e2826a73d11bb0b3ccf2c13e944.zip FreeBSD-src-6480d29561746e2826a73d11bb0b3ccf2c13e944.tar.gz |
Add an fls() inline function which does the opposite operation to
ffs(). (That is to say, it searches in the opposite direction.)
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/include/cpufunc.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h index e49066a..0f54b11 100644 --- a/sys/i386/include/cpufunc.h +++ b/sys/i386/include/cpufunc.h @@ -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) |