summaryrefslogtreecommitdiffstats
path: root/sys/i386/include/cpufunc.h
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1996-08-01 20:29:28 +0000
committerwollman <wollman@FreeBSD.org>1996-08-01 20:29:28 +0000
commit6480d29561746e2826a73d11bb0b3ccf2c13e944 (patch)
tree877cb85154b2bd7ccd90da0b990be7daee82bc16 /sys/i386/include/cpufunc.h
parent253c83930ab918d503074a3fe89c0152dd34cede (diff)
downloadFreeBSD-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/include/cpufunc.h')
-rw-r--r--sys/i386/include/cpufunc.h13
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)
OpenPOWER on IntegriCloud