Re: [PATCH] x86: do not expose CONFIG_BSWAP to userspace

From: H. Peter Anvin
Date: Fri Jan 30 2009 - 13:21:35 EST


Ben Pfaff wrote:
> Harvey Harrison <harvey.harrison@xxxxxxxxx> writes:
>
>> Is there a byteswap builtin in gcc? At least AVR32
>> seems to use it, but perhaps it's not generally exposed...perhaps we
>> could ask the gcc-folk?
>
> Yes, GCC has byteswap builtins on x86 documented as follows:
>
> -- Built-in Function: int32_t __builtin_bswap32 (int32_t x)
> Returns X with the order of the bytes reversed; for example,
> `0xaabbccdd' becomes `0xddccbbaa'. Byte here always means exactly
> 8 bits.
>
> -- Built-in Function: int64_t __builtin_bswap64 (int64_t x)
> Similar to `__builtin_bswap32', except the argument and return
> types are 64-bit.
>
> These were only added as of GCC 4.3 though.

It would make sense to use them if gcc >= 4.3 (both for userspace and
kernel space.) IMO, for older compilers we can just punt on the
enhancement for userspace and fall back to the i386 code.

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/