PATCH: Use__builtin_bswap[32|64] in i386/x86_64 bits/byteswap.h

H.J. Lu hjl.tools@gmail.com
Mon Mar 19 17:34:00 GMT 2012


On Sat, Mar 17, 2012 at 10:21 AM, Richard Henderson <rth@twiddle.net> wrote:
> On 03/17/2012 10:11 AM, H.J. Lu wrote:
>> GCC 4.7.0 defines __corei7__ for -march=corei7.  This patch adds
>> __corei7__ check in i386/x86_64 bits/byteswap.h.  OK to install?
>
> Isn't this (and the last couple added) recent enough that we can just
> defer to the gcc builtin?  I.e.
>
> #if __GCC_PREREQ(4,2)
> # define __bswap_16(x)  __builtin_bswap32((unsigned)(x) << 16)
> # define __bswap_32(x)  __builtin_bswap32(x)
> #else
> ... rest
> #endif
>

Here is a patch to use __builtin_bswap[32|64] in i386/x86_64 bits/byteswap.h
for GCC >= 4.2.  I didn't use __builtin_bswap32 for __bswap_16 since it is
less efficient:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624

Thanks.


-- 
H.J.
--
2012-03-19  H.J. Lu  <hongjiu.lu@intel.com>

	* sysdeps/i386/bits/byteswap.h: Include <features.h>.
	(__bswap_32): Use __builtin_bswap32 for GCC >= 4.2.
	(__bswap_64): Use __builtin_bswap64 for GCC >= 4.2.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libc-bswap-1.patch
Type: text/x-patch
Size: 6827 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120319/dfcb6835/attachment.bin>


More information about the Libc-alpha mailing list