summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qsimd.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2024-09-27 10:10:39 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2024-09-29 20:56:37 +0200
commitaeeb11841b3e37c7f227d1232e9c30a55307d534 (patch)
treeb122d433f9214f73874eab0f41d48bca9b601f5d /src/corelib/global/qsimd.cpp
parent899c89c8d71d90b30c21b688cfe6b62868ad1ee9 (diff)
Clean and assert our ARM extensions on Apple hardware
Only check runtime when it makes sense, and assert compile-time assumptions. Change-Id: Ie9fe802c6e19814414ccc5f78a3df0d48a3e92a2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qsimd.cpp')
-rw-r--r--src/corelib/global/qsimd.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/corelib/global/qsimd.cpp b/src/corelib/global/qsimd.cpp
index 5e0e8380d49..28d25b5baca 100644
--- a/src/corelib/global/qsimd.cpp
+++ b/src/corelib/global/qsimd.cpp
@@ -134,14 +134,27 @@ static inline quint64 detectProcessorFeatures()
#elif defined(Q_OS_DARWIN) && defined(Q_PROCESSOR_ARM)
unsigned feature;
size_t len = sizeof(feature);
- if (sysctlbyname("hw.optional.neon", &feature, &len, nullptr, 0) == 0)
- features |= feature ? CpuFeatureNEON : 0;
+ Q_UNUSED(len);
+#if defined(__ARM_NEON)
+ features |= CpuFeatureNEON;
+#else
+ #error "Misconfiguration, NEON should always be enabled on Apple hardware"
+#endif
+#if defined(__ARM_FEATURE_CRC32)
+ features |= CpuFeatureCRC32;
+#elif defined(Q_OS_MACOS)
+ #error "Misconfiguration, CRC32 should always be enabled on Apple desktop hardware"
+#else
if (sysctlbyname("hw.optional.armv8_crc32", &feature, &len, nullptr, 0) == 0)
features |= feature ? CpuFeatureCRC32 : 0;
- if (sysctlbyname("hw.optional.arm.FEAT_AES", &feature, &len, nullptr, 0) == 0)
- features |= feature ? CpuFeatureAES : 0;
+#endif
#if defined(__ARM_FEATURE_CRYPTO)
features |= CpuFeatureAES;
+#elif defined(Q_OS_MACOS)
+ #error "Misconfiguration, CRYPTO/AES should always be enabled on Apple desktop hardware"
+#else
+ if (sysctlbyname("hw.optional.arm.FEAT_AES", &feature, &len, nullptr, 0) == 0)
+ features |= feature ? CpuFeatureAES : 0;
#endif
return features;
#elif defined(Q_OS_WIN) && defined(Q_PROCESSOR_ARM_64)