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/qatomicpointer/tst_qatomicpointer.cpp | |
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/qatomicpointer/tst_qatomicpointer.cpp')
-rw-r--r-- | tests/auto/qatomicpointer/tst_qatomicpointer.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/qatomicpointer/tst_qatomicpointer.cpp b/tests/auto/qatomicpointer/tst_qatomicpointer.cpp index b9636a0..c1e0efd 100644 --- a/tests/auto/qatomicpointer/tst_qatomicpointer.cpp +++ b/tests/auto/qatomicpointer/tst_qatomicpointer.cpp @@ -58,6 +58,8 @@ public: ~tst_QAtomicPointer(); private slots: + void warningFree(); + void constructor(); void copy_constructor(); void equality_operator(); @@ -78,6 +80,9 @@ private slots: void isFetchAndAddWaitFree(); void fetchAndAdd_data(); void fetchAndAdd(); + +private: + static void warningFreeHelper(); }; tst_QAtomicPointer::tst_QAtomicPointer() @@ -86,6 +91,49 @@ tst_QAtomicPointer::tst_QAtomicPointer() tst_QAtomicPointer::~tst_QAtomicPointer() { } +struct WFHC +{ + void bar() {} +}; + +void tst_QAtomicPointer::warningFreeHelper() +{ + Q_ASSERT(false); + // The code below is bogus, and shouldn't be run. We're looking for warnings, only. + + QBasicAtomicPointer<WFHC> p = Q_BASIC_ATOMIC_INITIALIZER(0); + + p->bar(); + + WFHC *expectedValue = 0; + WFHC *newValue = 0; + qptrdiff valueToAdd = 0; + + p.testAndSetRelaxed(expectedValue, newValue); + p.testAndSetAcquire(expectedValue, newValue); + p.testAndSetRelease(expectedValue, newValue); + p.testAndSetOrdered(expectedValue, newValue); + + p.fetchAndStoreRelaxed(newValue); + p.fetchAndStoreAcquire(newValue); + p.fetchAndStoreRelease(newValue); + p.fetchAndStoreOrdered(newValue); + + p.fetchAndAddRelaxed(valueToAdd); + p.fetchAndAddAcquire(valueToAdd); + p.fetchAndAddRelease(valueToAdd); + p.fetchAndAddOrdered(valueToAdd); +} + +void tst_QAtomicPointer::warningFree() +{ + // This is a compile time check for warnings. + // No need for actual work here. + + void (*foo)() = &warningFreeHelper; + (void)foo; +} + void tst_QAtomicPointer::constructor() { void *one = this; |