Add Android CPU feature detection code

Also see https://developer.android.com/ndk/guides/cpu-features.html
pull/461/head
Jeffrey Walton 2017-08-07 11:20:14 -04:00
parent a04dda56fa
commit d95a38a9fc
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
4 changed files with 22 additions and 6 deletions

View File

@ -81,8 +81,11 @@ bool CPU_TryCRC32_ARMV8()
}
return result;
#else
# if defined(__android__)
if (android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_CRC32)
return true;
// https://sourceware.org/ml/libc-help/2017-08/msg00012.html
# if defined(__linux__) && defined(__aarch64__)
# elif defined(__linux__) && defined(__aarch64__)
if (getauxval(AT_HWCAP) & HWCAP_CRC32)
return true;
# elif defined(__linux__) && defined(__aarch32__)

View File

@ -214,8 +214,11 @@ bool CPU_TryPMULL_ARMV8()
}
return result;
# else
# if defined(__android__)
if (android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_PMULL)
return true;
// https://sourceware.org/ml/libc-help/2017-08/msg00012.html
# if defined(__linux__) && defined(__aarch64__)
# elif defined(__linux__) && defined(__aarch64__)
if (getauxval(AT_HWCAP) & HWCAP_PMULL)
return true;
# elif defined(__linux__) && defined(__aarch32__)

View File

@ -104,8 +104,11 @@ bool CPU_TryAES_ARMV8()
}
return result;
# else
# if defined(__android__)
if (android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_AES)
return true;
// https://sourceware.org/ml/libc-help/2017-08/msg00012.html
# if defined(__linux__) && defined(__aarch64__)
# elif defined(__linux__) && defined(__aarch64__)
if (getauxval(AT_HWCAP) & HWCAP_AES)
return true;
# elif defined(__linux__) && defined(__aarch32__)

View File

@ -91,8 +91,11 @@ bool CPU_TrySHA1_ARMV8()
}
return result;
# else
# if defined(__android__)
if (android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_SHA1)
return true;
// https://sourceware.org/ml/libc-help/2017-08/msg00012.html
# if defined(__linux__) && defined(__aarch64__)
# elif defined(__linux__) && defined(__aarch64__)
if (getauxval(AT_HWCAP) & HWCAP_SHA1)
return true;
# elif defined(__linux__) && defined(__aarch32__)
@ -158,11 +161,15 @@ bool CPU_TrySHA2_ARMV8()
}
return result;
#else
# if defined(__linux__) && defined(__aarch64__)
# if defined(__android__)
if (android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_SHA2)
return true;
// https://sourceware.org/ml/libc-help/2017-08/msg00012.html
# elif defined(__linux__) && defined(__aarch64__)
if (getauxval(AT_HWCAP) & HWCAP_SHA2)
return true;
# elif defined(__linux__) && defined(__aarch32__)
if (getauxval(AT_HWCAP) & HWCAP_SHA2)
if (getauxval(AT_HWCAP2) & HWCAP2_SHA2)
return true;
# endif