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 /src/corelib/thread | |
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 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qbasicatomic.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index e96b4d2..629fb3d 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -56,7 +56,13 @@ public: #ifdef QT_ARCH_PARISC int _q_lock[4]; #endif +#if defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE) + union { // needed for Q_BASIC_ATOMIC_INITIALIZER + volatile long _q_value; + }; +#else volatile int _q_value; +#endif // Non-atomic API inline bool operator==(int value) const @@ -128,7 +134,14 @@ public: #ifdef QT_ARCH_PARISC int _q_lock[4]; #endif +#if defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE) + union { + T * volatile _q_value; + long volatile _q_value_integral; + }; +#else T * volatile _q_value; +#endif // Non-atomic API inline bool operator==(T *value) const @@ -194,6 +207,8 @@ public: #ifdef QT_ARCH_PARISC # define Q_BASIC_ATOMIC_INITIALIZER(a) {{-1,-1,-1,-1},(a)} +#elif defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE) +# define Q_BASIC_ATOMIC_INITIALIZER(a) { {(a)} } #else # define Q_BASIC_ATOMIC_INITIALIZER(a) { (a) } #endif |