]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
cmake: check for unaligned access 28936/head
authorKefu Chai <kchai@redhat.com>
Tue, 9 Jul 2019 07:27:59 +0000 (15:27 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 11 Sep 2019 04:47:26 +0000 (12:47 +0800)
commit34b33d447f958982af657b1d44dabbc7b6437e75
tree153034db34ecabee5b65b82312d55ca5adedf9f8
parent67bf182aa542a614c591b55c11736a0082feed47
cmake: check for unaligned access

C and C++ allow us to cast a pointer with an alignment requirement to
one with a different alignment requirement. but if the destination
type's alignment is greater/stricter than the source type, the behavior
is undefined. on amd64, it's allowed. and on aarch64, GCC offers an
option named `-munaligned-access` to enable this behavior. so we cannot
take this as guaranteed.

in denc.h and messenger implementations, we just cast the pointers to
the type we want to access without memcpy(), which is, strictly
speaking, not quite standard compliant.

so, to be on the safe side, we detect the support of unaligned access at
compile time.

please note, this would fail the cross-compile. as the target platform
might not support unaligned access, and the produced executable does not
run on the build platform. so this test is skipped if the building
host's architecture is different than that of target host.

Signed-off-by: Kefu Chai <kchai@redhat.com>
cmake/modules/CephChecks.cmake