diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index bef109e401..1cbe0da771 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -267,7 +267,7 @@ static int tryReaping(pid_t pid, struct pipe_payload *payload) static void freeInfo(Header *header, ProcessInfo *entry) { entry->deathPipe = -1; - entry->pid = 0; + ffd_atomic_store(&entry->pid, 0, FFD_ATOMIC_RELEASE); (void)ffd_atomic_add_fetch(&header->busyCount, -1, FFD_ATOMIC_RELEASE); assert(header->busyCount >= 0); diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 84cf960f2d..379e37ac07 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -359,17 +359,17 @@ Q_NEVER_INLINE void QRandomGenerator::SystemGenerator::generate(quint32 *begin, quint32 *buffer = begin; qsizetype count = end - begin; - if (Q_UNLIKELY(uint(qt_randomdevice_control) & SetRandomData)) { - uint value = uint(qt_randomdevice_control) & RandomDataMask; + if (Q_UNLIKELY(uint(qt_randomdevice_control.loadAcquire()) & SetRandomData)) { + uint value = uint(qt_randomdevice_control.loadAcquire()) & RandomDataMask; std::fill_n(buffer, count, value); return; } qsizetype filled = 0; - if (qt_has_hwrng() && (uint(qt_randomdevice_control) & SkipHWRNG) == 0) + if (qt_has_hwrng() && (uint(qt_randomdevice_control.loadAcquire()) & SkipHWRNG) == 0) filled += qt_random_cpu(buffer, count); - if (filled != count && (uint(qt_randomdevice_control) & SkipSystemRNG) == 0) { + if (filled != count && (uint(qt_randomdevice_control.loadAcquire()) & SkipSystemRNG) == 0) { qsizetype bytesFilled = fillBuffer(buffer + filled, (count - filled) * qsizetype(sizeof(*buffer))); filled += bytesFilled / qsizetype(sizeof(*buffer)); @@ -1222,7 +1222,7 @@ void QRandomGenerator::_fillRange(void *buffer, void *bufferEnd) quint32 *begin = static_cast(buffer); quint32 *end = static_cast(bufferEnd); - if (type == SystemRNG || Q_UNLIKELY(uint(qt_randomdevice_control) & (UseSystemRNG|SetRandomData))) + if (type == SystemRNG || Q_UNLIKELY(uint(qt_randomdevice_control.loadAcquire()) & (UseSystemRNG|SetRandomData))) return SystemGenerator::self().generate(begin, end); SystemAndGlobalGenerators::PRNGLocker lock(this); diff --git a/src/corelib/global/qrandom_p.h b/src/corelib/global/qrandom_p.h index 917a91098e..167f4cc57d 100644 --- a/src/corelib/global/qrandom_p.h +++ b/src/corelib/global/qrandom_p.h @@ -76,7 +76,9 @@ Q_CORE_EXPORT QBasicAtomicInteger qt_randomdevice_control = Q_BASIC_ATOMIC #elif defined(QT_BUILD_INTERNAL) extern Q_CORE_EXPORT QBasicAtomicInteger qt_randomdevice_control; #else -enum { qt_randomdevice_control = 0 }; +static const struct { + uint loadAcquire() const { return 0; } +} qt_randomdevice_control; #endif inline bool qt_has_hwrng() diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 8f80be30bd..e3b25f8bf7 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -421,7 +421,7 @@ void QObjectPrivate::ConnectionData::cleanOrphanedConnectionsImpl(QObject *sende ConnectionOrSignalVector *c = nullptr; { QBasicMutexLocker l(signalSlotLock(sender)); - if (ref > 1) + if (ref.loadAcquire() > 1) return; // Since ref == 1, no activate() is in process since we locked the mutex. That implies, diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 1953aea21e..247c7b1501 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -279,7 +279,7 @@ public: void removeConnection(Connection *c); void cleanOrphanedConnections(QObject *sender) { - if (orphaned.loadRelaxed() && ref == 1) + if (orphaned.loadRelaxed() && ref.loadAcquire() == 1) cleanOrphanedConnectionsImpl(sender); } void cleanOrphanedConnectionsImpl(QObject *sender);