PATCH: Use__builtin_bswap[32|64] in i386/x86_64 bits/byteswap.h
H.J. Lu
hjl.tools@gmail.com
Mon Mar 26 22:23:00 GMT 2012
On Mon, Mar 19, 2012 at 10:33 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> 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.
Unfortunately __builtin_bswap32/__builtin_bswap64 don't work with
printf format:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52732
We may need to cast the results explicitly.
--
H.J.
More information about the Libc-alpha
mailing list