diff options
author | Brent Cook <busterb@gmail.com> | 2020-09-12 16:48:46 -0500 |
---|---|---|
committer | Brent Cook <busterb@gmail.com> | 2020-09-12 16:48:46 -0500 |
commit | 693d4575e279253cf91ba7029f1106d3b5193d25 (patch) | |
tree | 03c67c7632fc0e05c0734b3e17452dad182c2a61 | |
parent | a2ea6495367de4b8bf5f3de125777280e5242a68 (diff) | |
parent | 7bf5edc4f2f225cf5d7030ff824fd3944735bbf9 (diff) | |
download | portable-693d4575e279253cf91ba7029f1106d3b5193d25.tar.gz portable-693d4575e279253cf91ba7029f1106d3b5193d25.tar.bz2 portable-693d4575e279253cf91ba7029f1106d3b5193d25.zip |
Land #604, Get __STRICT_ALIGNMENT from machine/endian.h
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | include/compat/machine/endian.h | 11 |
2 files changed, 11 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac index 888ca19..75b88fe 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -75,26 +75,12 @@ AC_ARG_ENABLE([tests], | |||
75 | [enable_tests="yes"]) | 75 | [enable_tests="yes"]) |
76 | AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = xyes]) | 76 | AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" = xyes]) |
77 | 77 | ||
78 | # Add CPU-specific alignment flags | ||
79 | old_cflags=$CFLAGS | ||
80 | CFLAGS="$CFLAGS -I$srcdir/include" | ||
81 | AC_MSG_CHECKING([if BSWAP4 builds without __STRICT_ALIGNMENT]) | ||
82 | AC_TRY_COMPILE([#include "$srcdir/crypto/modes/modes_lcl.h"], | ||
83 | [int a = 0; BSWAP4(a);], | ||
84 | AC_MSG_RESULT([yes]) | ||
85 | BSWAP4=yes, | ||
86 | AC_MSG_RESULT([no]) | ||
87 | BSWAP4=no) | ||
88 | CFLAGS="$old_cflags" | ||
89 | |||
90 | AS_CASE([$host_cpu], | 78 | AS_CASE([$host_cpu], |
91 | [*sparc*], [CPPFLAGS="$CPPFLAGS -D__STRICT_ALIGNMENT"], | ||
92 | [*arm*], [host_cpu=arm], | 79 | [*arm*], [host_cpu=arm], |
93 | [*amd64*], [host_cpu=x86_64 HOSTARCH=intel], | 80 | [*amd64*], [host_cpu=x86_64 HOSTARCH=intel], |
94 | [i?86], [HOSTARCH=intel], | 81 | [i?86], [HOSTARCH=intel], |
95 | [x86_64], [HOSTARCH=intel] | 82 | [x86_64], [HOSTARCH=intel] |
96 | ) | 83 | ) |
97 | AS_IF([test "x$BSWAP4" = "xyes" -a "$host_cpu" = "arm" ],,CPPFLAGS="$CPPFLAGS -D__STRICT_ALIGNMENT") | ||
98 | AM_CONDITIONAL([HOST_CPU_IS_INTEL], [test "x$HOSTARCH" = "xintel"]) | 84 | AM_CONDITIONAL([HOST_CPU_IS_INTEL], [test "x$HOSTARCH" = "xintel"]) |
99 | 85 | ||
100 | AC_MSG_CHECKING([if .gnu.warning accepts long strings]) | 86 | AC_MSG_CHECKING([if .gnu.warning accepts long strings]) |
diff --git a/include/compat/machine/endian.h b/include/compat/machine/endian.h index 43dac8f..4dcb60d 100644 --- a/include/compat/machine/endian.h +++ b/include/compat/machine/endian.h | |||
@@ -37,4 +37,15 @@ | |||
37 | 37 | ||
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #ifndef __STRICT_ALIGNMENT | ||
41 | #define __STRICT_ALIGNMENT | ||
42 | #if defined(__i386) || defined(__i386__) || \ | ||
43 | defined(__x86_64) || defined(__x86_64__) || \ | ||
44 | defined(__s390__) || defined(__s390x__) || \ | ||
45 | defined(__aarch64__) || \ | ||
46 | ((defined(__arm__) || defined(__arm)) && __ARM_ARCH >= 6) | ||
47 | #undef __STRICT_ALIGNMENT | ||
48 | #endif | ||
49 | #endif | ||
50 | |||
40 | #endif | 51 | #endif |