summaryrefslogtreecommitdiffstats
path: root/sys/i386/include/endian.h
diff options
context:
space:
mode:
authordyson <dyson@FreeBSD.org>1996-11-29 07:04:03 +0000
committerdyson <dyson@FreeBSD.org>1996-11-29 07:04:03 +0000
commit16328d75a712d771d35e60a8c9d8a23663395dab (patch)
tree26db12cb7bd59e4a95580c1c0baeff28f2e462aa /sys/i386/include/endian.h
parente0557864f9f6cc17ff8cbf0b61b7d32164109170 (diff)
downloadFreeBSD-src-16328d75a712d771d35e60a8c9d8a23663395dab.zip
FreeBSD-src-16328d75a712d771d35e60a8c9d8a23663395dab.tar.gz
Support the appropriate use of bswap instruction on non-I386 builds.
Per Wayne Scott of Intel, the old sequence took 20cycles!!! on a P6. Another nice side-benefit is that the kernel is about 3K smaller!!! Submitted by: Wayne Scott <wscott@ichips.intel.com>
Diffstat (limited to 'sys/i386/include/endian.h')
-rw-r--r--sys/i386/include/endian.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/i386/include/endian.h b/sys/i386/include/endian.h
index 85ee057..6e31c7d 100644
--- a/sys/i386/include/endian.h
+++ b/sys/i386/include/endian.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)endian.h 7.8 (Berkeley) 4/3/91
- * $Id: endian.h,v 1.6 1995/02/12 08:31:31 jkh Exp $
+ * $Id: endian.h,v 1.7 1996/10/21 17:15:05 nate Exp $
*/
#ifndef _MACHINE_ENDIAN_H_
@@ -64,12 +64,21 @@
: "0" (__X)); \
__X; })
#if __GNUC__ >= 2
+#if defined(KERNEL) && !defined(I386_CPU)
+#define __byte_swap_long(x) \
+__extension__ ({ register u_long __X = (x); \
+ __asm ("bswap %0" \
+ : "=q" (__X) \
+ : "0" (__X)); \
+ __X; })
+#else
#define __byte_swap_long(x) \
__extension__ ({ register u_long __X = (x); \
__asm ("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" \
: "=q" (__X) \
: "0" (__X)); \
__X; })
+#endif
#define __byte_swap_word(x) \
__extension__ ({ register u_short __X = (x); \
__asm ("xchgb %h1, %b1" \
OpenPOWER on IntegriCloud