summaryrefslogtreecommitdiff
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-08-31 17:05:51 +0200
committerJoão Abecasis <joao@abecasis.name>2009-08-31 18:15:45 +0200
commite70980b2aacbc758a0cd1e2246633278f7c505ab (patch)
treeee19500748f62181afbf424438c6ff03d12d7912 /src/corelib/thread
parent06a4cdba05e4865d02a09a5633c31c462ac00014 (diff)
downloadqt4-tools-e70980b2aacbc758a0cd1e2246633278f7c505ab.tar.gz
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.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h
index e96b4d26e7..629fb3d81d 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