From 32692667a625f31aa02e0303f2139c780ae42694 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 17 Mar 2022 12:07:44 +0100 Subject: 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 Reviewed-by: Thiago Macieira --- src/corelib/global/qlogging.cpp | 4 ++-- src/corelib/global/qrandom.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib/global') 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 messageHandler = Q_BASIC_ATOMIC_INITIALIZER(nullptr); +Q_CONSTINIT static QBasicAtomicPointer 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 seed = Q_BASIC_ATOMIC_INITIALIZER(0U); +Q_CONSTINIT static QBasicAtomicInteger 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; } -- cgit v1.2.3