svn commit: r232266 - in head/sys: amd64/include i386/include pc98/include x86/include

Bruce Evans brde at optusnet.com.au
Fri Mar 2 21:56:33 UTC 2012


On Fri, 2 Mar 2012, Tijl Coosemans wrote:

> On Friday 02 March 2012 12:52:41 Bruce Evans wrote:
>> ...
>> Here is another version.  It has now been tested a bit at runtime.
>> I had to restore almost all of the complications, so the following
>> reduces to mostly style changes including comments about surprising
>> details.  It has 1 fix for clang (the comitted version doesn't
>> work for clang).
>> ...
>> % -#define	_BYTEORDER_FUNC_DEFINED
>> % +/* XXX these are broken, since they evaluate x more than once. */
>
> Maybe make them static inline functions. That won't be very efficient at
> -O0 but it'll be correct and this implementation probably isn't very
> efficient anyway. Otherwise the patch looks good to me.
>
>> % +#define	__bswap16(x)	(__bswap16_gen((__uint16_t)(x)))
>> % +#define	__bswap32(x)	(__bswap32_gen((__uint32_t)(x)))
>> % +#define	__bswap64(x)	(__bswap64_gen((__uint64_t)(x)))

They are already static inline for the gcc `var' case, and that would
work for any compiler if the asms in them were ifdefed.  The problem
is the lack of __builtin_const_p() for non-gcc.  This is only needed
for the `const' case, since the static inlines don't work in static
initializers.  OTOH, the only thing that stops the generic expressions
working in the `var' case is their side effects.

Bruce


More information about the svn-src-head mailing list