summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-03-17 12:07:44 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-03-29 06:18:49 +0100
commit32692667a625f31aa02e0303f2139c780ae42694 (patch)
treebab74a97f673fd2caee7d1d0b68fac4583fcfb11 /src/corelib/global
parent9578a3f72fd67011263eac9d306750a2dbef01d1 (diff)
Apply Q_CONSTINIT across the codebase
Still not complete. Just grepping for static and thread_local. Task-number: QTBUG-100486 Change-Id: I90ca14e8db3a95590ecde5f89924cf6fcc9755a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qlogging.cpp4
-rw-r--r--src/corelib/global/qrandom.cpp4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 6302fc9d80..e0dbfcf09b 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1568,7 +1568,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &buf);
// pointer to QtMessageHandler debug handler (with context)
-static QBasicAtomicPointer<void (QtMsgType, const QMessageLogContext &, const QString &)> messageHandler = Q_BASIC_ATOMIC_INITIALIZER(nullptr);
+Q_CONSTINIT static QBasicAtomicPointer<void (QtMsgType, const QMessageLogContext &, const QString &)> messageHandler = Q_BASIC_ATOMIC_INITIALIZER(nullptr);
// ------------------------ Alternate logging sinks -------------------------
@@ -1873,7 +1873,7 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
#if defined(Q_COMPILER_THREAD_LOCAL)
-static thread_local bool msgHandlerGrabbed = false;
+Q_CONSTINIT static thread_local bool msgHandlerGrabbed = false;
static bool grabMessageHandler()
{
diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp
index eb9aa542d3..daf0a46387 100644
--- a/src/corelib/global/qrandom.cpp
+++ b/src/corelib/global/qrandom.cpp
@@ -229,7 +229,7 @@ static void fallback_fill(quint32 *ptr, qsizetype left) noexcept
arc4random_buf(ptr, left * sizeof(*ptr));
}
#else
-static QBasicAtomicInteger<unsigned> seed = Q_BASIC_ATOMIC_INITIALIZER(0U);
+Q_CONSTINIT static QBasicAtomicInteger<unsigned> seed = Q_BASIC_ATOMIC_INITIALIZER(0U);
static void fallback_update_seed(unsigned value)
{
// Update the seed to be used for the fallback mechanism, if we need to.
@@ -379,7 +379,7 @@ struct QRandomGenerator::SystemAndGlobalGenerators
static SystemAndGlobalGenerators *self()
{
- static SystemAndGlobalGenerators g;
+ Q_CONSTINIT static SystemAndGlobalGenerators g;
static_assert(sizeof(g) > sizeof(QRandomGenerator64));
return &g;
}