PATCH: Add bits/byteswap-16.h and use GCC builtin 32/64-bit bswap

Chung-Lin Tang cltang@codesourcery.com
Tue Apr 24 13:32:00 GMT 2012


On 2012/4/24 07:19 PM, Andreas Jaeger wrote:
> I suggest to solve this differently for sh.
> Currently you do:
> #if __BYTE_ORDER == __BIG_ENDIAN
> 
> Looking at sysdeps/sh/bits/endian.h, can't you use instead:
> #ifndef __LITTLE_ENDIAN__
> 
> Andreas

Agreed. Here's the corresponding fixes for SH, CCing Thomas.

Thanks,
Chung-Lin

2012-04-24  Chung-Lin Tang  <cltang@codesourcery.com>

	* sysdeps/sh/memcpy.S: Remove include of endian.h, change
	preprocessor endian tests to '#ifdef __BIG_ENDIAN__'.
	* sysdeps/sh/strlen.S: Likewise.
-------------- next part --------------
diff --git a/sysdeps/sh/memcpy.S b/sysdeps/sh/memcpy.S
index 0b9ed6b..38560a4 100644
--- a/sysdeps/sh/memcpy.S
+++ b/sysdeps/sh/memcpy.S
@@ -18,7 +18,6 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#include <endian.h>
 
 /* void *memcpy(void *dst, const void *src, size_t n);
     No overlap between the memory of DST and of SRC are assumed.  */
@@ -49,7 +48,7 @@ L_wordalign:
 
 	mov.w	@r0+,r1		/* Copy one word.  */
 	add	#-2,r6
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifdef __BIG_ENDIAN__
 	add	#1,r4
 	mov.b	r1,@r4
 	shlr8	r1
@@ -98,7 +97,7 @@ L_copydest1_or_3_loop:
 	mov.l	@r5+,r0		/* Read first longword.  */
 	dt	r7
 	mov.l	@r5+,r1		/* Read second longword.  */
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifdef __BIG_ENDIAN__
 	/* Write first longword as byte, word, byte.  */
 	mov.b	r0,@(4,r4)
 	shlr8	r0
@@ -140,7 +139,7 @@ L_copydest2_loop:
 	mov.l	@r5+,r0
 	dt	r7
 	mov.l	@r5+,r1
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifdef __BIG_ENDIAN__
 	mov.w	r0,@(2,r4)
 	shlr16	r0
 	mov.w	r0,@r4
diff --git a/sysdeps/sh/strlen.S b/sysdeps/sh/strlen.S
index 93f7dd8..88fd372 100644
--- a/sysdeps/sh/strlen.S
+++ b/sysdeps/sh/strlen.S
@@ -17,7 +17,6 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <sysdep.h>
-#include <endian.h>
 
 /* size_t strlen (const char *s)  */
 
@@ -58,7 +57,7 @@ ENTRY(strlen)
 	add	#4, r2
 
 	add	#-4, r2
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifdef __BIG_ENDIAN__
 	swap.b	r1, r1
 	swap.w	r1, r1
 	swap.b	r1, r1


More information about the Libc-alpha mailing list