aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/s390
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/s390')
-rw-r--r--sysdeps/s390/bits/byteswap.h50
1 files changed, 31 insertions, 19 deletions
diff --git a/sysdeps/s390/bits/byteswap.h b/sysdeps/s390/bits/byteswap.h
index 6a4b4ae425..d0e31b8364 100644
--- a/sysdeps/s390/bits/byteswap.h
+++ b/sysdeps/s390/bits/byteswap.h
@@ -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.
@@ -35,11 +35,11 @@
# 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) ); \
@@ -48,11 +48,11 @@
# 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" \
@@ -64,7 +64,11 @@
# 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. */
@@ -76,11 +80,11 @@
# 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)); \
@@ -89,11 +93,11 @@
# 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" \
@@ -105,7 +109,11 @@
__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. */
@@ -119,11 +127,11 @@
# 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)); \
@@ -140,7 +148,11 @@
__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 */