PATCH: Use __builtin_bswap32/64 for GCC >= 4.2
Andreas Jaeger
aj@suse.com
Fri Apr 6 06:51:00 GMT 2012
On 04/05/2012 10:08 PM, H.J. Lu wrote:
> Hi,
>
> sysdeps/x86_64/bits/byteswap.h has
>
> #if defined __GNUC__&& __GNUC__>= 2
> ..
> #else
> # define __bswap_32(x) \
> (__extension__
> \
> ({ register unsigned int __x = (x); __bswap_constant_32 (__x); }))
> #endif
>
> It doesn't work for compilers without GCC __extension__
> support.
>
> This patch uses __builtin_bswap32/64 for GCC>= 4.2.
> I used inline function instead of __extension__ to avoid
> the __builtin_bswap32/64 return type issue:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37743
>
> Tested on Linux/ia32 and Linux/x86-64. OK to install?
>
> Thanks.
>
> H.J.
> --
> 2012-04-05 H.J. Lu<hongjiu.lu@intel.com>
>
> * sysdeps/i386/bits/byteswap.h: (__bswap_32): Use
> __builtin_bswap32 for GCC>= 4.2.
> (__bswap_64): Use __builtin_bswap64 for GCC>= 4.2.
> * sysdeps/x86_64/bits/byteswap.h: Likewise.
Please check all other byteswap.h functions as well and do a similar
change there as well.
Btw. I see a lot of duplication in this code. Perhaps we can reduce the
number of files somehow.
Andreas
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
More information about the Libc-alpha
mailing list