summaryrefslogtreecommitdiff
path: root/usr/src/uts/intel/asm/bitmap.h
diff options
context:
space:
mode:
authorJosef 'Jeff' Sipek <josef.sipek@nexenta.com>2014-11-07 08:35:00 -0500
committerRobert Mustacchi <rm@joyent.com>2014-11-10 21:21:27 -0800
commit7e33f252cf7e3c3ee6c4ad7a90480f5aea3a026c (patch)
treebafbff10b8f4fc0626d6a625c34bbf4c66768748 /usr/src/uts/intel/asm/bitmap.h
parentde710d24d2fae4468e64da999e1d952a247f142c (diff)
downloadillumos-joyent-7e33f252cf7e3c3ee6c4ad7a90480f5aea3a026c.tar.gz
5288 x86 bitmap inline asm functions duplicate code
Reviewed by: Keith Wesolowski <keith.wesolowski@joyent.com> Approved by: Robert Mustacchi <rm@joyent.com>
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