Date: Sat, 3 Mar 2012 08:56:29 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Tijl Coosemans <tijl@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Dimitry Andric <dim@freebsd.org>, Bruce Evans <brde@optusnet.com.au> Subject: Re: svn commit: r232266 - in head/sys: amd64/include i386/include pc98/include x86/include Message-ID: <20120303084934.L888@besplex.bde.org> In-Reply-To: <201203022129.10849.tijl@freebsd.org> References: <201202281939.q1SJdtYr084858@svn.freebsd.org> <20120302130435.J929@besplex.bde.org> <20120302223355.Q2543@besplex.bde.org> <201203022129.10849.tijl@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120303084934.L888>