PATCH: Use __builtin_bswap32/64 for GCC >= 4.2
H.J. Lu
hjl.tools@gmail.com
Fri Apr 6 17:34:00 GMT 2012
On Thu, Apr 5, 2012 at 11:50 PM, Andreas Jaeger <aj@suse.com> wrote:
> 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.
>
That is a good idea. This patch adds bits/byteswap2.h for __bswap_16 and
put common 32bit and 64bit bswap in bits/byteswap.h. I created hjl/bswap
branch with my change. OK to install?
Thanks.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libc-bswap-3.patch
Type: application/octet-stream
Size: 31236 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120406/c9be9df9/attachment.obj>
More information about the Libc-alpha
mailing list