[__GNUC__ >= 2] (__bswap_16,
authordrepper <drepper>
Wed, 8 Jan 2003 00:07:10 +0000 (00:07 +0000)
committerdrepper <drepper>
Wed, 8 Jan 2003 00:07:10 +0000 (00:07 +0000)
__bswap_32, __bswap_64): Put x into temporary variable
to avoid warnings.
[!__GNUC__] (__bswap_16, __bswap_32, __bswap_64): Change into static
(inline) functions.

sysdeps/s390/bits/byteswap.h

index 6a4b4ae..d0e31b8 100644 (file)
@@ -1,5 +1,5 @@
 /* Macros to swap the order of bytes in integer values.  s390 version.
-   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
 # if __WORDSIZE == 64
 #  define __bswap_16(x) \
      (__extension__                                                          \
-      ({ unsigned short int __v;                                             \
+      ({ unsigned short int __v, __x = (x);                                  \
         if (__builtin_constant_p (x))                                        \
-          __v = __bswap_constant_16 (x);                                     \
+          __v = __bswap_constant_16 (__x);                                   \
         else {                                                               \
-           unsigned short int __tmp = (unsigned short int) (x);               \
+           unsigned short int __tmp = (unsigned short int) (__x);             \
            __asm__ __volatile__ (                                             \
               "lrvh %0,%1"                                                    \
               : "=&d" (__v) : "m" (__tmp) );                                  \
 # else
 #  define __bswap_16(x) \
      (__extension__                                                          \
-      ({ unsigned short int __v;                                             \
+      ({ unsigned short int __v, __x = (x);                                  \
         if (__builtin_constant_p (x))                                        \
-          __v = __bswap_constant_16 (x);                                     \
+          __v = __bswap_constant_16 (__x);                                   \
         else {                                                               \
-           unsigned short int __tmp = (unsigned short int) (x);               \
+           unsigned short int __tmp = (unsigned short int) (__x);             \
            __asm__ __volatile__ (                                             \
               "sr   %0,%0\n"                                                  \
               "la   1,%1\n"                                                   \
 # endif
 #else
 /* This is better than nothing.  */
-#define __bswap_16(x) __bswap_constant_16 (x)
+static __inline unsigned short int
+__bswap_16 (unsigned short int __bsx)
+{
+  return __bswap_constant_16 (__bsx);
+}
 #endif
 
 /* Swap bytes in 32 bit value.  */
 # if __WORDSIZE == 64
 #  define __bswap_32(x) \
      (__extension__                                                          \
-      ({ unsigned int __v;                                                   \
+      ({ unsigned int __v, __x = (x);                                        \
         if (__builtin_constant_p (x))                                        \
-          __v = __bswap_constant_32 (x);                                     \
+          __v = __bswap_constant_32 (__x);                                   \
         else {                                                               \
-           unsigned int __tmp = (unsigned int) (x);                           \
+           unsigned int __tmp = (unsigned int) (__x);                         \
            __asm__ __volatile__ (                                             \
               "lrv   %0,%1"                                                   \
               : "=&d" (__v) : "m" (__tmp));                                   \
 # else
 #  define __bswap_32(x) \
      (__extension__                                                          \
-      ({ unsigned int __v;                                                   \
+      ({ unsigned int __v, __x = (x);                                        \
         if (__builtin_constant_p (x))                                        \
-          __v = __bswap_constant_32 (x);                                     \
+          __v = __bswap_constant_32 (__x);                                   \
         else {                                                               \
-           unsigned int __tmp = (unsigned int) (x);                           \
+           unsigned int __tmp = (unsigned int) (__x);                         \
            __asm__ __volatile__ (                                             \
               "la    1,%1\n"                                                  \
               "icm   %0,8,3(1)\n"                                             \
         __v; }))
 # endif
 #else
-# define __bswap_32(x) __bswap_constant_32 (x)
+static __inline unsigned int
+__bswap_32 (unsigned int __bsx)
+{
+  return __bswap_constant_32 (__bsx);
+}
 #endif
 
 /* Swap bytes in 64 bit value.  */
 # if __WORDSIZE == 64
 #  define __bswap_64(x) \
      (__extension__                                                          \
-      ({ unsigned long __w;                                                  \
+      ({ unsigned long __w, __x = (x);                                       \
         if (__builtin_constant_p (x))                                        \
-          __w = __bswap_constant_64 (x);                                     \
+          __w = __bswap_constant_64 (__x);                                   \
         else {                                                               \
-           unsigned long __tmp = (unsigned long) (x);                         \
+           unsigned long __tmp = (unsigned long) (__x);                       \
            __asm__ __volatile__ (                                             \
               "lrvg  %0,%1"                                                   \
               : "=&d" (__w) : "m" (__tmp));                                   \
           __r.__ll; })
 # endif
 #else
-# define __bswap_64(x) __bswap_constant_64 (x)
+static __inline unsigned long long int
+__bswap_64 (unsigned long long int __bsx)
+{
+  return __bswap_constant_64 (__bsx);
+}
 #endif
 
 #endif /* _BITS_BYTESWAP_H */