1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-24 04:25:10 -07:00

Detect NEON and ARMCRYPTO on ARM32

Which doesn't mean that the compiler will support these opcodes, so
we need to autoconf magic as well.
This commit is contained in:
Frank Denis 2019-10-22 23:03:28 +02:00
parent 456a57f235
commit 1910ca83d8

View File

@ -71,6 +71,8 @@ _sodium_runtime_arm_cpu_features(CPUFeatures * const cpu_features)
(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0x0;
#elif defined(HAVE_GETAUXVAL) && defined(AT_HWCAP) && defined(__aarch64__)
cpu_features->has_neon = (getauxval(AT_HWCAP) & (1L << 1)) != 0;
#elif defined(HAVE_GETAUXVAL) && defined(AT_HWCAP) && defined(__arm__)
cpu_features->has_neon = (getauxval(AT_HWCAP) & (1L << 12)) != 0;
#endif
if (cpu_features->has_neon == 0) {
@ -98,6 +100,8 @@ _sodium_runtime_arm_cpu_features(CPUFeatures * const cpu_features)
(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_AES) != 0x0;
#elif defined(HAVE_GETAUXVAL) && defined(AT_HWCAP) && defined(__aarch64__)
cpu_features->has_armcrypto_aes = (getauxval(AT_HWCAP) & (1L << 3)) != 0;
#elif defined(HAVE_GETAUXVAL) && defined(AT_HWCAP) && defined(__arm__)
cpu_features->has_armcrypto_aes = (getauxval(AT_HWCAP2) & (1L << 0)) != 0;
#endif
return 0;