From 34fe9232dbf6a9fe58ebc4c7680bb67d2f642c40 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 10 Jun 2019 11:08:29 +0200 Subject: Port from QAtomic::load() to loadRelaxed() Semi-automated, just needed ~20 manual fixes: $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)load\(\)/$1loadRelaxed\(\)/g' -i \{\} + $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)store\(/$1storeRelaxed\(/g' -i \{\} + It can be easily improved (e.g. for store check that there are no commas after the opening parens). The most common offender is QLibrary::load, and some code using std::atomic directly. Change-Id: I07c38a3c8ed32c924ef4999e85c7e45cf48f0f6c Reviewed-by: Marc Mutz --- .../global/qglobalstatic/tst_qglobalstatic.cpp | 18 +- .../qrandomgenerator/tst_qrandomgenerator.cpp | 2 +- .../qcoreapplication/tst_qcoreapplication.cpp | 22 +-- .../corelib/kernel/qeventloop/tst_qeventloop.cpp | 6 +- .../corelib/kernel/qtranslator/tst_qtranslator.cpp | 2 +- .../corelib/thread/qatomicint/tst_qatomicint.cpp | 50 +++--- .../thread/qatomicinteger/tst_qatomicinteger.cpp | 194 ++++++++++----------- .../thread/qatomicpointer/tst_qatomicpointer.cpp | 176 +++++++++---------- tests/auto/corelib/thread/qmutex/tst_qmutex.cpp | 24 +-- .../thread/qreadwritelock/tst_qreadwritelock.cpp | 8 +- tests/auto/corelib/thread/qthread/tst_qthread.cpp | 10 +- .../corelib/thread/qthreadonce/tst_qthreadonce.cpp | 8 +- .../corelib/thread/qthreadpool/tst_qthreadpool.cpp | 76 ++++---- .../thread/qthreadstorage/tst_qthreadstorage.cpp | 12 +- .../thread/qwaitcondition/tst_qwaitcondition.cpp | 32 ++-- .../corelib/tools/qarraydata/tst_qarraydata.cpp | 36 ++-- .../qcontiguouscache/tst_qcontiguouscache.cpp | 2 +- .../tools/qscopedpointer/tst_qscopedpointer.cpp | 42 ++--- .../tools/qsharedpointer/tst_qsharedpointer.cpp | 86 ++++----- tests/auto/corelib/tools/qvector/tst_qvector.cpp | 2 +- 20 files changed, 404 insertions(+), 404 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp index 2d7db813dd..820a0b999b 100644 --- a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp +++ b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp @@ -145,7 +145,7 @@ void tst_QGlobalStatic::exception() exceptionCaught = true; } QVERIFY(exceptionCaught); - QCOMPARE(Q_QGS_throwingGS::guard.load(), 0); + QCOMPARE(Q_QGS_throwingGS::guard.loadRelaxed(), 0); QVERIFY(!throwingGS.exists()); QVERIFY(!throwingGS.isDestroyed()); } @@ -154,10 +154,10 @@ QBasicAtomicInt exceptionControlVar = Q_BASIC_ATOMIC_INITIALIZER(1); Q_GLOBAL_STATIC_WITH_ARGS(ThrowingType, exceptionGS, (exceptionControlVar)) void tst_QGlobalStatic::catchExceptionAndRetry() { - if (exceptionControlVar.load() != 1) + if (exceptionControlVar.loadRelaxed() != 1) QSKIP("This test cannot be run more than once"); - ThrowingType::constructedCount.store(0); - ThrowingType::destructedCount.store(0); + ThrowingType::constructedCount.storeRelaxed(0); + ThrowingType::destructedCount.storeRelaxed(0); bool exceptionCaught = false; try { @@ -165,11 +165,11 @@ void tst_QGlobalStatic::catchExceptionAndRetry() } catch (int) { exceptionCaught = true; } - QCOMPARE(ThrowingType::constructedCount.load(), 1); + QCOMPARE(ThrowingType::constructedCount.loadRelaxed(), 1); QVERIFY(exceptionCaught); exceptionGS(); - QCOMPARE(ThrowingType::constructedCount.load(), 2); + QCOMPARE(ThrowingType::constructedCount.loadRelaxed(), 2); } QBasicAtomicInt threadStressTestControlVar = Q_BASIC_ATOMIC_INITIALIZER(5); @@ -194,9 +194,9 @@ void tst_QGlobalStatic::threadStressTest() } }; - ThrowingType::constructedCount.store(0); - ThrowingType::destructedCount.store(0); - int expectedConstructionCount = threadStressTestControlVar.load() + 1; + ThrowingType::constructedCount.storeRelaxed(0); + ThrowingType::destructedCount.storeRelaxed(0); + int expectedConstructionCount = threadStressTestControlVar.loadRelaxed() + 1; if (expectedConstructionCount <= 0) QSKIP("This test cannot be run more than once"); diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp index 64557f1460..e238be1de3 100644 --- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp +++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp @@ -57,7 +57,7 @@ static const double RandomValueFP = double(0.3010463714599609); static void setRNGControl(uint v) { #ifdef QT_BUILD_INTERNAL - qt_randomdevice_control.store(v); + qt_randomdevice_control.storeRelaxed(v); #else Q_UNUSED(v); #endif diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index d68cefc807..39c90f69b4 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -775,49 +775,49 @@ private slots: QCoreApplicationPrivate *privateClass = static_cast(QObjectPrivate::get(qApp)); { - QCOMPARE(privateClass->quitLockRef.load(), 0); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 0); // Test with a lock active so that the refcount doesn't drop to zero during these tests, causing a quit. // (until we exit the scope) QEventLoopLocker locker; - QCOMPARE(privateClass->quitLockRef.load(), 1); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 1); JobObject *job1 = new JobObject(this); - QCOMPARE(privateClass->quitLockRef.load(), 2); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 2); delete job1; - QCOMPARE(privateClass->quitLockRef.load(), 1); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 1); job1 = new JobObject(this); - QCOMPARE(privateClass->quitLockRef.load(), 2); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 2); JobObject *job2 = new JobObject(this); - QCOMPARE(privateClass->quitLockRef.load(), 3); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 3); delete job1; - QCOMPARE(privateClass->quitLockRef.load(), 2); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 2); JobObject *job3 = new JobObject(job2); Q_UNUSED(job3); - QCOMPARE(privateClass->quitLockRef.load(), 3); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 3); JobObject *job4 = new JobObject(job2); Q_UNUSED(job4); - QCOMPARE(privateClass->quitLockRef.load(), 4); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 4); delete job2; - QCOMPARE(privateClass->quitLockRef.load(), 1); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 1); } - QCOMPARE(privateClass->quitLockRef.load(), 0); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 0); } }; diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp index 482ed8d130..1f0b8d4b4e 100644 --- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp @@ -638,16 +638,16 @@ void tst_QEventLoop::testQuitLock() QEventLoopPrivate* privateClass = static_cast(QObjectPrivate::get(&eventLoop)); - QCOMPARE(privateClass->quitLockRef.load(), 0); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 0); JobObject *job1 = new JobObject(&eventLoop, this); job1->start(500); - QCOMPARE(privateClass->quitLockRef.load(), 1); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 1); eventLoop.exec(); - QCOMPARE(privateClass->quitLockRef.load(), 0); + QCOMPARE(privateClass->quitLockRef.loadRelaxed(), 0); job1 = new JobObject(&eventLoop, this); diff --git a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp index 40a29c723c..b3efa97dbd 100644 --- a/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp +++ b/tests/auto/corelib/kernel/qtranslator/tst_qtranslator.cpp @@ -310,7 +310,7 @@ struct TranslateThread : public QThread void run() { bool startSignalled = false; - while (terminate.load() == 0) { + while (terminate.loadRelaxed() == 0) { const QString result = QCoreApplication::translate("QPushButton", "Hello %n world(s)!", 0, 0); if (!startSignalled) { diff --git a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp index 9b5a273131..bef491d5f0 100644 --- a/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp +++ b/tests/auto/corelib/thread/qatomicint/tst_qatomicint.cpp @@ -105,12 +105,12 @@ static void warningFreeHelperTemplate() assemblyMarker<1>(&i); // the loads sometimes generate no assembly output - i.load(); + i.loadRelaxed(); assemblyMarker<11>(&i); i.loadAcquire(); assemblyMarker<12>(&i); - i.store(newValue); + i.storeRelaxed(newValue); assemblyMarker<21>(&i); i.storeRelease(newValue); assemblyMarker<22>(&i); @@ -282,9 +282,9 @@ void tst_QAtomicInt::constructor() { QFETCH(int, value); QAtomicInt atomic1(value); - QCOMPARE(atomic1.load(), value); + QCOMPARE(atomic1.loadRelaxed(), value); QAtomicInt atomic2 = value; - QCOMPARE(atomic2.load(), value); + QCOMPARE(atomic2.loadRelaxed(), value); } void tst_QAtomicInt::copy_constructor_data() @@ -294,16 +294,16 @@ void tst_QAtomicInt::copy_constructor() { QFETCH(int, value); QAtomicInt atomic1(value); - QCOMPARE(atomic1.load(), value); + QCOMPARE(atomic1.loadRelaxed(), value); QAtomicInt atomic2(atomic1); - QCOMPARE(atomic2.load(), value); + QCOMPARE(atomic2.loadRelaxed(), value); QAtomicInt atomic3 = atomic1; - QCOMPARE(atomic3.load(), value); + QCOMPARE(atomic3.loadRelaxed(), value); QAtomicInt atomic4(atomic2); - QCOMPARE(atomic4.load(), value); + QCOMPARE(atomic4.loadRelaxed(), value); QAtomicInt atomic5 = atomic2; - QCOMPARE(atomic5.load(), value); + QCOMPARE(atomic5.loadRelaxed(), value); } void tst_QAtomicInt::assignment_operator_data() @@ -327,13 +327,13 @@ void tst_QAtomicInt::assignment_operator() { QAtomicInt atomic1 = value; atomic1 = newval; - QCOMPARE(atomic1.load(), newval); + QCOMPARE(atomic1.loadRelaxed(), newval); atomic1 = value; - QCOMPARE(atomic1.load(), value); + QCOMPARE(atomic1.loadRelaxed(), value); QAtomicInt atomic2 = newval; atomic1 = atomic2; - QCOMPARE(atomic1.load(), atomic2.load()); + QCOMPARE(atomic1.loadRelaxed(), atomic2.loadRelaxed()); } } @@ -401,7 +401,7 @@ void tst_QAtomicInt::ref() QFETCH(int, value); QAtomicInt x = value; QTEST(x.ref() ? 1 : 0, "result"); - QTEST(x.load(), "expected"); + QTEST(x.loadRelaxed(), "expected"); } void tst_QAtomicInt::deref_data() @@ -420,7 +420,7 @@ void tst_QAtomicInt::deref() QFETCH(int, value); QAtomicInt x = value; QTEST(x.deref() ? 1 : 0, "result"); - QTEST(x.load(), "expected"); + QTEST(x.loadRelaxed(), "expected"); } void tst_QAtomicInt::isTestAndSetNative() @@ -636,25 +636,25 @@ void tst_QAtomicInt::fetchAndStore() { QAtomicInt atomic = value; QCOMPARE(atomic.fetchAndStoreRelaxed(newval), value); - QCOMPARE(atomic.load(), newval); + QCOMPARE(atomic.loadRelaxed(), newval); } { QAtomicInt atomic = value; QCOMPARE(atomic.fetchAndStoreAcquire(newval), value); - QCOMPARE(atomic.load(), newval); + QCOMPARE(atomic.loadRelaxed(), newval); } { QAtomicInt atomic = value; QCOMPARE(atomic.fetchAndStoreRelease(newval), value); - QCOMPARE(atomic.load(), newval); + QCOMPARE(atomic.loadRelaxed(), newval); } { QAtomicInt atomic = value; QCOMPARE(atomic.fetchAndStoreOrdered(newval), value); - QCOMPARE(atomic.load(), newval); + QCOMPARE(atomic.loadRelaxed(), newval); } } @@ -773,28 +773,28 @@ void tst_QAtomicInt::fetchAndAdd() QAtomicInt atomic = value1; result = atomic.fetchAndAddRelaxed(value2); QCOMPARE(result, value1); - QCOMPARE(atomic.load(), value1 + value2); + QCOMPARE(atomic.loadRelaxed(), value1 + value2); } { QAtomicInt atomic = value1; result = atomic.fetchAndAddAcquire(value2); QCOMPARE(result, value1); - QCOMPARE(atomic.load(), value1 + value2); + QCOMPARE(atomic.loadRelaxed(), value1 + value2); } { QAtomicInt atomic = value1; result = atomic.fetchAndAddRelease(value2); QCOMPARE(result, value1); - QCOMPARE(atomic.load(), value1 + value2); + QCOMPARE(atomic.loadRelaxed(), value1 + value2); } { QAtomicInt atomic = value1; result = atomic.fetchAndAddOrdered(value2); QCOMPARE(result, value1); - QCOMPARE(atomic.load(), value1 + value2); + QCOMPARE(atomic.loadRelaxed(), value1 + value2); } } @@ -859,7 +859,7 @@ void tst_QAtomicInt::testAndSet_loop() QAtomicInt val=0; for (int i = 0; i < iterations; ++i) { - int v = val.load(); + int v = val.loadRelaxed(); QVERIFY(val.testAndSetRelaxed(v, v+1)); if ((i % 1000) == 999) { if (stopWatch.elapsed() > 60 * 1000) { @@ -882,7 +882,7 @@ void tst_QAtomicInt::fetchAndAdd_loop() QAtomicInt val=0; for (int i = 0; i < iterations; ++i) { const int prev = val.fetchAndAddRelaxed(1); - QCOMPARE(prev, val.load() -1); + QCOMPARE(prev, val.loadRelaxed() -1); } } @@ -920,7 +920,7 @@ void tst_QAtomicInt::fetchAndAdd_threadedLoop() t1.wait(); t2.wait(); - QCOMPARE(val.load(), 0); + QCOMPARE(val.loadRelaxed(), 0); } QTEST_MAIN(tst_QAtomicInt) diff --git a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp index 3a98732f9d..bfe2a60088 100644 --- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp +++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp @@ -270,13 +270,13 @@ void tst_QAtomicIntegerXX::constructor() QFETCH(LargeInt, value); QAtomicInteger atomic(value); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QAtomicInteger atomic2 = value; - QCOMPARE(atomic2.load(), T(value)); + QCOMPARE(atomic2.loadRelaxed(), T(value)); - QVERIFY(atomic.load() >= std::numeric_limits::min()); - QVERIFY(atomic.load() <= std::numeric_limits::max()); + QVERIFY(atomic.loadRelaxed() >= std::numeric_limits::min()); + QVERIFY(atomic.loadRelaxed() <= std::numeric_limits::max()); } void tst_QAtomicIntegerXX::copy() @@ -285,17 +285,17 @@ void tst_QAtomicIntegerXX::copy() QAtomicInteger atomic(value); QAtomicInteger copy(atomic); - QCOMPARE(copy.load(), atomic.load()); + QCOMPARE(copy.loadRelaxed(), atomic.loadRelaxed()); QAtomicInteger copy2 = atomic; - QCOMPARE(copy2.load(), atomic.load()); + QCOMPARE(copy2.loadRelaxed(), atomic.loadRelaxed()); // move QAtomicInteger copy3(std::move(copy)); - QCOMPARE(copy3.load(), atomic.load()); + QCOMPARE(copy3.loadRelaxed(), atomic.loadRelaxed()); QAtomicInteger copy4 = std::move(copy2); - QCOMPARE(copy4.load(), atomic.load()); + QCOMPARE(copy4.loadRelaxed(), atomic.loadRelaxed()); } void tst_QAtomicIntegerXX::assign() @@ -305,24 +305,24 @@ void tst_QAtomicIntegerXX::assign() QAtomicInteger atomic(value); QAtomicInteger copy; copy = atomic; - QCOMPARE(copy.load(), atomic.load()); + QCOMPARE(copy.loadRelaxed(), atomic.loadRelaxed()); QAtomicInteger copy2; copy2 = atomic; // operator=(const QAtomicInteger &) - QCOMPARE(copy2.load(), atomic.load()); + QCOMPARE(copy2.loadRelaxed(), atomic.loadRelaxed()); QAtomicInteger copy2bis; - copy2bis = atomic.load(); // operator=(T) - QCOMPARE(copy2bis.load(), atomic.load()); + copy2bis = atomic.loadRelaxed(); // operator=(T) + QCOMPARE(copy2bis.loadRelaxed(), atomic.loadRelaxed()); // move QAtomicInteger copy3; copy3 = std::move(copy); - QCOMPARE(copy3.load(), atomic.load()); + QCOMPARE(copy3.loadRelaxed(), atomic.loadRelaxed()); QAtomicInteger copy4; copy4 = std::move(copy2); - QCOMPARE(copy4.load(), atomic.load()); + QCOMPARE(copy4.loadRelaxed(), atomic.loadRelaxed()); } void tst_QAtomicIntegerXX::operatorInteger() @@ -331,7 +331,7 @@ void tst_QAtomicIntegerXX::operatorInteger() QAtomicInteger atomic(value); T val2 = atomic; - QCOMPARE(val2, atomic.load()); + QCOMPARE(val2, atomic.loadRelaxed()); QCOMPARE(val2, T(value)); } @@ -346,7 +346,7 @@ void tst_QAtomicIntegerXX::loadAcquireStoreRelease() QCOMPARE(atomic.loadAcquire(), T(~value)); atomic.storeRelease(value); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); } void tst_QAtomicIntegerXX::refDeref() @@ -364,16 +364,16 @@ void tst_QAtomicIntegerXX::refDeref() QAtomicInteger atomic(value); if (!needToPreventOverflow) { QCOMPARE(atomic.ref(), (nextValue != 0)); - QCOMPARE(atomic.load(), nextValue); + QCOMPARE(atomic.loadRelaxed(), nextValue); QCOMPARE(atomic.deref(), (value != 0)); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventUnderflow) { QCOMPARE(atomic.deref(), (prevValue != 0)); - QCOMPARE(atomic.load(), prevValue); + QCOMPARE(atomic.loadRelaxed(), prevValue); QCOMPARE(atomic.ref(), (value != 0)); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventOverflow) { QCOMPARE(++atomic, nextValue); @@ -392,7 +392,7 @@ void tst_QAtomicIntegerXX::refDeref() QCOMPARE(atomic--, T(value)); QCOMPARE(atomic++, prevValue); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); } void tst_QAtomicIntegerXX::testAndSet() @@ -402,16 +402,16 @@ void tst_QAtomicIntegerXX::testAndSet() QAtomicInteger atomic(value); QVERIFY(atomic.testAndSetRelaxed(value, newValue)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QVERIFY(!atomic.testAndSetRelaxed(value, newValue)); QVERIFY(atomic.testAndSetRelaxed(newValue, value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QVERIFY(atomic.testAndSetAcquire(value, newValue)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QVERIFY(!atomic.testAndSetAcquire(value, newValue)); QVERIFY(atomic.testAndSetAcquire(newValue, value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QVERIFY(atomic.testAndSetRelease(value, newValue)); QCOMPARE(atomic.loadAcquire(), newValue); @@ -434,18 +434,18 @@ void tst_QAtomicIntegerXX::testAndSet3() QAtomicInteger atomic(value); QVERIFY(atomic.testAndSetRelaxed(value, newValue, oldValue)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QVERIFY(!atomic.testAndSetRelaxed(value, newValue, oldValue)); QCOMPARE(oldValue, newValue); QVERIFY(atomic.testAndSetRelaxed(newValue, value, oldValue)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QVERIFY(atomic.testAndSetAcquire(value, newValue, oldValue)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QVERIFY(!atomic.testAndSetAcquire(value, newValue, oldValue)); QCOMPARE(oldValue, newValue); QVERIFY(atomic.testAndSetAcquire(newValue, value, oldValue)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QVERIFY(atomic.testAndSetRelease(value, newValue, oldValue)); QCOMPARE(atomic.loadAcquire(), newValue); @@ -469,14 +469,14 @@ void tst_QAtomicIntegerXX::fetchAndStore() QAtomicInteger atomic(value); QCOMPARE(atomic.fetchAndStoreRelaxed(newValue), T(value)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QCOMPARE(atomic.fetchAndStoreRelaxed(value), newValue); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndStoreAcquire(newValue), T(value)); - QCOMPARE(atomic.load(), newValue); + QCOMPARE(atomic.loadRelaxed(), newValue); QCOMPARE(atomic.fetchAndStoreAcquire(value), newValue); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndStoreRelease(newValue), T(value)); QCOMPARE(atomic.loadAcquire(), newValue); @@ -509,29 +509,29 @@ void tst_QAtomicIntegerXX::fetchAndAdd() if (!needToPreventOverflow) { QCOMPARE(atomic.fetchAndAddRelaxed(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); + QCOMPARE(atomic.loadRelaxed(), newValue1); QCOMPARE(atomic.fetchAndAddRelaxed(parcel2), newValue1); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventUnderflow) { QCOMPARE(atomic.fetchAndAddRelaxed(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); + QCOMPARE(atomic.loadRelaxed(), newValue2); QCOMPARE(atomic.fetchAndAddRelaxed(parcel1), newValue2); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventOverflow) { QCOMPARE(atomic.fetchAndAddAcquire(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); + QCOMPARE(atomic.loadRelaxed(), newValue1); QCOMPARE(atomic.fetchAndAddAcquire(parcel2), newValue1); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventUnderflow) { QCOMPARE(atomic.fetchAndAddAcquire(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); + QCOMPARE(atomic.loadRelaxed(), newValue2); QCOMPARE(atomic.fetchAndAddAcquire(parcel1), newValue2); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventOverflow) { QCOMPARE(atomic.fetchAndAddRelease(parcel1), T(value)); @@ -590,29 +590,29 @@ void tst_QAtomicIntegerXX::fetchAndSub() if (!needToPreventUnderflow) { QCOMPARE(atomic.fetchAndSubRelaxed(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); + QCOMPARE(atomic.loadRelaxed(), newValue1); QCOMPARE(atomic.fetchAndSubRelaxed(parcel2), newValue1); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventOverflow) { QCOMPARE(atomic.fetchAndSubRelaxed(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); + QCOMPARE(atomic.loadRelaxed(), newValue2); QCOMPARE(atomic.fetchAndSubRelaxed(parcel1), newValue2); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventUnderflow) { QCOMPARE(atomic.fetchAndSubAcquire(parcel1), T(value)); - QCOMPARE(atomic.load(), newValue1); + QCOMPARE(atomic.loadRelaxed(), newValue1); QCOMPARE(atomic.fetchAndSubAcquire(parcel2), newValue1); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventOverflow) { QCOMPARE(atomic.fetchAndSubAcquire(parcel2), T(value)); - QCOMPARE(atomic.load(), newValue2); + QCOMPARE(atomic.loadRelaxed(), newValue2); QCOMPARE(atomic.fetchAndSubAcquire(parcel1), newValue2); } - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); if (!needToPreventUnderflow) { QCOMPARE(atomic.fetchAndSubRelease(parcel1), T(value)); @@ -662,32 +662,32 @@ void tst_QAtomicIntegerXX::fetchAndOr() QCOMPARE(atomic.fetchAndOrRelaxed(zero), T(value)); QCOMPARE(atomic.fetchAndOrRelaxed(one), T(value)); - QCOMPARE(atomic.load(), T(value | 1)); + QCOMPARE(atomic.loadRelaxed(), T(value | 1)); QCOMPARE(atomic.fetchAndOrRelaxed(minusOne), T(value | 1)); - QCOMPARE(atomic.load(), minusOne); + QCOMPARE(atomic.loadRelaxed(), minusOne); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndOrAcquire(zero), T(value)); QCOMPARE(atomic.fetchAndOrAcquire(one), T(value)); - QCOMPARE(atomic.load(), T(value | 1)); + QCOMPARE(atomic.loadRelaxed(), T(value | 1)); QCOMPARE(atomic.fetchAndOrAcquire(minusOne), T(value | 1)); - QCOMPARE(atomic.load(), minusOne); + QCOMPARE(atomic.loadRelaxed(), minusOne); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndOrRelease(zero), T(value)); QCOMPARE(atomic.fetchAndOrRelease(one), T(value)); - QCOMPARE(atomic.load(), T(value | 1)); + QCOMPARE(atomic.loadRelaxed(), T(value | 1)); QCOMPARE(atomic.fetchAndOrRelease(minusOne), T(value | 1)); - QCOMPARE(atomic.load(), minusOne); + QCOMPARE(atomic.loadRelaxed(), minusOne); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndOrOrdered(zero), T(value)); QCOMPARE(atomic.fetchAndOrOrdered(one), T(value)); - QCOMPARE(atomic.load(), T(value | 1)); + QCOMPARE(atomic.loadRelaxed(), T(value | 1)); QCOMPARE(atomic.fetchAndOrOrdered(minusOne), T(value | 1)); - QCOMPARE(atomic.load(), minusOne); + QCOMPARE(atomic.loadRelaxed(), minusOne); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic |= zero, T(value)); QCOMPARE(atomic |= one, T(value | 1)); QCOMPARE(atomic |= minusOne, minusOne); @@ -703,37 +703,37 @@ void tst_QAtomicIntegerXX::fetchAndAnd() T minusOne = T(~0); QCOMPARE(atomic.fetchAndAndRelaxed(minusOne), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndAndRelaxed(f), T(value)); - QCOMPARE(atomic.load(), T(value & 0xf)); + QCOMPARE(atomic.loadRelaxed(), T(value & 0xf)); QCOMPARE(atomic.fetchAndAndRelaxed(zero), T(value & 0xf)); - QCOMPARE(atomic.load(), zero); + QCOMPARE(atomic.loadRelaxed(), zero); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndAndAcquire(minusOne), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndAndAcquire(f), T(value)); - QCOMPARE(atomic.load(), T(value & 0xf)); + QCOMPARE(atomic.loadRelaxed(), T(value & 0xf)); QCOMPARE(atomic.fetchAndAndAcquire(zero), T(value & 0xf)); - QCOMPARE(atomic.load(), zero); + QCOMPARE(atomic.loadRelaxed(), zero); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndAndRelease(minusOne), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndAndRelease(f), T(value)); - QCOMPARE(atomic.load(), T(value & 0xf)); + QCOMPARE(atomic.loadRelaxed(), T(value & 0xf)); QCOMPARE(atomic.fetchAndAndRelease(zero), T(value & 0xf)); - QCOMPARE(atomic.load(), zero); + QCOMPARE(atomic.loadRelaxed(), zero); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic.fetchAndAndOrdered(minusOne), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndAndOrdered(f), T(value)); - QCOMPARE(atomic.load(), T(value & 0xf)); + QCOMPARE(atomic.loadRelaxed(), T(value & 0xf)); QCOMPARE(atomic.fetchAndAndOrdered(zero), T(value & 0xf)); - QCOMPARE(atomic.load(), zero); + QCOMPARE(atomic.loadRelaxed(), zero); - atomic.store(value); + atomic.storeRelaxed(value); QCOMPARE(atomic &= minusOne, T(value)); QCOMPARE(atomic &= f, T(value & 0xf)); QCOMPARE(atomic &= zero, zero); @@ -749,48 +749,48 @@ void tst_QAtomicIntegerXX::fetchAndXor() T minusOne = T(~0); QCOMPARE(atomic.fetchAndXorRelaxed(zero), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorRelaxed(pattern), T(value)); - QCOMPARE(atomic.load(), T(value ^ pattern)); + QCOMPARE(atomic.loadRelaxed(), T(value ^ pattern)); QCOMPARE(atomic.fetchAndXorRelaxed(pattern), T(value ^ pattern)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorRelaxed(minusOne), T(value)); - QCOMPARE(atomic.load(), T(~value)); + QCOMPARE(atomic.loadRelaxed(), T(~value)); QCOMPARE(atomic.fetchAndXorRelaxed(minusOne), T(~value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorAcquire(zero), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorAcquire(pattern), T(value)); - QCOMPARE(atomic.load(), T(value ^ pattern)); + QCOMPARE(atomic.loadRelaxed(), T(value ^ pattern)); QCOMPARE(atomic.fetchAndXorAcquire(pattern), T(value ^ pattern)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorAcquire(minusOne), T(value)); - QCOMPARE(atomic.load(), T(~value)); + QCOMPARE(atomic.loadRelaxed(), T(~value)); QCOMPARE(atomic.fetchAndXorAcquire(minusOne), T(~value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorRelease(zero), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorRelease(pattern), T(value)); - QCOMPARE(atomic.load(), T(value ^ pattern)); + QCOMPARE(atomic.loadRelaxed(), T(value ^ pattern)); QCOMPARE(atomic.fetchAndXorRelease(pattern), T(value ^ pattern)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorRelease(minusOne), T(value)); - QCOMPARE(atomic.load(), T(~value)); + QCOMPARE(atomic.loadRelaxed(), T(~value)); QCOMPARE(atomic.fetchAndXorRelease(minusOne), T(~value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorOrdered(zero), T(value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorOrdered(pattern), T(value)); - QCOMPARE(atomic.load(), T(value ^ pattern)); + QCOMPARE(atomic.loadRelaxed(), T(value ^ pattern)); QCOMPARE(atomic.fetchAndXorOrdered(pattern), T(value ^ pattern)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic.fetchAndXorOrdered(minusOne), T(value)); - QCOMPARE(atomic.load(), T(~value)); + QCOMPARE(atomic.loadRelaxed(), T(~value)); QCOMPARE(atomic.fetchAndXorOrdered(minusOne), T(~value)); - QCOMPARE(atomic.load(), T(value)); + QCOMPARE(atomic.loadRelaxed(), T(value)); QCOMPARE(atomic ^= zero, T(value)); QCOMPARE(atomic ^= pattern, T(value ^ pattern)); diff --git a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp index 0200473cae..a699cf6202 100644 --- a/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp +++ b/tests/auto/corelib/thread/qatomicpointer/tst_qatomicpointer.cpp @@ -75,7 +75,7 @@ void tst_QAtomicPointer::warningFreeHelper() QBasicAtomicPointer p = Q_BASIC_ATOMIC_INITIALIZER(0); - p.load()->bar(); + p.loadRelaxed()->bar(); WFHC *expectedValue = 0; WFHC *newValue = 0; @@ -119,15 +119,15 @@ void tst_QAtomicPointer::constructor() { void *one = this; QAtomicPointer atomic1 = one; - QCOMPARE(atomic1.load(), one); + QCOMPARE(atomic1.loadRelaxed(), one); void *two = &one; QAtomicPointer atomic2 = two; - QCOMPARE(atomic2.load(), two); + QCOMPARE(atomic2.loadRelaxed(), two); void *three = &two; QAtomicPointer atomic3 = three; - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic3.loadRelaxed(), three); } void tst_QAtomicPointer::copy_constructor() @@ -135,20 +135,20 @@ void tst_QAtomicPointer::copy_constructor() void *one = this; QAtomicPointer atomic1 = one; QAtomicPointer atomic1_copy = atomic1; - QCOMPARE(atomic1_copy.load(), one); - QCOMPARE(atomic1_copy.load(), atomic1.load()); + QCOMPARE(atomic1_copy.loadRelaxed(), one); + QCOMPARE(atomic1_copy.loadRelaxed(), atomic1.loadRelaxed()); void *two = &one; QAtomicPointer atomic2 = two; QAtomicPointer atomic2_copy = atomic2; - QCOMPARE(atomic2_copy.load(), two); - QCOMPARE(atomic2_copy.load(), atomic2.load()); + QCOMPARE(atomic2_copy.loadRelaxed(), two); + QCOMPARE(atomic2_copy.loadRelaxed(), atomic2.loadRelaxed()); void *three = &two; QAtomicPointer atomic3 = three; QAtomicPointer atomic3_copy = atomic3; - QCOMPARE(atomic3_copy.load(), three); - QCOMPARE(atomic3_copy.load(), atomic3.load()); + QCOMPARE(atomic3_copy.loadRelaxed(), three); + QCOMPARE(atomic3_copy.loadRelaxed(), atomic3.loadRelaxed()); } void tst_QAtomicPointer::assignment_operator() @@ -161,17 +161,17 @@ void tst_QAtomicPointer::assignment_operator() QAtomicPointer atomic2 = two; QAtomicPointer atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); atomic1 = two; atomic2 = three; atomic3 = one; - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } void tst_QAtomicPointer::isTestAndSetNative() @@ -234,17 +234,17 @@ void tst_QAtomicPointer::testAndSet() QAtomicPointer atomic2 = two; QAtomicPointer atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QVERIFY(atomic1.testAndSetRelaxed(one, two)); QVERIFY(atomic2.testAndSetRelaxed(two, three)); QVERIFY(atomic3.testAndSetRelaxed(three, one)); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -252,17 +252,17 @@ void tst_QAtomicPointer::testAndSet() QAtomicPointer atomic2 = two; QAtomicPointer atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QVERIFY(atomic1.testAndSetAcquire(one, two)); QVERIFY(atomic2.testAndSetAcquire(two, three)); QVERIFY(atomic3.testAndSetAcquire(three, one)); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -270,17 +270,17 @@ void tst_QAtomicPointer::testAndSet() QAtomicPointer atomic2 = two; QAtomicPointer atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QVERIFY(atomic1.testAndSetRelease(one, two)); QVERIFY(atomic2.testAndSetRelease(two, three)); QVERIFY(atomic3.testAndSetRelease(three, one)); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -288,17 +288,17 @@ void tst_QAtomicPointer::testAndSet() QAtomicPointer atomic2 = two; QAtomicPointer atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QVERIFY(atomic1.testAndSetOrdered(one, two)); QVERIFY(atomic2.testAndSetOrdered(two, three)); QVERIFY(atomic3.testAndSetOrdered(three, one)); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } } @@ -362,17 +362,17 @@ void tst_QAtomicPointer::fetchAndStore() QAtomicPointer atomic2 = two; QAtomicPointer atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QCOMPARE(atomic1.fetchAndStoreRelaxed(two), one); QCOMPARE(atomic2.fetchAndStoreRelaxed(three), two); QCOMPARE(atomic3.fetchAndStoreRelaxed(one), three); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -380,17 +380,17 @@ void tst_QAtomicPointer::fetchAndStore() QAtomicPointer atomic2 = two; QAtomicPointer atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QCOMPARE(atomic1.fetchAndStoreAcquire(two), one); QCOMPARE(atomic2.fetchAndStoreAcquire(three), two); QCOMPARE(atomic3.fetchAndStoreAcquire(one), three); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -398,17 +398,17 @@ void tst_QAtomicPointer::fetchAndStore() QAtomicPointer atomic2 = two; QAtomicPointer atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QCOMPARE(atomic1.fetchAndStoreRelease(two), one); QCOMPARE(atomic2.fetchAndStoreRelease(three), two); QCOMPARE(atomic3.fetchAndStoreRelease(one), three); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } { @@ -416,17 +416,17 @@ void tst_QAtomicPointer::fetchAndStore() QAtomicPointer atomic2 = two; QAtomicPointer atomic3 = three; - QCOMPARE(atomic1.load(), one); - QCOMPARE(atomic2.load(), two); - QCOMPARE(atomic3.load(), three); + QCOMPARE(atomic1.loadRelaxed(), one); + QCOMPARE(atomic2.loadRelaxed(), two); + QCOMPARE(atomic3.loadRelaxed(), three); QCOMPARE(atomic1.fetchAndStoreOrdered(two), one); QCOMPARE(atomic2.fetchAndStoreOrdered(three), two); QCOMPARE(atomic3.fetchAndStoreOrdered(one), three); - QCOMPARE(atomic1.load(), two); - QCOMPARE(atomic2.load(), three); - QCOMPARE(atomic3.load(), one); + QCOMPARE(atomic1.loadRelaxed(), two); + QCOMPARE(atomic2.loadRelaxed(), three); + QCOMPARE(atomic3.loadRelaxed(), one); } } @@ -530,60 +530,60 @@ void tst_QAtomicPointer::fetchAndAdd() // cast to void* in order to avoid QCOMPARE to compare string content of the char* QCOMPARE(static_cast(pointer1.fetchAndAddRelaxed(valueToAdd)), static_cast(pc)); QCOMPARE(static_cast(pointer1.fetchAndAddRelaxed(-valueToAdd)), static_cast(pc + valueToAdd)); - QCOMPARE(static_cast(pointer1.load()), static_cast(pc)); + QCOMPARE(static_cast(pointer1.loadRelaxed()), static_cast(pc)); QAtomicPointer pointer2 = ps; QCOMPARE(pointer2.fetchAndAddRelaxed(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddRelaxed(-valueToAdd), ps + valueToAdd); - QCOMPARE(pointer2.load(), ps); + QCOMPARE(pointer2.loadRelaxed(), ps); QAtomicPointer pointer3 = pi; QCOMPARE(pointer3.fetchAndAddRelaxed(valueToAdd), pi); QCOMPARE(pointer3.fetchAndAddRelaxed(-valueToAdd), pi + valueToAdd); - QCOMPARE(pointer3.load(), pi); + QCOMPARE(pointer3.loadRelaxed(), pi); } { QAtomicPointer pointer1 = pc; QCOMPARE(static_cast(pointer1.fetchAndAddAcquire(valueToAdd)), static_cast(pc)); QCOMPARE(static_cast(pointer1.fetchAndAddAcquire(-valueToAdd)), static_cast(pc + valueToAdd)); - QCOMPARE(static_cast(pointer1.load()), static_cast(pc)); + QCOMPARE(static_cast(pointer1.loadRelaxed()), static_cast(pc)); QAtomicPointer pointer2 = ps; QCOMPARE(pointer2.fetchAndAddAcquire(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddAcquire(-valueToAdd), ps + valueToAdd); - QCOMPARE(pointer2.load(), ps); + QCOMPARE(pointer2.loadRelaxed(), ps); QAtomicPointer pointer3 = pi; QCOMPARE(pointer3.fetchAndAddAcquire(valueToAdd), pi); QCOMPARE(pointer3.fetchAndAddAcquire(-valueToAdd), pi + valueToAdd); - QCOMPARE(pointer3.load(), pi); + QCOMPARE(pointer3.loadRelaxed(), pi); } { QAtomicPointer pointer1 = pc; QCOMPARE(static_cast(pointer1.fetchAndAddRelease(valueToAdd)), static_cast(pc)); QCOMPARE(static_cast(pointer1.fetchAndAddRelease(-valueToAdd)), static_cast(pc + valueToAdd)); - QCOMPARE(static_cast(pointer1.load()), static_cast(pc)); + QCOMPARE(static_cast(pointer1.loadRelaxed()), static_cast(pc)); QAtomicPointer pointer2 = ps; QCOMPARE(pointer2.fetchAndAddRelease(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddRelease(-valueToAdd), ps + valueToAdd); - QCOMPARE(pointer2.load(), ps); + QCOMPARE(pointer2.loadRelaxed(), ps); QAtomicPointer pointer3 = pi; QCOMPARE(pointer3.fetchAndAddRelease(valueToAdd), pi); QCOMPARE(pointer3.fetchAndAddRelease(-valueToAdd), pi + valueToAdd); - QCOMPARE(pointer3.load(), pi); + QCOMPARE(pointer3.loadRelaxed(), pi); } { QAtomicPointer pointer1 = pc; QCOMPARE(static_cast(pointer1.fetchAndAddOrdered(valueToAdd)), static_cast(pc)); QCOMPARE(static_cast(pointer1.fetchAndAddOrdered(-valueToAdd)), static_cast(pc + valueToAdd)); - QCOMPARE(static_cast(pointer1.load()), static_cast(pc)); + QCOMPARE(static_cast(pointer1.loadRelaxed()), static_cast(pc)); QAtomicPointer pointer2 = ps; QCOMPARE(pointer2.fetchAndAddOrdered(valueToAdd), ps); QCOMPARE(pointer2.fetchAndAddOrdered(-valueToAdd), ps + valueToAdd); - QCOMPARE(pointer2.load(), ps); + QCOMPARE(pointer2.loadRelaxed(), ps); QAtomicPointer pointer3 = pi; QCOMPARE(pointer3.fetchAndAddOrdered(valueToAdd), pi); QCOMPARE(pointer3.fetchAndAddOrdered(-valueToAdd), pi + valueToAdd); - QCOMPARE(pointer3.load(), pi); + QCOMPARE(pointer3.loadRelaxed(), pi); } } @@ -598,34 +598,34 @@ template void constAndVolatile_helper() QAtomicPointer atomic2 = two; QAtomicPointer atomic3 = three; - QVERIFY(atomic1.load() == one); - QVERIFY(atomic2.load() == two); - QVERIFY(atomic3.load() == three); + QVERIFY(atomic1.loadRelaxed() == one); + QVERIFY(atomic2.loadRelaxed() == two); + QVERIFY(atomic3.loadRelaxed() == three); QVERIFY(atomic1.fetchAndStoreRelaxed(two) == one); QVERIFY(atomic2.fetchAndStoreRelaxed(three) == two); QVERIFY(atomic3.fetchAndStoreRelaxed(one) == three); - QVERIFY(atomic1.load() == two); - QVERIFY(atomic2.load() == three); - QVERIFY(atomic3.load() == one); + QVERIFY(atomic1.loadRelaxed() == two); + QVERIFY(atomic2.loadRelaxed() == three); + QVERIFY(atomic3.loadRelaxed() == one); } { QAtomicPointer atomic1 = one; QAtomicPointer atomic2 = two; QAtomicPointer atomic3 = three; - QVERIFY(atomic1.load() == one); - QVERIFY(atomic2.load() == two); - QVERIFY(atomic3.load() == three); + QVERIFY(atomic1.loadRelaxed() == one); + QVERIFY(atomic2.loadRelaxed() == two); + QVERIFY(atomic3.loadRelaxed() == three); QVERIFY(atomic1.testAndSetRelaxed(one, two)); QVERIFY(atomic2.testAndSetRelaxed(two, three)); QVERIFY(atomic3.testAndSetRelaxed(three, one)); - QVERIFY(atomic1.load() == two); - QVERIFY(atomic2.load() == three); - QVERIFY(atomic3.load() == one); + QVERIFY(atomic1.loadRelaxed() == two); + QVERIFY(atomic2.loadRelaxed() == three); + QVERIFY(atomic3.loadRelaxed() == one); } } diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp index 7fb9a861d7..37c5874c02 100644 --- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp @@ -1132,7 +1132,7 @@ void tst_QMutex::stressTest() for (int i = 1; i < threadCount; ++i) QVERIFY(threads[i].wait(10000)); QCOMPARE(StressTestThread::errorCount, 0); - qDebug("locked %d times", int(StressTestThread::lockCount.load())); + qDebug("locked %d times", int(StressTestThread::lockCount.loadRelaxed())); } class TryLockRaceThread : public QThread @@ -1286,28 +1286,28 @@ public: quint64 i = 0; while (t.elapsed() < one_minute) { i++; - uint nb = (i * 9 + lockCount.load() * 13) % threadCount; + uint nb = (i * 9 + lockCount.loadRelaxed() * 13) % threadCount; QMutexLocker locker(&mutex[nb]); - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); if (sentinel[nb].fetchAndAddRelaxed(5)) errorCount.ref(); if (!sentinel[nb].testAndSetRelaxed(5, 0)) errorCount.ref(); - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); lockCount.ref(); - nb = (nb * 17 + i * 5 + lockCount.load() * 3) % threadCount; + nb = (nb * 17 + i * 5 + lockCount.loadRelaxed() * 3) % threadCount; if (mutex[nb].tryLock()) { - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); if (sentinel[nb].fetchAndAddRelaxed(16)) errorCount.ref(); if (!sentinel[nb].testAndSetRelaxed(16, 0)) errorCount.ref(); - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); lockCount.ref(); mutex[nb].unlock(); } - nb = (nb * 15 + i * 47 + lockCount.load() * 31) % threadCount; + nb = (nb * 15 + i * 47 + lockCount.loadRelaxed() * 31) % threadCount; if (mutex[nb].tryLock(2)) { - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); if (sentinel[nb].fetchAndAddRelaxed(53)) errorCount.ref(); if (!sentinel[nb].testAndSetRelaxed(53, 0)) errorCount.ref(); - if (sentinel[nb].load()) errorCount.ref(); + if (sentinel[nb].loadRelaxed()) errorCount.ref(); lockCount.ref(); mutex[nb].unlock(); } @@ -1327,8 +1327,8 @@ void tst_QMutex::moreStress() QVERIFY(threads[0].wait(one_minute + 10000)); for (int i = 1; i < threadCount; ++i) QVERIFY(threads[i].wait(10000)); - qDebug("locked %d times", MoreStressTestThread::lockCount.load()); - QCOMPARE(MoreStressTestThread::errorCount.load(), 0); + qDebug("locked %d times", MoreStressTestThread::lockCount.loadRelaxed()); + QCOMPARE(MoreStressTestThread::errorCount.loadRelaxed(), 0); } diff --git a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp index 45fcf9657d..47bae585a1 100644 --- a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp +++ b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp @@ -458,7 +458,7 @@ public: void run() { testRwlock.lockForWrite(); - while(release.load()==false) { + while (release.loadRelaxed() == false) { RWTESTSLEEP } testRwlock.unlock(); @@ -478,7 +478,7 @@ public: void run() { testRwlock.lockForRead(); - while(release.load()==false) { + while (release.loadRelaxed() == false) { RWTESTSLEEP } testRwlock.unlock(); @@ -677,7 +677,7 @@ void tst_QReadWriteLock::multipleReadersBlockRelease() { QReadWriteLock testLock; - release.store(false); + release.storeRelaxed(false); threadDone=false; ReadLockReleasableThread rlt1(testLock); ReadLockReleasableThread rlt2(testLock); @@ -687,7 +687,7 @@ void tst_QReadWriteLock::multipleReadersBlockRelease() WriteLockThread wlt(testLock); wlt.start(); sleep(1); - release.store(true); + release.storeRelaxed(true); wlt.wait(); rlt1.wait(); rlt2.wait(); diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 19922b1ea5..baec4a22a5 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -121,7 +121,7 @@ public: { } bool wasActivated() - { return activationCount.load() > 0; } + { return activationCount.loadRelaxed() > 0; } public slots: void slot(); @@ -900,7 +900,7 @@ void tst_QThread::adoptMultipleThreads() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(recorder.activationCount.load(), numThreads); + QCOMPARE(recorder.activationCount.loadRelaxed(), numThreads); } void tst_QThread::adoptMultipleThreadsOverlap() @@ -937,7 +937,7 @@ void tst_QThread::adoptMultipleThreadsOverlap() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(recorder.activationCount.load(), numThreads); + QCOMPARE(recorder.activationCount.loadRelaxed(), numThreads); } // Disconnects on WinCE @@ -1208,7 +1208,7 @@ class DummyEventDispatcher : public QAbstractEventDispatcher { public: DummyEventDispatcher() : QAbstractEventDispatcher() {} bool processEvents(QEventLoop::ProcessEventsFlags) { - visited.store(true); + visited.storeRelaxed(true); emit awake(); QCoreApplication::sendPostedEvents(); return false; @@ -1270,7 +1270,7 @@ void tst_QThread::customEventDispatcher() QMetaObject::invokeMethod(&obj, "visit", Qt::QueuedConnection); loop.exec(); // test that the ED has really been used - QVERIFY(ed->visited.load()); + QVERIFY(ed->visited.loadRelaxed()); QPointer weak_ed(ed); QVERIFY(!weak_ed.isNull()); diff --git a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp index a9af182ed8..710288af9e 100644 --- a/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp +++ b/tests/auto/corelib/thread/qthreadonce/tst_qthreadonce.cpp @@ -56,7 +56,7 @@ class SingletonObject: public QObject Q_OBJECT public: static int runCount; - SingletonObject() { val.store(42); ++runCount; } + SingletonObject() { val.storeRelaxed(42); ++runCount; } ~SingletonObject() { } QBasicAtomicInt val; @@ -112,7 +112,7 @@ void tst_QThreadOnce::sameThread() QCOMPARE(controlVariable, 1); static QSingleton s; - QTEST((int)s->val.load(), "expectedValue"); + QTEST((int)s->val.loadRelaxed(), "expectedValue"); s->val.ref(); QCOMPARE(SingletonObject::runCount, 1); @@ -134,7 +134,7 @@ void tst_QThreadOnce::multipleThreads() QCOMPARE(controlVariable, 0); // nothing must have set them yet SingletonObject::runCount = 0; - IncrementThread::runCount.store(0); + IncrementThread::runCount.storeRelaxed(0); // wait for all of them to be ready sem2.acquire(NumberOfThreads); @@ -145,7 +145,7 @@ void tst_QThreadOnce::multipleThreads() delete parent; QCOMPARE(controlVariable, 1); - QCOMPARE((int)IncrementThread::runCount.load(), NumberOfThreads); + QCOMPARE((int)IncrementThread::runCount.loadRelaxed(), NumberOfThreads); QCOMPARE(SingletonObject::runCount, 1); } diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index f41cbe2601..112c36952c 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -220,16 +220,16 @@ class TestTask : public QRunnable public: void run() { - ran.store(true); + ran.storeRelaxed(true); } }; void tst_QThreadPool::runTask() { QThreadPool manager; - ran.store(false); + ran.storeRelaxed(false); manager.start(new TestTask()); - QTRY_VERIFY(ran.load()); + QTRY_VERIFY(ran.loadRelaxed()); } /* @@ -237,9 +237,9 @@ void tst_QThreadPool::runTask() */ void tst_QThreadPool::singleton() { - ran.store(false); + ran.storeRelaxed(false); QThreadPool::globalInstance()->start(new TestTask()); - QTRY_VERIFY(ran.load()); + QTRY_VERIFY(ran.loadRelaxed()); } QAtomicInt *value = 0; @@ -344,7 +344,7 @@ void tst_QThreadPool::expiryTimeout() // run the task threadPool.start(&task); QVERIFY(task.semaphore.tryAcquire(1, 10000)); - QCOMPARE(task.runCount.load(), 1); + QCOMPARE(task.runCount.loadRelaxed(), 1); QVERIFY(!task.thread->wait(100)); // thread should expire QThread *firstThread = task.thread; @@ -353,7 +353,7 @@ void tst_QThreadPool::expiryTimeout() // run task again, thread should be restarted threadPool.start(&task); QVERIFY(task.semaphore.tryAcquire(1, 10000)); - QCOMPARE(task.runCount.load(), 2); + QCOMPARE(task.runCount.loadRelaxed(), 2); QVERIFY(!task.thread->wait(100)); // thread should expire again QVERIFY(task.thread->wait(10000)); @@ -382,7 +382,7 @@ void tst_QThreadPool::expiryTimeoutRace() // QTBUG-3786 QThread::msleep(50); // exactly the same as the expiry timeout } QVERIFY(task.semaphore.tryAcquire(numTasks, 10000)); - QCOMPARE(task.runCount.load(), numTasks); + QCOMPARE(task.runCount.loadRelaxed(), numTasks); QVERIFY(threadPool.waitForDone(2000)); } @@ -685,7 +685,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051 QCOMPARE(threadpool->activeThreadCount(), 2); task->waitForStarted.acquire(); task->waitBeforeDone.release(); - QTRY_COMPARE(task->count.load(), 1); + QTRY_COMPARE(task->count.loadRelaxed(), 1); QTRY_COMPARE(threadpool->activeThreadCount(), 1); // now the thread is waiting, but tryStart() will fail since activeThreadCount() >= maxThreadCount() @@ -698,7 +698,7 @@ void tst_QThreadPool::reserveAndStart() // QTBUG-21051 QTRY_COMPARE(threadpool->activeThreadCount(), 2); task->waitForStarted.acquire(); task->waitBeforeDone.release(); - QTRY_COMPARE(task->count.load(), 2); + QTRY_COMPARE(task->count.loadRelaxed(), 2); QTRY_COMPARE(threadpool->activeThreadCount(), 1); threadpool->releaseThread(); @@ -721,14 +721,14 @@ class CountingRunnable : public QRunnable void tst_QThreadPool::start() { const int runs = 1000; - count.store(0); + count.storeRelaxed(0); { QThreadPool threadPool; for (int i = 0; i< runs; ++i) { threadPool.start(new CountingRunnable()); } } - QCOMPARE(count.load(), runs); + QCOMPARE(count.loadRelaxed(), runs); } void tst_QThreadPool::tryStart() @@ -747,7 +747,7 @@ void tst_QThreadPool::tryStart() } }; - count.store(0); + count.storeRelaxed(0); WaitingTask task; QThreadPool threadPool; @@ -757,7 +757,7 @@ void tst_QThreadPool::tryStart() QVERIFY(!threadPool.tryStart(&task)); task.semaphore.release(threadPool.maxThreadCount()); threadPool.waitForDone(); - QCOMPARE(count.load(), threadPool.maxThreadCount()); + QCOMPARE(count.loadRelaxed(), threadPool.maxThreadCount()); } QMutex mutex; @@ -775,7 +775,7 @@ void tst_QThreadPool::tryStartPeakThreadCount() { QMutexLocker lock(&mutex); activeThreads.ref(); - peakActiveThreads.store(qMax(peakActiveThreads.load(), activeThreads.load())); + peakActiveThreads.storeRelaxed(qMax(peakActiveThreads.loadRelaxed(), activeThreads.loadRelaxed())); } QTest::qWait(100); @@ -793,13 +793,13 @@ void tst_QThreadPool::tryStartPeakThreadCount() if (threadPool.tryStart(&task) == false) QTest::qWait(10); } - QCOMPARE(peakActiveThreads.load(), QThread::idealThreadCount()); + QCOMPARE(peakActiveThreads.loadRelaxed(), QThread::idealThreadCount()); for (int i = 0; i < 20; ++i) { if (threadPool.tryStart(&task) == false) QTest::qWait(10); } - QCOMPARE(peakActiveThreads.load(), QThread::idealThreadCount()); + QCOMPARE(peakActiveThreads.loadRelaxed(), QThread::idealThreadCount()); } void tst_QThreadPool::tryStartCount() @@ -877,7 +877,7 @@ void tst_QThreadPool::priorityStart() sem.release(); QVERIFY(threadPool.waitForDone()); - QCOMPARE(firstStarted.load(), expected); + QCOMPARE(firstStarted.loadRelaxed(), expected); } void tst_QThreadPool::waitForDone() @@ -888,16 +888,16 @@ void tst_QThreadPool::waitForDone() QThreadPool threadPool; while (total.elapsed() < 10000) { int runs; - count.store(runs = 0); + count.storeRelaxed(runs = 0); pass.restart(); while (pass.elapsed() < 100) { threadPool.start(new CountingRunnable()); ++runs; } threadPool.waitForDone(); - QCOMPARE(count.load(), runs); + QCOMPARE(count.loadRelaxed(), runs); - count.store(runs = 0); + count.storeRelaxed(runs = 0); pass.restart(); while (pass.elapsed() < 100) { threadPool.start(new CountingRunnable()); @@ -905,7 +905,7 @@ void tst_QThreadPool::waitForDone() runs += 2; } threadPool.waitForDone(); - QCOMPARE(count.load(), runs); + QCOMPARE(count.loadRelaxed(), runs); } } @@ -953,14 +953,14 @@ void tst_QThreadPool::clear() QThreadPool threadPool; threadPool.setMaxThreadCount(10); int runs = 2 * threadPool.maxThreadCount(); - count.store(0); + count.storeRelaxed(0); for (int i = 0; i <= runs; i++) { threadPool.start(new BlockingRunnable(sem)); } threadPool.clear(); sem.release(threadPool.maxThreadCount()); threadPool.waitForDone(); - QCOMPARE(count.load(), threadPool.maxThreadCount()); + QCOMPARE(count.loadRelaxed(), threadPool.maxThreadCount()); } void tst_QThreadPool::cancel() @@ -1008,7 +1008,7 @@ void tst_QThreadPool::cancel() // and cause an early return: const QSemaphoreReleaser semReleaser(sem, runs); - count.store(0); + count.storeRelaxed(0); QAtomicInt dtorCounter = 0; QAtomicInt runCounter = 0; for (int i = 0; i < runs; i++) { @@ -1025,12 +1025,12 @@ void tst_QThreadPool::cancel() } runnables[0]->dummy = 0; //valgrind will catch this if cancel() is crazy enough to delete currently running jobs runnables[runs-1]->dummy = 0; - QCOMPARE(dtorCounter.load(), runs - threadPool.maxThreadCount() - 1); + QCOMPARE(dtorCounter.loadRelaxed(), runs - threadPool.maxThreadCount() - 1); sem.release(threadPool.maxThreadCount()); threadPool.waitForDone(); - QCOMPARE(runCounter.load(), threadPool.maxThreadCount()); - QCOMPARE(count.load(), threadPool.maxThreadCount()); - QCOMPARE(dtorCounter.load(), runs - 2); + QCOMPARE(runCounter.loadRelaxed(), threadPool.maxThreadCount()); + QCOMPARE(count.loadRelaxed(), threadPool.maxThreadCount()); + QCOMPARE(dtorCounter.loadRelaxed(), runs - 2); delete runnables[0]; //if the pool deletes them then we'll get double-free crash delete runnables[runs-1]; } @@ -1080,7 +1080,7 @@ void tst_QThreadPool::tryTake() // and cause an early return: const QSemaphoreReleaser semReleaser(sem, Runs); - count.store(0); + count.storeRelaxed(0); QAtomicInt dtorCounter = 0; QAtomicInt runCounter = 0; for (int i = 0; i < Runs; i++) { @@ -1102,12 +1102,12 @@ void tst_QThreadPool::tryTake() } runnables[0]->dummy = 0; // valgrind will catch this if tryTake() is crazy enough to delete currently running jobs - QCOMPARE(dtorCounter.load(), int(Runs - MaxThreadCount)); + QCOMPARE(dtorCounter.loadRelaxed(), int(Runs - MaxThreadCount)); sem.release(MaxThreadCount); threadPool.waitForDone(); - QCOMPARE(runCounter.load(), int(MaxThreadCount)); - QCOMPARE(count.load(), int(MaxThreadCount)); - QCOMPARE(dtorCounter.load(), int(Runs - 1)); + QCOMPARE(runCounter.loadRelaxed(), int(MaxThreadCount)); + QCOMPARE(count.loadRelaxed(), int(MaxThreadCount)); + QCOMPARE(dtorCounter.loadRelaxed(), int(Runs - 1)); delete runnables[0]; // if the pool deletes them then we'll get double-free crash } @@ -1118,7 +1118,7 @@ void tst_QThreadPool::destroyingWaitsForTasksToFinish() while (total.elapsed() < 10000) { int runs; - count.store(runs = 0); + count.storeRelaxed(runs = 0); { QThreadPool threadPool; pass.restart(); @@ -1127,9 +1127,9 @@ void tst_QThreadPool::destroyingWaitsForTasksToFinish() ++runs; } } - QCOMPARE(count.load(), runs); + QCOMPARE(count.loadRelaxed(), runs); - count.store(runs = 0); + count.storeRelaxed(runs = 0); { QThreadPool threadPool; pass.restart(); @@ -1139,7 +1139,7 @@ void tst_QThreadPool::destroyingWaitsForTasksToFinish() runs += 2; } } - QCOMPARE(count.load(), runs); + QCOMPARE(count.loadRelaxed(), runs); } } diff --git a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp index ef5d3452d5..3538d90803 100644 --- a/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp +++ b/tests/auto/corelib/thread/qthreadstorage/tst_qthreadstorage.cpp @@ -359,7 +359,7 @@ void tst_QThreadStorage::leakInDestructor() QVERIFY(tls.hasLocalData()); } }; - int c = SPointer::count.load(); + int c = SPointer::count.loadRelaxed(); QThreadStorage tls; @@ -383,7 +383,7 @@ void tst_QThreadStorage::leakInDestructor() QVERIFY(t3.wait()); //check all the constructed things have been destructed - QCOMPARE(int(SPointer::count.load()), c); + QCOMPARE(int(SPointer::count.loadRelaxed()), c); } class ThreadStorageResetLocalDataTester { @@ -411,7 +411,7 @@ void tst_QThreadStorage::resetInDestructor() QVERIFY(ThreadStorageResetLocalDataTesterTls()->hasLocalData()); } }; - int c = SPointer::count.load(); + int c = SPointer::count.loadRelaxed(); Thread t1; Thread t2; @@ -424,7 +424,7 @@ void tst_QThreadStorage::resetInDestructor() QVERIFY(t3.wait()); //check all the constructed things have been destructed - QCOMPARE(int(SPointer::count.load()), c); + QCOMPARE(int(SPointer::count.loadRelaxed()), c); } @@ -475,7 +475,7 @@ void tst_QThreadStorage::valueBased() QThreadStorage tlsString; QThreadStorage tlsInt; - int c = SPointer::count.load(); + int c = SPointer::count.loadRelaxed(); Thread t1(tlsSPointer, tlsString, tlsInt); Thread t2(tlsSPointer, tlsString, tlsInt); @@ -495,7 +495,7 @@ void tst_QThreadStorage::valueBased() QVERIFY(t2.wait()); QVERIFY(t3.wait()); - QCOMPARE(c, int(SPointer::count.load())); + QCOMPARE(c, int(SPointer::count.loadRelaxed())); } diff --git a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp index 126cb6b180..5363231895 100644 --- a/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp +++ b/tests/auto/corelib/thread/qwaitcondition/tst_qwaitcondition.cpp @@ -481,7 +481,7 @@ void tst_QWaitCondition::wakeOne() } mutex.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up threads one at a time for (x = 0; x < ThreadCount; ++x) { @@ -502,10 +502,10 @@ void tst_QWaitCondition::wakeOne() } QCOMPARE(exited, 1); - QCOMPARE(count.load(), ThreadCount - (x + 1)); + QCOMPARE(count.loadRelaxed(), ThreadCount - (x + 1)); } - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); // QReadWriteLock QReadWriteLock readWriteLock; @@ -530,7 +530,7 @@ void tst_QWaitCondition::wakeOne() } readWriteLock.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up threads one at a time for (x = 0; x < ThreadCount; ++x) { @@ -551,10 +551,10 @@ void tst_QWaitCondition::wakeOne() } QCOMPARE(exited, 1); - QCOMPARE(count.load(), ThreadCount - (x + 1)); + QCOMPARE(count.loadRelaxed(), ThreadCount - (x + 1)); } - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); } // wake up threads, two at a time @@ -585,7 +585,7 @@ void tst_QWaitCondition::wakeOne() } mutex.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up threads one at a time for (x = 0; x < ThreadCount; x += 2) { @@ -608,10 +608,10 @@ void tst_QWaitCondition::wakeOne() } QCOMPARE(exited, 2); - QCOMPARE(count.load(), ThreadCount - (x + 2)); + QCOMPARE(count.loadRelaxed(), ThreadCount - (x + 2)); } - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); // QReadWriteLock QReadWriteLock readWriteLock; @@ -636,7 +636,7 @@ void tst_QWaitCondition::wakeOne() } readWriteLock.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up threads one at a time for (x = 0; x < ThreadCount; x += 2) { @@ -659,10 +659,10 @@ void tst_QWaitCondition::wakeOne() } QCOMPARE(exited, 2); - QCOMPARE(count.load(), ThreadCount - (x + 2)); + QCOMPARE(count.loadRelaxed(), ThreadCount - (x + 2)); } - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); } } @@ -692,7 +692,7 @@ void tst_QWaitCondition::wakeAll() } mutex.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up all threads at once mutex.lock(); @@ -707,7 +707,7 @@ void tst_QWaitCondition::wakeAll() } QCOMPARE(exited, ThreadCount); - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); // QReadWriteLock QReadWriteLock readWriteLock; @@ -728,7 +728,7 @@ void tst_QWaitCondition::wakeAll() } readWriteLock.unlock(); - QCOMPARE(count.load(), ThreadCount); + QCOMPARE(count.loadRelaxed(), ThreadCount); // wake up all threads at once readWriteLock.lockForWrite(); @@ -743,7 +743,7 @@ void tst_QWaitCondition::wakeAll() } QCOMPARE(exited, ThreadCount); - QCOMPARE(count.load(), 0); + QCOMPARE(count.loadRelaxed(), 0); } } diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 6ae2aab5b9..7db7d71b1f 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -91,7 +91,7 @@ void tst_QArrayData::referenceCounting() // Reference counting initialized to 1 (owned) QArrayData array = { { Q_BASIC_ATOMIC_INITIALIZER(1) }, 0, 0, 0, 0 }; - QCOMPARE(array.ref.atomic.load(), 1); + QCOMPARE(array.ref.atomic.loadRelaxed(), 1); QVERIFY(!array.ref.isStatic()); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) @@ -99,19 +99,19 @@ void tst_QArrayData::referenceCounting() #endif QVERIFY(array.ref.ref()); - QCOMPARE(array.ref.atomic.load(), 2); + QCOMPARE(array.ref.atomic.loadRelaxed(), 2); QVERIFY(array.ref.deref()); - QCOMPARE(array.ref.atomic.load(), 1); + QCOMPARE(array.ref.atomic.loadRelaxed(), 1); QVERIFY(array.ref.ref()); - QCOMPARE(array.ref.atomic.load(), 2); + QCOMPARE(array.ref.atomic.loadRelaxed(), 2); QVERIFY(array.ref.deref()); - QCOMPARE(array.ref.atomic.load(), 1); + QCOMPARE(array.ref.atomic.loadRelaxed(), 1); QVERIFY(!array.ref.deref()); - QCOMPARE(array.ref.atomic.load(), 0); + QCOMPARE(array.ref.atomic.loadRelaxed(), 0); // Now would be a good time to free/release allocated data } @@ -121,17 +121,17 @@ void tst_QArrayData::referenceCounting() // Reference counting initialized to 0 (non-sharable) QArrayData array = { { Q_BASIC_ATOMIC_INITIALIZER(0) }, 0, 0, 0, 0 }; - QCOMPARE(array.ref.atomic.load(), 0); + QCOMPARE(array.ref.atomic.loadRelaxed(), 0); QVERIFY(!array.ref.isStatic()); QVERIFY(!array.ref.isSharable()); QVERIFY(!array.ref.ref()); // Reference counting fails, data should be copied - QCOMPARE(array.ref.atomic.load(), 0); + QCOMPARE(array.ref.atomic.loadRelaxed(), 0); QVERIFY(!array.ref.deref()); - QCOMPARE(array.ref.atomic.load(), 0); + QCOMPARE(array.ref.atomic.loadRelaxed(), 0); // Free/release data } @@ -141,7 +141,7 @@ void tst_QArrayData::referenceCounting() // Reference counting initialized to -1 (static read-only data) QArrayData array = { Q_REFCOUNT_INITIALIZE_STATIC, 0, 0, 0, 0 }; - QCOMPARE(array.ref.atomic.load(), -1); + QCOMPARE(array.ref.atomic.loadRelaxed(), -1); QVERIFY(array.ref.isStatic()); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) @@ -149,10 +149,10 @@ void tst_QArrayData::referenceCounting() #endif QVERIFY(array.ref.ref()); - QCOMPARE(array.ref.atomic.load(), -1); + QCOMPARE(array.ref.atomic.loadRelaxed(), -1); QVERIFY(array.ref.deref()); - QCOMPARE(array.ref.atomic.load(), -1); + QCOMPARE(array.ref.atomic.loadRelaxed(), -1); } } @@ -168,8 +168,8 @@ void tst_QArrayData::sharedNullEmpty() QVERIFY(empty->ref.isStatic()); QVERIFY(empty->ref.isShared()); - QCOMPARE(null->ref.atomic.load(), -1); - QCOMPARE(empty->ref.atomic.load(), -1); + QCOMPARE(null->ref.atomic.loadRelaxed(), -1); + QCOMPARE(empty->ref.atomic.loadRelaxed(), -1); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(null->ref.isSharable()); @@ -179,14 +179,14 @@ void tst_QArrayData::sharedNullEmpty() QVERIFY(null->ref.ref()); QVERIFY(empty->ref.ref()); - QCOMPARE(null->ref.atomic.load(), -1); - QCOMPARE(empty->ref.atomic.load(), -1); + QCOMPARE(null->ref.atomic.loadRelaxed(), -1); + QCOMPARE(empty->ref.atomic.loadRelaxed(), -1); QVERIFY(null->ref.deref()); QVERIFY(empty->ref.deref()); - QCOMPARE(null->ref.atomic.load(), -1); - QCOMPARE(empty->ref.atomic.load(), -1); + QCOMPARE(null->ref.atomic.loadRelaxed(), -1); + QCOMPARE(empty->ref.atomic.loadRelaxed(), -1); QVERIFY(null != empty); diff --git a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp index 9b45e17a28..f305d63d46 100644 --- a/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp +++ b/tests/auto/corelib/tools/qcontiguouscache/tst_qcontiguouscache.cpp @@ -244,7 +244,7 @@ public: return *this; } - int refCount() const { return d->ref.load(); } + int refCount() const { return d->ref.loadRelaxed(); } private: RefCountingClassData *d; }; diff --git a/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp index b943b04e23..ea94cc2999 100644 --- a/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/corelib/tools/qscopedpointer/tst_qscopedpointer.cpp @@ -327,7 +327,7 @@ struct RefCounted ~RefCounted() { - QVERIFY( ref.load() == 0 ); + QVERIFY( ref.loadRelaxed() == 0 ); instanceCount.deref(); } @@ -369,13 +369,13 @@ void scopedPointerComparisonTest(const A1 &a1, const A2 &a2, const B &b) void tst_QScopedPointer::comparison() { - QCOMPARE( RefCounted::instanceCount.load(), 0 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 0 ); { RefCounted *a = new RefCounted; RefCounted *b = new RefCounted; - QCOMPARE( RefCounted::instanceCount.load(), 2 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 2 ); QScopedPointer pa1(a); QScopedPointer pa2(a); @@ -387,16 +387,16 @@ void tst_QScopedPointer::comparison() pa2.take(); - QCOMPARE( RefCounted::instanceCount.load(), 2 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 2 ); } - QCOMPARE( RefCounted::instanceCount.load(), 0 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 0 ); { RefCounted *a = new RefCounted[42]; RefCounted *b = new RefCounted[43]; - QCOMPARE( RefCounted::instanceCount.load(), 85 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 85 ); QScopedArrayPointer pa1(a); QScopedArrayPointer pa2(a); @@ -406,10 +406,10 @@ void tst_QScopedPointer::comparison() pa2.take(); - QCOMPARE( RefCounted::instanceCount.load(), 85 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 85 ); } - QCOMPARE( RefCounted::instanceCount.load(), 0 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 0 ); { // QScopedSharedPointer is an internal helper class -- it is unsupported! @@ -417,42 +417,42 @@ void tst_QScopedPointer::comparison() RefCounted *a = new RefCounted; RefCounted *b = new RefCounted; - QCOMPARE( RefCounted::instanceCount.load(), 2 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 2 ); QSharedDataPointer pa1(a); QSharedDataPointer pa2(a); QSharedDataPointer pb(b); - QCOMPARE( a->ref.load(), 2 ); - QCOMPARE( b->ref.load(), 1 ); - QCOMPARE( RefCounted::instanceCount.load(), 2 ); + QCOMPARE( a->ref.loadRelaxed(), 2 ); + QCOMPARE( b->ref.loadRelaxed(), 1 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 2 ); scopedPointerComparisonTest(pa1, pa2, pb); - QCOMPARE( RefCounted::instanceCount.load(), 2 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 2 ); } - QCOMPARE( RefCounted::instanceCount.load(), 0 ); + QCOMPARE( RefCounted::instanceCount.loadRelaxed(), 0 ); } void tst_QScopedPointer::array() { - int instCount = RefCounted::instanceCount.load(); + int instCount = RefCounted::instanceCount.loadRelaxed(); { QScopedArrayPointer array; array.reset(new RefCounted[42]); - QCOMPARE(instCount + 42, RefCounted::instanceCount.load()); + QCOMPARE(instCount + 42, RefCounted::instanceCount.loadRelaxed()); } - QCOMPARE(instCount, RefCounted::instanceCount.load()); + QCOMPARE(instCount, RefCounted::instanceCount.loadRelaxed()); { QScopedArrayPointer array(new RefCounted[42]); - QCOMPARE(instCount + 42, RefCounted::instanceCount.load()); + QCOMPARE(instCount + 42, RefCounted::instanceCount.loadRelaxed()); array.reset(new RefCounted[28]); - QCOMPARE(instCount + 28, RefCounted::instanceCount.load()); + QCOMPARE(instCount + 28, RefCounted::instanceCount.loadRelaxed()); array.reset(0); - QCOMPARE(instCount, RefCounted::instanceCount.load()); + QCOMPARE(instCount, RefCounted::instanceCount.loadRelaxed()); } - QCOMPARE(instCount, RefCounted::instanceCount.load()); + QCOMPARE(instCount, RefCounted::instanceCount.loadRelaxed()); } diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index d0bc237a5d..187b73eeec 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -294,8 +294,8 @@ void tst_QSharedPointer::basics() QVERIFY(! (ptr == otherData)); QVERIFY(! (otherData == ptr)); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); { // create another object: @@ -307,8 +307,8 @@ void tst_QSharedPointer::basics() // otherData is deleted here } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); { // create a copy: @@ -325,8 +325,8 @@ void tst_QSharedPointer::basics() QCOMPARE(copy.get(), aData); QVERIFY(copy == aData); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); { // create a weak reference: @@ -358,8 +358,8 @@ void tst_QSharedPointer::basics() QCOMPARE(strong.data(), aData); QCOMPARE(strong.get(), aData); } - QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.load() == 1); - QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.load() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref.loadRelaxed() == 1); + QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref.loadRelaxed() == 1); // aData is deleted here } @@ -843,15 +843,15 @@ void tst_QSharedPointer::upCast() QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer derivedptr = qWeakPointerCast(baseptr); QVERIFY(baseptr == derivedptr); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer weakptr = baseptr; @@ -859,16 +859,16 @@ void tst_QSharedPointer::upCast() QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer derivedptr = baseptr.staticCast(); QVERIFY(baseptr == derivedptr); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } class OtherObject: public QObject @@ -1297,8 +1297,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer weakptr = baseptr; @@ -1307,8 +1307,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); @@ -1316,8 +1316,8 @@ void tst_QSharedPointer::dynamicCast() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } void tst_QSharedPointer::dynamicCastDifferentPointers() @@ -1332,8 +1332,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer weakptr = baseptr; @@ -1342,8 +1342,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); @@ -1351,8 +1351,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { Stuffing *nakedptr = dynamic_cast(baseptr.data()); @@ -1377,8 +1377,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QWeakPointer weakptr = baseptr; @@ -1387,8 +1387,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); @@ -1396,8 +1396,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase() QCOMPARE(derivedptr.data(), aData); QCOMPARE(static_cast(derivedptr.data()), baseptr.data()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } void tst_QSharedPointer::dynamicCastFailure() @@ -1409,15 +1409,15 @@ void tst_QSharedPointer::dynamicCastFailure() QSharedPointer derivedptr = qSharedPointerDynamicCast(baseptr); QVERIFY(derivedptr.isNull()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); { QSharedPointer derivedptr = baseptr.dynamicCast(); QVERIFY(derivedptr.isNull()); } - QCOMPARE(int(refCountData(baseptr)->weakref.load()), 1); - QCOMPARE(int(refCountData(baseptr)->strongref.load()), 1); + QCOMPARE(int(refCountData(baseptr)->weakref.loadRelaxed()), 1); + QCOMPARE(int(refCountData(baseptr)->strongref.loadRelaxed()), 1); } void tst_QSharedPointer::dynamicCastFailureNoLeak() @@ -1786,8 +1786,8 @@ void tst_QSharedPointer::creating() QCOMPARE(Data::destructorCounter, 1); // valgrind will complain here if something happened to the pointer - QVERIFY(d->weakref.load() == 1); - QVERIFY(d->strongref.load() == 0); + QVERIFY(d->weakref.loadRelaxed() == 1); + QVERIFY(d->strongref.loadRelaxed() == 0); } safetyCheck(); @@ -2022,7 +2022,7 @@ void tst_QSharedPointer::threadStressTest() for (int r = 0; r < 5; ++r) { QVector allThreads(6 * qMax(strongThreadCount, weakThreadCount) + 3, 0); QSharedPointer base = QSharedPointer(new ThreadData(&counter)); - counter.store(0); + counter.storeRelaxed(0); // set the pointers for (int i = 0; i < strongThreadCount; ++i) { @@ -2056,8 +2056,8 @@ void tst_QSharedPointer::threadStressTest() // verify that the count is the right range int minValue = strongThreadCount; int maxValue = strongThreadCount + weakThreadCount; - QVERIFY(counter.load() >= minValue); - QVERIFY(counter.load() <= maxValue); + QVERIFY(counter.loadRelaxed() >= minValue); + QVERIFY(counter.loadRelaxed() <= maxValue); } } diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 11c255b184..3256130472 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -2882,7 +2882,7 @@ void tst_QVector::detachThreadSafety() const struct : QThread { void run() override { - QVector copy(*detachThreadSafetyData()->load()); + QVector copy(*detachThreadSafetyData()->loadRelaxed()); QVERIFY(!copy.isDetached()); detachThreadSafetyLock.release(); detachThreadSafetyLock.acquire(100); -- cgit v1.2.3