diff options
author | João Abecasis <joao@abecasis.name> | 2009-08-31 15:05:51 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-08-31 16:15:45 (GMT) |
commit | e70980b2aacbc758a0cd1e2246633278f7c505ab (patch) | |
tree | ee19500748f62181afbf424438c6ff03d12d7912 /tests/auto/qatomicint | |
parent | 06a4cdba05e4865d02a09a5633c31c462ac00014 (diff) | |
download | Qt-e70980b2aacbc758a0cd1e2246633278f7c505ab.zip Qt-e70980b2aacbc758a0cd1e2246633278f7c505ab.tar.gz Qt-e70980b2aacbc758a0cd1e2246633278f7c505ab.tar.bz2 |
Refactoring qatomic_windows.h
Consolidated Interlocked* declarations and API implementation through
macro hackery, (hopefully) for improved readability and maintainability.
Fixes anti-aliasing warnings with MinGW in qatomic_windows.h. Gcc
builds now use inline assembly for atomic operations, instead of relying
on Interlocked* functions which aren't consistently declared across
implementations (mingw32, mingw-w64, wine... others?).
Drops support for VC 6 and MetroWerks.
Reviewed-by: Thiago Macieira
Diffstat (limited to 'tests/auto/qatomicint')
-rw-r--r-- | tests/auto/qatomicint/tst_qatomicint.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/qatomicint/tst_qatomicint.cpp b/tests/auto/qatomicint/tst_qatomicint.cpp index c3ea31d..5fde633 100644 --- a/tests/auto/qatomicint/tst_qatomicint.cpp +++ b/tests/auto/qatomicint/tst_qatomicint.cpp @@ -59,6 +59,8 @@ public: ~tst_QAtomicInt(); private slots: + void warningFree(); + // QAtomicInt members void constructor_data(); void constructor(); @@ -101,6 +103,9 @@ private slots: void testAndSet_loop(); void fetchAndAdd_loop(); void fetchAndAdd_threadedLoop(); + +private: + static void warningFreeHelper(); }; tst_QAtomicInt::tst_QAtomicInt() @@ -109,6 +114,45 @@ tst_QAtomicInt::tst_QAtomicInt() tst_QAtomicInt::~tst_QAtomicInt() { } +void tst_QAtomicInt::warningFreeHelper() +{ + Q_ASSERT(false); + // The code below is bogus, and shouldn't be run. We're looking for warnings, only. + + QBasicAtomicInt i = Q_BASIC_ATOMIC_INITIALIZER(0); + + int expectedValue = 0; + int newValue = 0; + int valueToAdd = 0; + + i.ref(); + i.deref(); + + i.testAndSetRelaxed(expectedValue, newValue); + i.testAndSetAcquire(expectedValue, newValue); + i.testAndSetRelease(expectedValue, newValue); + i.testAndSetOrdered(expectedValue, newValue); + + i.fetchAndStoreRelaxed(newValue); + i.fetchAndStoreAcquire(newValue); + i.fetchAndStoreRelease(newValue); + i.fetchAndStoreOrdered(newValue); + + i.fetchAndAddRelaxed(valueToAdd); + i.fetchAndAddAcquire(valueToAdd); + i.fetchAndAddRelease(valueToAdd); + i.fetchAndAddOrdered(valueToAdd); +} + +void tst_QAtomicInt::warningFree() +{ + // This is a compile time check for warnings. + // No need for actual work here. + + void (*foo)() = &warningFreeHelper; + (void)foo; +} + void tst_QAtomicInt::constructor_data() { QTest::addColumn<int>("value"); |