diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-06-26 07:56:49 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-06-28 00:24:10 +0200 |
commit | 5220b40edd52ea70ed3a09f9a28fa7fe50ce71e6 (patch) | |
tree | 4bdd731901e9352ea302fafd2f6413cb84ec9750 /src/corelib/global/qrandom.cpp | |
parent | e36e32c21312eee42194815da82203648023a67b (diff) |
Port from implicit to explicit atomic integer operations
The old code used the implicit conversions from QAtomicInteger<T> to T
and vice versa. The semantics of these differ from the ones std::atomic
uses, so we're going to deprecate these, like we did for load() and
store(), too.
This patch fixex some users of these APIs before we deprecate them.
Change-Id: I4877276581757cd57e042efea8296fe535a493d1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qrandom.cpp')
-rw-r--r-- | src/corelib/global/qrandom.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
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<quint32 *>(buffer); quint32 *end = static_cast<quint32 *>(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); |