From bafd3fdf1c72040abbf7ddf354f6b1c15c9985a4 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 25 Mar 2013 17:30:26 -0700 Subject: [PATCH] Make the inline CPU detection functions also static MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since qCpuHasFeature() checks the static qCompilerCpuFeatures variable and that variable's value might change depending on the compiler flags, it's best to ensure that the function is not subject to link-time merging. That would be bad if it happened when qCpuHasFeature() was used from a file with higher CPU compiler settings than the default, as it would incorrectly conclude that certain features are always available. Change-Id: I8bacde056fb89869ec1d306a163742e72522315e Reviewed-by: Tor Arne Vestbø --- src/corelib/tools/qsimd_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index b9d546452f..98eb473da0 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -228,7 +228,7 @@ static const uint qCompilerCpuFeatures = 0 extern Q_CORE_EXPORT QBasicAtomicInt qt_cpu_features; Q_CORE_EXPORT void qDetectCpuFeatures(); -inline uint qCpuFeatures() +static inline uint qCpuFeatures() { int features = qt_cpu_features.load(); if (Q_UNLIKELY(features == 0)) { @@ -239,7 +239,7 @@ inline uint qCpuFeatures() return uint(features); } -inline uint qCpuHasFeature(CPUFeatures feature) +static inline uint qCpuHasFeature(CPUFeatures feature) { return qCompilerCpuFeatures & feature || qCpuFeatures() & feature; }