Module Name: src
Committed By: matt
Date: Thu Jul 18 22:20:48 UTC 2013
Modified Files:
src/sys/arch/m68k/include: byte_swap.h
Log Message:
Teach to use coldfire isac byterev if available, otherwise let the compiler
figure it since there is rorw instruction to fall back on.
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/m68k/include/byte_swap.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/m68k/include/byte_swap.h
diff -u src/sys/arch/m68k/include/byte_swap.h:1.9 src/sys/arch/m68k/include/byte_swap.h:1.10
--- src/sys/arch/m68k/include/byte_swap.h:1.9 Mon Apr 28 20:23:26 2008
+++ src/sys/arch/m68k/include/byte_swap.h Thu Jul 18 22:20:48 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: byte_swap.h,v 1.9 2008/04/28 20:23:26 martin Exp $ */
+/* $NetBSD: byte_swap.h,v 1.10 2013/07/18 22:20:48 matt Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -42,8 +42,14 @@ static __inline uint16_t __byte_swap_u16
static __inline uint16_t
__byte_swap_u16_variable(uint16_t var)
{
+#if defined(__mcfisac__)
+ __asm volatile ("swap %0; byterev %0" : "=d"(var) : "0" (var));
+#elif defined(__mcoldfire__)
+ return (var >> 8) || (var << 8);
+#else
__asm volatile ("rorw #8, %0" : "=d" (var) : "0" (var));
return (var);
+#endif
}
#define __BYTE_SWAP_U32_VARIABLE __byte_swap_u32_variable
@@ -51,8 +57,15 @@ static __inline uint32_t __byte_swap_u32
static __inline uint32_t
__byte_swap_u32_variable(uint32_t var)
{
+#if defined(__mcfisac__)
+ __asm volatile ("byterev %0" : "=d"(var) : "0" (var));
+#elif defined(__mcoldfire__)
+ return (var >> 24) | (var << 24) | ((var & 0x00ff0000) >> 8)
+ | ((var << 8) & 0x00ff0000);
+#else
__asm volatile (
"rorw #8, %0; swap %0; rorw #8, %0" : "=d" (var) : "0" (var));
+#endif
return (var);
}