diff options
Diffstat (limited to 'src/corelib/global/qsimd.cpp')
-rw-r--r-- | src/corelib/global/qsimd.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/corelib/global/qsimd.cpp b/src/corelib/global/qsimd.cpp index cc90433567..8bc5381591 100644 --- a/src/corelib/global/qsimd.cpp +++ b/src/corelib/global/qsimd.cpp @@ -9,8 +9,6 @@ #include "qsimd_p.h" #include "qalgorithms.h" -#include <array> // for std::size - #include <stdio.h> #include <string.h> @@ -64,6 +62,14 @@ QT_BEGIN_NAMESPACE +template <typename T, uint N> QT_FUNCTION_TARGET_BASELINE +uint arraysize(T (&)[N]) +{ + // Same as std::size, but with QT_FUNCTION_TARGET_BASELIE, + // otherwise some versions of GCC fail to compile. + return N; +} + #if defined(Q_PROCESSOR_ARM) /* Data: neon @@ -97,12 +103,7 @@ static const int features_indices[] = { 0 }; #endif // end generated -#if defined (Q_OS_NACL) -static inline uint detectProcessorFeatures() -{ - return 0; -} -#elif defined(Q_PROCESSOR_ARM) +#if defined(Q_PROCESSOR_ARM) static inline quint64 detectProcessorFeatures() { quint64 features = 0; @@ -364,7 +365,7 @@ static quint64 detectProcessorFeatures() cpuidFeatures07_00(results[Leaf07_00EBX], results[Leaf07_00ECX], results[Leaf07_00EDX]); // populate our feature list - for (uint i = 0; i < std::size(x86_locators); ++i) { + for (uint i = 0; i < arraysize(x86_locators); ++i) { uint word = x86_locators[i] / 32; uint bit = 1U << (x86_locators[i] % 32); quint64 feature = Q_UINT64_C(1) << i; @@ -560,11 +561,6 @@ QT_FUNCTION_TARGET_BASELINE uint64_t QT_MANGLE_NAMESPACE(qDetectCpuFeatures)() { auto minFeatureTest = minFeature; -#if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM_64) - // Yocto hard-codes CRC32+AES on. Since they are unlikely to be used - // automatically by compilers, we can just add runtime check. - minFeatureTest &= ~(CpuFeatureAES|CpuFeatureCRC32); -#endif #if defined(Q_PROCESSOR_X86_64) && defined(cpu_feature_shstk) // Controlflow Enforcement Technology (CET) is an OS-assisted // hardware-feature, meaning the CPUID bit may be disabled if the OS @@ -583,7 +579,7 @@ uint64_t QT_MANGLE_NAMESPACE(qDetectCpuFeatures)() #endif while (char *token = strtok(disable, " ")) { disable = nullptr; - for (uint i = 0; i < std::size(features_indices); ++i) { + for (uint i = 0; i < arraysize(features_indices); ++i) { if (strcmp(token, features_string + features_indices[i]) == 0) f &= ~(Q_UINT64_C(1) << i); } @@ -598,7 +594,7 @@ uint64_t QT_MANGLE_NAMESPACE(qDetectCpuFeatures)() if (Q_UNLIKELY(!runningOnValgrind && minFeatureTest != 0 && (f & minFeatureTest) != minFeatureTest)) { quint64 missing = minFeatureTest & ~quint64(f); fprintf(stderr, "Incompatible processor. This Qt build requires the following features:\n "); - for (uint i = 0; i < std::size(features_indices); ++i) { + for (uint i = 0; i < arraysize(features_indices); ++i) { if (missing & (Q_UINT64_C(1) << i)) fprintf(stderr, "%s", features_string + features_indices[i]); } @@ -618,14 +614,14 @@ void qDumpCPUFeatures() { quint64 features = detectProcessorFeatures() & ~SimdInitialized; printf("Processor features: "); - for (uint i = 0; i < std::size(features_indices); ++i) { + for (uint i = 0; i < arraysize(features_indices); ++i) { if (features & (Q_UINT64_C(1) << i)) printf("%s%s", features_string + features_indices[i], minFeature & (Q_UINT64_C(1) << i) ? "[required]" : ""); } if ((features = (qCompilerCpuFeatures & ~features))) { printf("\n!!!!!!!!!!!!!!!!!!!!\n!!! Missing required features:"); - for (uint i = 0; i < std::size(features_indices); ++i) { + for (uint i = 0; i < arraysize(features_indices); ++i) { if (features & (Q_UINT64_C(1) << i)) printf("%s", features_string + features_indices[i]); } @@ -760,7 +756,7 @@ QT_FUNCTION_TARGET(RDRND) qsizetype qRandomCpu(void *buffer, qsizetype count) no ptr = qt_random_rdrnd(ptr, end); return ptr - reinterpret_cast<unsigned *>(buffer); } -#elif defined(Q_PROCESSOR_X86) && !defined(Q_OS_NACL) && !defined(Q_PROCESSOR_ARM) +#elif defined(Q_PROCESSOR_X86) && !defined(Q_PROCESSOR_ARM) static bool checkRdrndWorks() noexcept { return false; } #endif // Q_PROCESSOR_X86 && RDRND |