summaryrefslogtreecommitdiff
path: root/usr/src/uts/intel/asm/bitmap.h
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/intel/asm/bitmap.h')
-rw-r--r--usr/src/uts/intel/asm/bitmap.h70
1 files changed, 26 insertions, 44 deletions
diff --git a/usr/src/uts/intel/asm/bitmap.h b/usr/src/uts/intel/asm/bitmap.h
index c72f52a8e7..6148277085 100644
--- a/usr/src/uts/intel/asm/bitmap.h
+++ b/usr/src/uts/intel/asm/bitmap.h
@@ -22,6 +22,7 @@
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _ASM_BITMAP_H
@@ -36,79 +37,60 @@ extern "C" {
#if !defined(__lint) && defined(__GNUC__)
+#if defined(__amd64)
+#define __SUF "q"
+#elif defined(__i386)
+#define __SUF "l"
+#else
+#error "port me"
+#endif
+
extern __GNU_INLINE int
highbit(ulong_t i)
{
- long __value = -1l;
+ long value = -1l;
-#if defined(__amd64)
- __asm__(
- "bsrq %1,%0"
- : "+r" (__value)
- : "r" (i)
- : "cc");
-#elif defined(__i386)
__asm__(
- "bsrl %1,%0"
- : "+r" (__value)
+ "bsr" __SUF " %1,%0"
+ : "+r" (value)
: "r" (i)
: "cc");
-#else
-#error "port me"
-#endif
- return ((int)(__value + 1));
+
+ return ((int)(value + 1));
}
extern __GNU_INLINE int
lowbit(ulong_t i)
{
- long __value = -1l;
+ long value = -1l;
-#if defined(__amd64)
- __asm__(
- "bsfq %1,%0"
- : "+r" (__value)
- : "r" (i)
- : "cc");
-#elif defined(__i386)
__asm__(
- "bsfl %1,%0"
- : "+r" (__value)
+ "bsf" __SUF " %1,%0"
+ : "+r" (value)
: "r" (i)
: "cc");
-#else
-#error "port me"
-#endif
- return ((int)(__value + 1));
+
+ return ((int)(value + 1));
}
extern __GNU_INLINE uint_t
atomic_btr32(uint32_t *memory, uint_t bitnum)
{
- uint8_t __value;
+ uint8_t value;
-#if defined(__amd64)
- __asm__ __volatile__(
- "lock;"
- "btrl %2, (%0);"
- "setc %1"
- : "+r" (memory), "+r" (__value)
- : "ir" (bitnum)
- : "cc");
-#elif defined(__i386)
__asm__ __volatile__(
"lock;"
- "btrl %2, (%0);"
+ "btrl %2,%0;"
"setc %1"
- : "+r" (memory), "=r" (__value)
+ : "+m" (*memory), "=r" (value)
: "ir" (bitnum)
: "cc");
-#else
-#error "port me"
-#endif
- return ((uint_t)__value);
+
+ return ((uint_t)value);
}
+#undef __SUF
+
#endif /* !__lint && __GNUC__ */
#ifdef __cplusplus