summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-01-20 13:23:41 -0500
committerJeffrey Walton <noloader@gmail.com>2018-01-20 13:23:41 -0500
commit5cee4a6573573379d8a1ec9e560751364181c94f (patch)
treefe54fb1565fbf9ffd275fe2f9e3c7cf50cebf342
parent5adfe4e812a2fc22f457911eeb1b0add27799256 (diff)
downloadcryptopp-git-5cee4a6573573379d8a1ec9e560751364181c94f.tar.gz
Improve logic for <arm_acle.h> include (GH #568)
-rwxr-xr-xTestScripts/setenv-android-old.sh6
-rw-r--r--aria-simd.cpp11
-rw-r--r--blake2-simd.cpp11
-rw-r--r--config.h39
-rw-r--r--crc-simd.cpp3
-rw-r--r--gcm-simd.cpp5
-rw-r--r--neon-simd.cpp7
-rw-r--r--rijndael-simd.cpp17
-rwxr-xr-xsetenv-android.sh6
-rw-r--r--sha-simd.cpp17
-rw-r--r--shacal2-simd.cpp16
-rw-r--r--simon-simd.cpp15
-rw-r--r--speck-simd.cpp15
13 files changed, 103 insertions, 65 deletions
diff --git a/TestScripts/setenv-android-old.sh b/TestScripts/setenv-android-old.sh
index 3f7cac7b..d93b568d 100755
--- a/TestScripts/setenv-android-old.sh
+++ b/TestScripts/setenv-android-old.sh
@@ -108,21 +108,21 @@ case "$THE_ARCH" in
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi"
AOSP_ARCH="arch-arm"
- AOSP_FLAGS="-march=armv5te -mtune=xscale -mthumb -msoft-float -funwind-tables -fexceptions -frtti"
+ AOSP_FLAGS="-march=armv5te -mtune=xscale -mthumb -msoft-float -DCRYPTOPP_DISABLE_ASM -funwind-tables -fexceptions -frtti"
;;
armv7a|armv7-a|armeabi-v7a)
TOOLCHAIN_ARCH="arm-linux-androideabi"
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi-v7a"
AOSP_ARCH="arch-arm"
- AOSP_FLAGS="-march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti"
+ AOSP_FLAGS="-march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -DCRYPTOPP_DISABLE_ASM -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti"
;;
hard|armv7a-hard|armeabi-v7a-hard)
TOOLCHAIN_ARCH="arm-linux-androideabi"
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi-v7a"
AOSP_ARCH="arch-arm"
- AOSP_FLAGS="-mhard-float -D_NDK_MATH_NO_SOFTFP=1 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti -Wl,--no-warn-mismatch -Wl,-lm_hard"
+ AOSP_FLAGS="-mhard-float -D_NDK_MATH_NO_SOFTFP=1 -march=armv7-a -mfpu=vfpv3-d16 -DCRYPTOPP_DISABLE_ASM -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti -Wl,--no-warn-mismatch -Wl,-lm_hard"
;;
neon|armv7a-neon)
TOOLCHAIN_ARCH="arm-linux-androideabi"
diff --git a/aria-simd.cpp b/aria-simd.cpp
index af90a42a..f855be90 100644
--- a/aria-simd.cpp
+++ b/aria-simd.cpp
@@ -10,16 +10,19 @@
#include "config.h"
#include "misc.h"
-#if !(defined(__ARM_NEON) || defined(_MSC_VER))
-# undef CRYPTOPP_ARM_NEON_AVAILABLE
+#if (CRYPTOPP_SSSE3_AVAILABLE)
+# include <tmmintrin.h>
#endif
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
# include <arm_neon.h>
#endif
-#if (CRYPTOPP_SSSE3_AVAILABLE)
-# include <tmmintrin.h>
+// Can't use CRYPTOPP_ARM_XXX_AVAILABLE because too many
+// compilers don't follow ACLE conventions for the include.
+#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
+# include <stdint.h>
+# include <arm_acle.h>
#endif
// Clang __m128i casts, http://bugs.llvm.org/show_bug.cgi?id=20670
diff --git a/blake2-simd.cpp b/blake2-simd.cpp
index d3bae574..76e7c153 100644
--- a/blake2-simd.cpp
+++ b/blake2-simd.cpp
@@ -22,10 +22,6 @@
# undef CRYPTOPP_ARM_NEON_AVAILABLE
#endif
-#if !(defined(__ARM_NEON) || defined(_MSC_VER))
-# undef CRYPTOPP_ARM_NEON_AVAILABLE
-#endif
-
#if (CRYPTOPP_SSE41_AVAILABLE)
# include <emmintrin.h>
# include <tmmintrin.h>
@@ -36,6 +32,13 @@
# include <arm_neon.h>
#endif
+// Can't use CRYPTOPP_ARM_XXX_AVAILABLE because too many
+// compilers don't follow ACLE conventions for the include.
+#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
+# include <stdint.h>
+# include <arm_acle.h>
+#endif
+
// Clang __m128i casts, http://bugs.llvm.org/show_bug.cgi?id=20670
#define M128_CAST(x) ((__m128i *)(void *)(x))
#define CONST_M128_CAST(x) ((const __m128i *)(const void *)(x))
diff --git a/config.h b/config.h
index 9ad864f8..8de736df 100644
--- a/config.h
+++ b/config.h
@@ -563,12 +563,20 @@ NAMESPACE_END
// Requires ARMv7 and ACLE 1.0. Testing shows ARMv7 is really ARMv7a under most toolchains.
// Android still uses ARMv5 and ARMv6 so we have to be conservative when enabling NEON.
#if !defined(CRYPTOPP_ARM_NEON_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
-# if defined(__ARM_NEON) || defined(__ARM_NEON_FP) || defined(__ARM_FEATURE_NEON) || defined(__ARM_FEATURE_ASIMD) || \
+# if defined(__ARM_NEON) || defined(__ARM_NEON_FP) || defined(__ARM_FEATURE_NEON) || \
(__ARM_ARCH >= 7) || (CRYPTOPP_MSC_VERSION >= 1700)
# define CRYPTOPP_ARM_NEON_AVAILABLE 1
# endif
#endif
+// ARMv8 and ASIMD, which is NEON. It is part of ARMv8 core.
+// TODO: Add MSC_VER and ARM-64 platform define when available
+#if !defined(CRYPTOPP_ARM_ASIMD_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM)
+# if defined(__aarch32__) || defined(__aarch64__) || (CRYPTOPP_MSC_VERSION >= 1910)
+# define CRYPTOPP_ARM_ASIMD_AVAILABLE 1
+# endif
+#endif
+
// Requires ARMv8 and ACLE 2.0. GCC requires 4.8 and above.
// LLVM Clang requires 3.5. Apple Clang is unknown at the moment.
// Microsoft plans to support ARM-64, but its not clear how to detect it.
@@ -598,26 +606,33 @@ NAMESPACE_END
// Microsoft plans to support ARM-64, but its not clear how to detect it.
// TODO: Add Android ARMv8 support for AES and SHA
// TODO: Add MSC_VER and ARM-64 platform define when available
-#if !defined(CRYPTOPP_ARM_CRYPTO_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && !defined(__ANDROID__)
+#if !defined(CRYPTOPP_ARM_AES_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && !defined(__ANDROID__)
# if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_MSC_VERSION >= 1910) || \
defined(__aarch32__) || defined(__aarch64__)
# define CRYPTOPP_ARM_AES_AVAILABLE 1
+# endif
+#endif
+
+// Requires ARMv8 and ACLE 2.0. GCC requires 4.8 and above.
+// LLVM Clang requires 3.5. Apple Clang is unknown at the moment.
+// Microsoft plans to support ARM-64, but its not clear how to detect it.
+// TODO: Add Android ARMv8 support for AES and SHA
+// TODO: Add MSC_VER and ARM-64 platform define when available
+#if !defined(CRYPTOPP_ARM_SHA_AVAILABLE) && !defined(CRYPTOPP_DISABLE_ASM) && !defined(__ANDROID__)
+# if defined(__ARM_FEATURE_CRYPTO) || (CRYPTOPP_MSC_VERSION >= 1910) || \
+ defined(__aarch32__) || defined(__aarch64__)
# define CRYPTOPP_ARM_SHA_AVAILABLE 1
-# define CRYPTOPP_ARM_CRYPTO_AVAILABLE 1
# endif
#endif
-// Don't include <arm_acle.h> when using Apple Clang. Early Apple compilers
-// fail to compile with <arm_acle.h> included. Later Apple compilers compile
-// intrinsics without <arm_acle.h> included. Also avoid it with GCC 4.8,
-// and avoid it on Android, too.
-#if defined(CRYPTOPP_ARM_NEON_AVAILABLE) || defined(CRYPTOPP_ARM_CRC32_AVAILABLE) || \
- defined(CRYPTOPP_ARM_AES_AVAILABLE) || defined(CRYPTOPP_ARM_PMULL_AVAILABLE) || \
- defined(CRYPTOPP_ARM_SHA_AVAILABLE)
-# define CRYPTOPP_ARM_ACLE_AVAILABLE 1
+// Limit the <arm_acle.h> include.
+#if defined(__aarch32__) || defined(__aarch64__) || (__ARM_ARCH >= 8) || defined(__ARM_ACLE)
+# define CRYPTOPP_ARM_ACLE_AVAILABLE 1
#endif
-#if (defined(__ANDROID__) || defined(ANDROID)) && !defined(__ARM_ACLE)
+// Man, this is borked. Apple Clang defines __ARM_ACLE but then fails
+// to compile with "fatal error: 'arm_acle.h' file not found"
+#if defined(__ANDROID__) || defined(ANDROID) || defined(__APPLE__)
# undef CRYPTOPP_ARM_ACLE_AVAILABLE
#endif
diff --git a/crc-simd.cpp b/crc-simd.cpp
index 2d55e008..ed709b28 100644
--- a/crc-simd.cpp
+++ b/crc-simd.cpp
@@ -14,10 +14,13 @@
# include <nmmintrin.h>
#endif
+// Use ARMv8 rather than NEON due to compiler inconsistencies
#if (CRYPTOPP_ARM_CRC32_AVAILABLE)
# include <arm_neon.h>
#endif
+// Can't use CRYPTOPP_ARM_XXX_AVAILABLE because too many
+// compilers don't follow ACLE conventions for the include.
#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
# include <stdint.h>
# include <arm_acle.h>
diff --git a/gcm-simd.cpp b/gcm-simd.cpp
index 88d260b0..32f04e40 100644
--- a/gcm-simd.cpp
+++ b/gcm-simd.cpp
@@ -39,11 +39,14 @@
# include <wmmintrin.h>
#endif
-#if (CRYPTOPP_ARM_NEON_AVAILABLE || CRYPTOPP_ARM_PMULL_AVAILABLE)
+#if (CRYPTOPP_ARM_NEON_AVAILABLE)
# include <arm_neon.h>
#endif
+// Can't use CRYPTOPP_ARM_XXX_AVAILABLE because too many
+// compilers don't follow ACLE conventions for the include.
#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
+# include <stdint.h>
# include <arm_acle.h>
#endif
diff --git a/neon-simd.cpp b/neon-simd.cpp
index 4c64b45a..5b2c8b05 100644
--- a/neon-simd.cpp
+++ b/neon-simd.cpp
@@ -10,15 +10,14 @@
#include "config.h"
#include "stdcpp.h"
-#if !(defined(__ARM_NEON) || defined(_MSC_VER))
-# undef CRYPTOPP_ARM_NEON_AVAILABLE
-#endif
-
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
# include <arm_neon.h>
#endif
+// Can't use CRYPTOPP_ARM_XXX_AVAILABLE because too many
+// compilers don't follow ACLE conventions for the include.
#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
+# include <stdint.h>
# include <arm_acle.h>
#endif
diff --git a/rijndael-simd.cpp b/rijndael-simd.cpp
index 032899e2..8a493606 100644
--- a/rijndael-simd.cpp
+++ b/rijndael-simd.cpp
@@ -25,12 +25,6 @@
#include "misc.h"
#include "adv-simd.h"
-// We set CRYPTOPP_ARM_AES_AVAILABLE based on compiler version.
-// If the crypto is not available, then we have to disable it here.
-#if !(defined(__ARM_FEATURE_CRYPTO) || defined(_MSC_VER))
-# undef CRYPTOPP_ARM_AES_AVAILABLE
-#endif
-
// We set CRYPTOPP_POWER8_CRYPTO_AVAILABLE based on compiler version.
// If the crypto is not available, then we have to disable it here.
#if !(defined(__CRYPTO) || defined(_ARCH_PWR8) || defined(_ARCH_PWR9))
@@ -43,11 +37,16 @@
# include <wmmintrin.h>
#endif
+// Use ARMv8 rather than NEON due to compiler inconsistencies
#if (CRYPTOPP_ARM_AES_AVAILABLE)
# include <arm_neon.h>
-# if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
-# include <arm_acle.h>
-# endif
+#endif
+
+// Can't use CRYPTOPP_ARM_XXX_AVAILABLE because too many
+// compilers don't follow ACLE conventions for the include.
+#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
+# include <stdint.h>
+# include <arm_acle.h>
#endif
#if defined(CRYPTOPP_POWER8_AES_AVAILABLE)
diff --git a/setenv-android.sh b/setenv-android.sh
index 04191133..3066eeb3 100755
--- a/setenv-android.sh
+++ b/setenv-android.sh
@@ -101,21 +101,21 @@ case "$THE_ARCH" in
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi"
AOSP_ARCH="arch-arm"
- AOSP_FLAGS="-march=armv5te -mtune=xscale -mthumb -msoft-float -funwind-tables -fexceptions -frtti"
+ AOSP_FLAGS="-march=armv5te -mtune=xscale -mthumb -msoft-float -DCRYPTOPP_DISABLE_ASM -funwind-tables -fexceptions -frtti"
;;
armv7a|armv7-a|armeabi-v7a)
TOOLCHAIN_ARCH="arm-linux-androideabi"
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi-v7a"
AOSP_ARCH="arch-arm"
- AOSP_FLAGS="-march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti"
+ AOSP_FLAGS="-march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -DCRYPTOPP_DISABLE_ASM -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti"
;;
hard|armv7a-hard|armeabi-v7a-hard)
TOOLCHAIN_ARCH="arm-linux-androideabi"
TOOLCHAIN_NAME="arm-linux-androideabi"
AOSP_ABI="armeabi-v7a"
AOSP_ARCH="arch-arm"
- AOSP_FLAGS="-mhard-float -D_NDK_MATH_NO_SOFTFP=1 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti -Wl,--no-warn-mismatch -Wl,-lm_hard"
+ AOSP_FLAGS="-mhard-float -D_NDK_MATH_NO_SOFTFP=1 -march=armv7-a -mfpu=vfpv3-d16 -DCRYPTOPP_DISABLE_ASM -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti -Wl,--no-warn-mismatch -Wl,-lm_hard"
;;
neon|armv7a-neon)
TOOLCHAIN_ARCH="arm-linux-androideabi"
diff --git a/sha-simd.cpp b/sha-simd.cpp
index 25805f46..e3a45d17 100644
--- a/sha-simd.cpp
+++ b/sha-simd.cpp
@@ -11,22 +11,21 @@
#include "sha.h"
#include "misc.h"
-// We set CRYPTOPP_ARM_SHA_AVAILABLE based on compiler version.
-// If the crypto is not available, then we have to disable it here.
-#if !(defined(__ARM_FEATURE_CRYPTO) || defined(_MSC_VER))
-# undef CRYPTOPP_ARM_SHA_AVAILABLE
-#endif
-
#if (CRYPTOPP_SHANI_AVAILABLE)
# include <nmmintrin.h>
# include <immintrin.h>
#endif
+// Use ARMv8 rather than NEON due to compiler inconsistencies
#if (CRYPTOPP_ARM_SHA_AVAILABLE)
# include <arm_neon.h>
-# if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
-# include <arm_acle.h>
-# endif
+#endif
+
+// Can't use CRYPTOPP_ARM_XXX_AVAILABLE because too many
+// compilers don't follow ACLE conventions for the include.
+#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
+# include <stdint.h>
+# include <arm_acle.h>
#endif
#if CRYPTOPP_POWER8_SHA_AVAILABLE
diff --git a/shacal2-simd.cpp b/shacal2-simd.cpp
index 93cb6e07..6fb7f2b0 100644
--- a/shacal2-simd.cpp
+++ b/shacal2-simd.cpp
@@ -17,21 +17,21 @@
#include "sha.h"
#include "misc.h"
-// Clang and GCC hoops...
-#if !(defined(__ARM_FEATURE_CRYPTO) || defined(_MSC_VER))
-# undef CRYPTOPP_ARM_SHA_AVAILABLE
-#endif
-
#if (CRYPTOPP_SHANI_AVAILABLE)
# include <nmmintrin.h>
# include <immintrin.h>
#endif
+// Use ARMv8 rather than NEON due to compiler inconsistencies
#if (CRYPTOPP_ARM_SHA_AVAILABLE)
# include <arm_neon.h>
-# if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
-# include <arm_acle.h>
-# endif
+#endif
+
+// Can't use CRYPTOPP_ARM_XXX_AVAILABLE because too many
+// compilers don't follow ACLE conventions for the include.
+#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
+# include <stdint.h>
+# include <arm_acle.h>
#endif
// Clang __m128i casts, http://bugs.llvm.org/show_bug.cgi?id=20670
diff --git a/simon-simd.cpp b/simon-simd.cpp
index 26b41c73..81a73204 100644
--- a/simon-simd.cpp
+++ b/simon-simd.cpp
@@ -18,10 +18,6 @@
// #undef CRYPTOPP_SSE41_AVAILABLE
// #undef CRYPTOPP_ARM_NEON_AVAILABLE
-#if (CRYPTOPP_ARM_NEON_AVAILABLE)
-# include <arm_neon.h>
-#endif
-
#if (CRYPTOPP_SSSE3_AVAILABLE)
# include <pmmintrin.h>
# include <tmmintrin.h>
@@ -36,6 +32,17 @@
# include <immintrin.h>
#endif
+#if (CRYPTOPP_ARM_NEON_AVAILABLE)
+# include <arm_neon.h>
+#endif
+
+// Can't use CRYPTOPP_ARM_XXX_AVAILABLE because too many
+// compilers don't follow ACLE conventions for the include.
+#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
+# include <stdint.h>
+# include <arm_acle.h>
+#endif
+
// https://www.spinics.net/lists/gcchelp/msg47735.html and
// https://www.spinics.net/lists/gcchelp/msg47749.html
#if (CRYPTOPP_GCC_VERSION >= 40900)
diff --git a/speck-simd.cpp b/speck-simd.cpp
index b946460a..04db1030 100644
--- a/speck-simd.cpp
+++ b/speck-simd.cpp
@@ -27,10 +27,6 @@
# define WORKAROUND_GCC_AARCH64_BUG 1
#endif
-#if (CRYPTOPP_ARM_NEON_AVAILABLE)
-# include <arm_neon.h>
-#endif
-
#if (CRYPTOPP_SSSE3_AVAILABLE)
# include <pmmintrin.h>
# include <tmmintrin.h>
@@ -45,6 +41,17 @@
# include <immintrin.h>
#endif
+#if (CRYPTOPP_ARM_NEON_AVAILABLE)
+# include <arm_neon.h>
+#endif
+
+// Can't use CRYPTOPP_ARM_XXX_AVAILABLE because too many
+// compilers don't follow ACLE conventions for the include.
+#if defined(CRYPTOPP_ARM_ACLE_AVAILABLE)
+# include <stdint.h>
+# include <arm_acle.h>
+#endif
+
// https://www.spinics.net/lists/gcchelp/msg47735.html and
// https://www.spinics.net/lists/gcchelp/msg47749.html
#if (CRYPTOPP_GCC_VERSION >= 40900)