termux-packages/packages/cryptopp/cpu.cpp.patch

284 lines
10 KiB
Diff
Raw Normal View History

diff -uNr cryptopp/cpu.cpp cryptopp.mod/cpu.cpp
--- cryptopp/cpu.cpp 2019-04-28 23:36:50.000000000 +0000
+++ cryptopp.mod/cpu.cpp 2019-05-10 14:47:58.091890446 +0000
@@ -47,7 +47,7 @@
// "$ANDROID_NDK_ROOT/sources/android/cpufeatures".
// setenv-android.sh will copy the header and source file
// into PWD and the makefile will build it in place.
-#if defined(__ANDROID__)
+#if 0
# include "cpu-features.h"
#endif
@@ -548,264 +548,64 @@
inline bool CPU_QueryARMv7()
{
-#if defined(__aarch32__) || defined(__aarch64__)
- // ARMv7 or above
+#if defined(__arm__) || defined(__aarch32__) || defined(__aarch64__)
return true;
-#elif defined(__ANDROID__) && defined(__arm__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_ARMv7) != 0))
- return true;
-#elif defined(__linux__) && defined(__arm__)
- if ((getauxval(AT_HWCAP) & HWCAP_ARMv7) != 0)
- return true;
-#elif defined(__APPLE__) && defined(__arm__)
- // Apple hardware is ARMv7 or above.
- return true;
-#endif
+#else
return false;
+#endif
}
inline bool CPU_QueryNEON()
{
-#if defined(__ANDROID__) && defined(__aarch64__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM64) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_ASIMD) != 0))
- return true;
-#elif defined(__ANDROID__) && defined(__arm__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0))
- return true;
-#elif defined(__linux__) && defined(__aarch64__)
- if ((getauxval(AT_HWCAP) & HWCAP_ASIMD) != 0)
- return true;
-#elif defined(__linux__) && defined(__aarch32__)
- if ((getauxval(AT_HWCAP2) & HWCAP2_ASIMD) != 0)
- return true;
-#elif defined(__linux__) && defined(__arm__)
- if ((getauxval(AT_HWCAP) & HWCAP_ARM_NEON) != 0)
- return true;
-#elif defined(__APPLE__) && defined(__aarch64__)
- // Core feature set for Aarch32 and Aarch64.
+#if defined(__arm__) || defined(__aarch32__) || defined(__aarch64__)
return true;
-#endif
+#else
return false;
+#endif
}
inline bool CPU_QueryCRC32()
{
-#if defined(__ANDROID__) && defined(__aarch64__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM64) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_CRC32) != 0))
- return true;
-#elif defined(__ANDROID__) && defined(__aarch32__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_CRC32) != 0))
- return true;
-#elif defined(__linux__) && defined(__aarch64__)
- if ((getauxval(AT_HWCAP) & HWCAP_CRC32) != 0)
- return true;
-#elif defined(__linux__) && defined(__aarch32__)
- if ((getauxval(AT_HWCAP2) & HWCAP2_CRC32) != 0)
- return true;
-#elif defined(__APPLE__) && defined(__aarch64__)
- // No compiler support. CRC intrinsics result in a failed compiled.
- return false;
-#endif
return false;
}
inline bool CPU_QueryPMULL()
{
-#if defined(__ANDROID__) && defined(__aarch64__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM64) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_PMULL) != 0))
- return true;
-#elif defined(__ANDROID__) && defined(__aarch32__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_PMULL) != 0))
- return true;
-#elif defined(__linux__) && defined(__aarch64__)
- if ((getauxval(AT_HWCAP) & HWCAP_PMULL) != 0)
- return true;
-#elif defined(__linux__) && defined(__aarch32__)
- if ((getauxval(AT_HWCAP2) & HWCAP2_PMULL) != 0)
- return true;
-#elif defined(__APPLE__) && defined(__aarch64__)
- // No compiler support. PMULL intrinsics result in a failed compiled.
- return false;
-#endif
return false;
}
inline bool CPU_QueryAES()
{
-#if defined(__ANDROID__) && defined(__aarch64__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM64) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_AES) != 0))
- return true;
-#elif defined(__ANDROID__) && defined(__aarch32__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_AES) != 0))
- return true;
-#elif defined(__linux__) && defined(__aarch64__)
- if ((getauxval(AT_HWCAP) & HWCAP_AES) != 0)
- return true;
-#elif defined(__linux__) && defined(__aarch32__)
- if ((getauxval(AT_HWCAP2) & HWCAP2_AES) != 0)
- return true;
-#elif defined(__APPLE__) && defined(__aarch64__)
- unsigned int device, version;
- GetAppleMachineInfo(device, version);
- return IsAppleMachineARMv8(device, version);
-#endif
return false;
}
inline bool CPU_QuerySHA1()
{
-#if defined(__ANDROID__) && defined(__aarch64__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM64) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_SHA1) != 0))
- return true;
-#elif defined(__ANDROID__) && defined(__aarch32__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_SHA1) != 0))
- return true;
-#elif defined(__linux__) && defined(__aarch64__)
- if ((getauxval(AT_HWCAP) & HWCAP_SHA1) != 0)
- return true;
-#elif defined(__linux__) && defined(__aarch32__)
- if ((getauxval(AT_HWCAP2) & HWCAP2_SHA1) != 0)
- return true;
-#elif defined(__APPLE__) && defined(__aarch64__)
- unsigned int device, version;
- GetAppleMachineInfo(device, version);
- return IsAppleMachineARMv8(device, version);
-#endif
return false;
}
inline bool CPU_QuerySHA2()
{
-#if defined(__ANDROID__) && defined(__aarch64__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM64) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_SHA2) != 0))
- return true;
-#elif defined(__ANDROID__) && defined(__aarch32__)
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_SHA2) != 0))
- return true;
-#elif defined(__linux__) && defined(__aarch64__)
- if ((getauxval(AT_HWCAP) & HWCAP_SHA2) != 0)
- return true;
-#elif defined(__linux__) && defined(__aarch32__)
- if ((getauxval(AT_HWCAP2) & HWCAP2_SHA2) != 0)
- return true;
-#elif defined(__APPLE__) && defined(__aarch64__)
- unsigned int device, version;
- GetAppleMachineInfo(device, version);
- return IsAppleMachineARMv8(device, version);
-#endif
return false;
}
inline bool CPU_QuerySHA512()
{
-// Some ARMv8.4 features are disabled at the moment
-#if defined(__ANDROID__) && defined(__aarch64__) && 0
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM64) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_SHA512) != 0))
- return true;
-#elif defined(__ANDROID__) && defined(__aarch32__) && 0
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_SHA512) != 0))
- return true;
-#elif defined(__linux__) && defined(__aarch64__)
- if ((getauxval(AT_HWCAP) & HWCAP_SHA512) != 0)
- return true;
-#elif defined(__linux__) && defined(__aarch32__)
- if ((getauxval(AT_HWCAP2) & HWCAP2_SHA512) != 0)
- return true;
-#elif defined(__APPLE__) && defined(__aarch64__) && 0
- unsigned int device, version;
- GetAppleMachineInfo(device, version);
- return IsAppleMachineARMv84(device, version);
-#endif
return false;
}
inline bool CPU_QuerySHA3()
{
-// Some ARMv8.4 features are disabled at the moment
-#if defined(__ANDROID__) && defined(__aarch64__) && 0
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM64) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_SHA3) != 0))
- return true;
-#elif defined(__ANDROID__) && defined(__aarch32__) && 0
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_SHA3) != 0))
- return true;
-#elif defined(__linux__) && defined(__aarch64__)
- if ((getauxval(AT_HWCAP) & HWCAP_SHA3) != 0)
- return true;
-#elif defined(__linux__) && defined(__aarch32__)
- if ((getauxval(AT_HWCAP2) & HWCAP2_SHA3) != 0)
- return true;
-#elif defined(__APPLE__) && defined(__aarch64__) && 0
- unsigned int device, version;
- GetAppleMachineInfo(device, version);
- return IsAppleMachineARMv84(device, version);
-#endif
return false;
}
inline bool CPU_QuerySM3()
{
-// Some ARMv8.4 features are disabled at the moment
-#if defined(__ANDROID__) && defined(__aarch64__) && 0
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM64) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_SM3) != 0))
- return true;
-#elif defined(__ANDROID__) && defined(__aarch32__) && 0
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_SM3) != 0))
- return true;
-#elif defined(__linux__) && defined(__aarch64__)
- if ((getauxval(AT_HWCAP) & HWCAP_SM3) != 0)
- return true;
-#elif defined(__linux__) && defined(__aarch32__)
- if ((getauxval(AT_HWCAP2) & HWCAP2_SM3) != 0)
- return true;
-#elif defined(__APPLE__) && defined(__aarch64__) && 0
- unsigned int device, version;
- GetAppleMachineInfo(device, version);
- return IsAppleMachineARMv84(device, version);
-#endif
return false;
}
inline bool CPU_QuerySM4()
{
-// Some ARMv8.4 features are disabled at the moment
-#if defined(__ANDROID__) && defined(__aarch64__) && 0
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM64) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM64_FEATURE_SM4) != 0))
- return true;
-#elif defined(__ANDROID__) && defined(__aarch32__) && 0
- if (((android_getCpuFamily() & ANDROID_CPU_FAMILY_ARM) != 0) &&
- ((android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_SM4) != 0))
- return true;
-#elif defined(__linux__) && defined(__aarch64__)
- if ((getauxval(AT_HWCAP) & HWCAP_SM4) != 0)
- return true;
-#elif defined(__linux__) && defined(__aarch32__)
- if ((getauxval(AT_HWCAP2) & HWCAP2_SM4) != 0)
- return true;
-#elif defined(__APPLE__) && defined(__aarch64__) && 0
- unsigned int device, version;
- GetAppleMachineInfo(device, version);
- return IsAppleMachineARMv84(device, version);
-#endif
return false;
}