From: Vitaly Chikunov Date: Thu, 17 Sep 2020 22:47:27 +0000 (+0300) Subject: Provide cmake test if alignment requirement is strict X-Git-Url: http://www.wagner.pp.ru/gitweb/?a=commitdiff_plain;h=6a2542d1e514bb8f37f8307fa10e33ad3e092014;p=openssl-gost%2Fengine.git Provide cmake test if alignment requirement is strict This is based on AX_CHECK_ALIGNED_ACCESS_REQUIRED from autoconf-archive. Note, that on some arches unaligned access behavior could be changed at runtime via prctl(1). Also, unaligned memory access is still slower (and very slow on some arches) even if it's not strictly required. (cherry picked from commit d2810d23a9f30ae885f9bf0783f0847a12972ff3) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 28236b5..0c8cb2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,18 @@ if (ADDCARRY_U64) add_definitions(-DHAVE_ADDCARRY_U64) endif() +check_c_source_runs(" + int main(void) { + char buf[16] = { 0, 1, 2 }; + int *p = buf + 1; + int *q = buf + 2; + return (*p == *q); + } + " RELAXED_ALIGNMENT) +if (NOT RELAXED_ALIGNMENT) + add_definitions(-DSTRICT_ALIGNMENT) +endif() + set(BIN_DIRECTORY bin) # Same soversion as OpenSSL