Bug#652356: please use argument-safe bswap macros on all architectures
Aurelien Jarno dixit:
>I have dropped it in favor of the default version for the next upload.
Why don’t you just use these? (Tested for 32-bit and 64-bit both.)
I’ve not looked at other architectures atm though.
--- usr/include/m68k-linux-gnu/bits/byteswap.h~ 2011-12-17 02:44:08.000000000 +0000
+++ usr/include/m68k-linux-gnu/bits/byteswap.h 2011-12-17 02:49:34.000000000 +0000
@@ -1,5 +1,5 @@
/* Macros to swap the order of bytes in integer values. m68k version.
- Copyright (C) 1997, 2002, 2008 Free Software Foundation, Inc.
+ Copyright (C) 1997, 2002, 2008, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -50,15 +50,15 @@
#if defined __GNUC__ && __GNUC__ >= 2 && !defined(__mcoldfire__)
# define __bswap_32(x) \
__extension__ \
- ({ unsigned int __bswap_32_v; \
- if (__builtin_constant_p (x)) \
- __bswap_32_v = __bswap_constant_32 (x); \
+ ({ unsigned int __bswap_32_v, __bswap_32_x = (x); \
+ if (__builtin_constant_p (__bswap_32_x)) \
+ __bswap_32_v = __bswap_constant_32 (__bswap_32_x); \
else \
__asm__ __volatile__ ("ror%.w %#8, %0;" \
"swap %0;" \
"ror%.w %#8, %0" \
: "=d" (__bswap_32_v) \
- : "0" ((unsigned int) (x))); \
+ : "0" (__bswap_32_x)); \
__bswap_32_v; })
#else
static __inline unsigned int
@@ -85,11 +85,12 @@
__extension__ \
({ union { unsigned long long int __ll; \
unsigned long int __l[2]; } __bswap_64_v, __bswap_64_r; \
- if (__builtin_constant_p (x)) \
- __bswap_64_r.__ll = __bswap_constant_64 (x); \
+ unsigned long long int __bswap_64_x = (x); \
+ if (__builtin_constant_p (__bswap_64_x)) \
+ __bswap_64_r.__ll = __bswap_constant_64 (__bswap_64_x); \
else \
{ \
- __bswap_64_v.__ll = (x); \
+ __bswap_64_v.__ll = __bswap_64_x; \
__bswap_64_r.__l[0] = __bswap_32 (__bswap_64_v.__l[1]); \
__bswap_64_r.__l[1] = __bswap_32 (__bswap_64_v.__l[0]); \
} \
bye,
//mirabilos
--
“Having a smoking section in a restaurant is like having
a peeing section in a swimming pool.”
-- Edward Burr
Reply to: