summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-06-06 20:42:32 +0000
committerLiang Qi <liang.qi@qt.io>2018-06-07 09:08:36 +0000
commit88eda007a3b5046999dd0b287634765efcd8934d (patch)
tree0aa6dfda768dcb822c8de2c1be818ad73bccef2e /src/corelib/tools
parentaf4435c5f8748a0135a06f7e85d979604b7eaffe (diff)
Revert "qsimd: remove support for systems without 64-bit atomics"
This reverts commit 6e1190053d28877b2e90375056735429525e2ee7. We had to bring back qatomic_msvc.h for MSVC 2015, which does not provide 64-bit atomics on 32-bit platforms. Task-number: QTBUG-68719 Change-Id: Iea902cf0b01191717e0a640944771fcede7b5ff8 Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qsimd.cpp7
-rw-r--r--src/corelib/tools/qsimd_p.h17
2 files changed, 17 insertions, 7 deletions
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index fd9c6a7079..b08e2aa611 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -522,7 +522,11 @@ static const int features_count = (sizeof features_indices) / (sizeof features_i
// record what CPU features were enabled by default in this Qt build
static const quint64 minFeature = qCompilerCpuFeatures;
+#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
Q_CORE_EXPORT QBasicAtomicInteger<quint64> qt_cpu_features[1] = { Q_BASIC_ATOMIC_INITIALIZER(0) };
+#else
+Q_CORE_EXPORT QBasicAtomicInteger<unsigned> qt_cpu_features[2] = { Q_BASIC_ATOMIC_INITIALIZER(0), Q_BASIC_ATOMIC_INITIALIZER(0) };
+#endif
void qDetectCpuFeatures()
{
@@ -555,6 +559,9 @@ void qDetectCpuFeatures()
}
qt_cpu_features[0].store(f | quint32(QSimdInitialized));
+#ifndef Q_ATOMIC_INT64_IS_SUPPORTED
+ qt_cpu_features[1].store(f >> 32);
+#endif
}
void qDumpCPUFeatures()
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 1b7ed57fa8..1bc7dd06b1 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -297,26 +297,29 @@ static const quint64 qCompilerCpuFeatures = 0
;
#endif
-#ifdef QT_BOOTSTRAPPED
-static inline quint64 qCpuFeatures()
-{
- return QSimdInitialized;
-}
-#else
+#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
extern Q_CORE_EXPORT QBasicAtomicInteger<quint64> qt_cpu_features[1];
+#else
+extern Q_CORE_EXPORT QBasicAtomicInteger<unsigned> qt_cpu_features[2];
+#endif
Q_CORE_EXPORT void qDetectCpuFeatures();
static inline quint64 qCpuFeatures()
{
quint64 features = qt_cpu_features[0].load();
+#ifndef Q_ATOMIC_INT64_IS_SUPPORTED
+ features |= quint64(qt_cpu_features[1].load()) << 32;
+#endif
if (Q_UNLIKELY(features == 0)) {
qDetectCpuFeatures();
features = qt_cpu_features[0].load();
+#ifndef Q_ATOMIC_INT64_IS_SUPPORTED
+ features |= quint64(qt_cpu_features[1].load()) << 32;
+#endif
Q_ASSUME(features != 0);
}
return features;
}
-#endif
#define qCpuHasFeature(feature) ((qCompilerCpuFeatures & (Q_UINT64_C(1) << CpuFeature ## feature)) \
|| (qCpuFeatures() & (Q_UINT64_C(1) << CpuFeature ## feature)))