svn commit: r233683 - head/sys/x86/include

Bruce Evans brde at optusnet.com.au
Fri Mar 30 10:25:42 UTC 2012


On Thu, 29 Mar 2012, Dimitry Andric wrote:

> Log:
>  Revert sys/x86/include/endian.h to what it was before r233419, as that
>  revision has two problems:
>  - It can produce worse code with both clang and gcc.
>  - It doesn't fix the actual issue introduced in r232721, which will be
>    fixed in the next commit.
>
>  Submitted by:	bde, tijl and jh
>  Pointy hat to:	dim

Thanks.  I didn't know that there was an actualy bug to be fixed...

> Modified:
>  head/sys/x86/include/endian.h
>
> Modified: head/sys/x86/include/endian.h
> ==============================================================================
> --- head/sys/x86/include/endian.h	Thu Mar 29 21:54:19 2012	(r233682)
> +++ head/sys/x86/include/endian.h	Thu Mar 29 23:30:17 2012	(r233683)
> @@ -63,11 +63,11 @@
> #define	BYTE_ORDER	_BYTE_ORDER
> #endif
>
> -#define	__bswap16_gen(x)	((__uint16_t)((x) << 8 | (x) >> 8))
> +#define	__bswap16_gen(x)	(__uint16_t)((x) << 8 | (x) >> 8)
> #define	__bswap32_gen(x)		\
> -	(((__uint32_t)__bswap16_gen(x) << 16) | __bswap16_gen((x) >> 16))
> +	(((__uint32_t)__bswap16(x) << 16) | __bswap16((x) >> 16))
> #define	__bswap64_gen(x)		\
> -	(((__uint64_t)__bswap32_gen(x) << 32) | __bswap32_gen((x) >> 32))
> +	(((__uint64_t)__bswap32(x) << 32) | __bswap32((x) >> 32))
>
> #ifdef __GNUCLIKE_BUILTIN_CONSTANT_P
> #define	__bswap16(x)				\
>

... it seems that there was no bug.  After looking at the next commit,
the bug backed out here is now clear, and I don't like the next commit
either (more details on that in a reply to it).  Using the non-generic
versions ensured that there were no extra bits.  In the `const' case,
this is implemented using casts.  But the generic versions don't have
these casts.

Bruce


More information about the svn-src-all mailing list