On Sat, 17 May 2014, [utf-8] Dag-Erling Sm??rgrav wrote:
Bruce Evans <b...@optusnet.com.au> writes:
-Wcast-qual is especially onerous in contrib'ed code written to a lower
standard.
Well, I could have just lowered WARNS... LDNS actually isn't that bad.
Unbound is much worse.
Converting this to use system endianness conversion functions wouldn't
take much more churn.
Do our standard endianness conversion functions handle unaligned
accesses?
Yes. They intentionally use pessimal bytewise accesses for everything.
However, clang optimizes away all the pessimizations in many useful
cases, at last on amd64. This depends on the functions being inline.
When clang can see that the pointed-to object is aligned, it generates
minimal code (at most a load-store for a null conversion, and I think
at most a load-bswap-store for a swapping conversion (I only checked
related cases for the latter)). The case where the pointed-to object
is just an array of uint8_t is still pessimized. Callers wanting to
avoid the pessimal case can avoid it by copying from the array to a
local variable.
gcc-4-2.1 doesn't optimize away any of the pessimizations. However,
in even more complicated conversions in FP code, it optimizes the
union hack just as well as clang.
Bruce
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"