diff options
author | Jack Lloyd <[email protected]> | 2015-12-31 11:59:27 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-12-31 11:59:27 -0500 |
commit | b269c8d1ce0cb5412712a8df963b2205364e17ae (patch) | |
tree | 8245489665f1f31c35626d4cf5275afbf0914276 /src/lib/codec/hex | |
parent | 18d81936b55874ba76eca59b1d01e8028cc2bf9a (diff) |
Use memcpy instead of misaligned pointer casts for reading words.
It works on x86, but C says it is undefined and it makes UBSan
unhappy. Happily, this memcpy approach probably also works fine under
processors which previously used the byte-at-a-time approach such as
ARM. But for right now using memcpy here is still gated under the
processor alignment flags.
In my tests recent GCC and Clang seemed to produce basically identical
code for either approach when using -O3; I imagine most compilers
these days are very good at analyzing/inlining/unrolling memcpys.
Also remove the manually unrolled versions of xor_buf, which caused
problems with GCC and -O3 due to it vectorizing the loads into
(aligned) SSE2 loads, which would fail when a misaligned pointer was
passed. Which always seemed kind of bogus to me, but I guess that's
what undefined behavior is for. Enable -O3 for GCC.
With this change the test suite is clean under GCC ASan+UBSan and
Clang ASan+UBSan, with the exception of one failure due to a bug in
libstdc++ (GCC bug 60734) when compiled by Clang.
Diffstat (limited to 'src/lib/codec/hex')
0 files changed, 0 insertions, 0 deletions