This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] byteswap-16.h: USe __builtin_bswap16 in gcc 4.8


---
 bits/byteswap-16.h                    | 8 ++++++++
 ports/sysdeps/ia64/bits/byteswap-16.h | 8 ++++++++
 sysdeps/s390/bits/byteswap-16.h       | 8 ++++++++
 sysdeps/x86/bits/byteswap-16.h        | 8 +++++++-
 4 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/bits/byteswap-16.h b/bits/byteswap-16.h
index 6179196..f118128 100644
--- a/bits/byteswap-16.h
+++ b/bits/byteswap-16.h
@@ -21,10 +21,18 @@
 #endif
 
 #ifdef __GNUC__
+# if __GNUC_PREREQ (4, 8)
+static __inline unsigned short int
+__bswap_16 (unsigned short int __bsx)
+{
+  return __builtin_bswap16 (__bsx);
+}
+# else
 # define __bswap_16(x) \
     (__extension__							      \
      ({ unsigned short int __bsx = (unsigned short int) (x);		      \
        __bswap_constant_16 (__bsx); }))
+#endif
 #else
 static __inline unsigned short int
 __bswap_16 (unsigned short int __bsx)
diff --git a/ports/sysdeps/ia64/bits/byteswap-16.h b/ports/sysdeps/ia64/bits/byteswap-16.h
index 2ff9b74..6ffb327 100644
--- a/ports/sysdeps/ia64/bits/byteswap-16.h
+++ b/ports/sysdeps/ia64/bits/byteswap-16.h
@@ -21,6 +21,13 @@
 #endif
 
 #if defined __GNUC__ && __GNUC__ >= 2
+# if __GNUC_PREREQ (4, 8)
+static __inline unsigned short int
+__bswap_16 (unsigned short int __bsx)
+{
+  return __builtin_bswap16 (__bsx);
+}
+# else
 # define __bswap_16(x) \
      (__extension__							      \
       ({ register unsigned short int __v, __x = (unsigned short int) (x);     \
@@ -32,6 +39,7 @@
 				 : "=r" (__v)				      \
 				 : "r" ((unsigned short int) (__x)));	      \
 	 __v; }))
+#endif
 #else
 /* This is better than nothing.  */
 static __inline unsigned short int
diff --git a/sysdeps/s390/bits/byteswap-16.h b/sysdeps/s390/bits/byteswap-16.h
index a6b2fa1..6aebbbb 100644
--- a/sysdeps/s390/bits/byteswap-16.h
+++ b/sysdeps/s390/bits/byteswap-16.h
@@ -25,6 +25,13 @@
 
 /* Swap bytes in 16 bit value. */
 #if defined __GNUC__ && __GNUC__ >= 2
+# if __GNUC_PREREQ (4, 8)
+static __inline unsigned short int
+__bswap_16 (unsigned short int __bsx)
+{
+  return __builtin_bswap16 (__bsx);
+}
+# else
 # if __WORDSIZE == 64
 #  define __bswap_16(x) \
      (__extension__							      \
@@ -55,6 +62,7 @@
 	 }                                                                    \
 	 __v; }))
 # endif
+#endif
 #else
 /* This is better than nothing.  */
 static __inline unsigned short int
diff --git a/sysdeps/x86/bits/byteswap-16.h b/sysdeps/x86/bits/byteswap-16.h
index 9bb70fb..9b99d85 100644
--- a/sysdeps/x86/bits/byteswap-16.h
+++ b/sysdeps/x86/bits/byteswap-16.h
@@ -21,7 +21,13 @@
 #endif
 
 #ifdef __GNUC__
-# if __GNUC__ >= 2
+# if __GNUC_PREREQ (4, 8)
+static __inline unsigned short int
+__bswap_16 (unsigned short int __bsx)
+{
+  return __builtin_bswap16 (__bsx);
+}
+# elif __GNUC__ >= 2
 #  define __bswap_16(x) \
      (__extension__							      \
       ({ register unsigned short int __v, __x = (unsigned short int) (x);     \
-- 
1.8.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]