blob: 64853565e842613f357c60b93b225c671b43ede5 [file] [log] [blame]
Mischa Jonker19b18522012-11-04 01:16:14 +00001From d4d07dac01796b2aa0fb501c14865cab7e42b3a9 Mon Sep 17 00:00:00 2001
2From: Mischa Jonker <mischa.jonker@synopsys.com>
3Date: Sun, 4 Nov 2012 11:42:04 +0100
4Subject: [PATCH] Fix const-related build error in generic atomic ops
5
6It's still not entirely const-correct though. In all other architectures
7this is obfuscated through the use of inline asm (which the compiler
8doesn't check). This patch obfuscates through const_cast
9---
10 src/corelib/arch/generic/qatomic_generic_unix.cpp | 8 ++++----
11 src/corelib/arch/qatomic_generic.h | 2 +-
12 2 files changed, 5 insertions(+), 5 deletions(-)
13
14diff --git a/src/corelib/arch/generic/qatomic_generic_unix.cpp b/src/corelib/arch/generic/qatomic_generic_unix.cpp
15index 1c6cbf0..6fce81d 100644
16--- a/src/corelib/arch/generic/qatomic_generic_unix.cpp
17+++ b/src/corelib/arch/generic/qatomic_generic_unix.cpp
18@@ -85,13 +85,13 @@ int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd)
19
20 Q_CORE_EXPORT
21 bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value,
22- void *expectedValue,
23- void *newValue)
24+ const void *expectedValue,
25+ const void *newValue)
26 {
27 bool returnValue = false;
28 pthread_mutex_lock(&qAtomicMutex);
29 if (*_q_value == expectedValue) {
30- *_q_value = newValue;
31+ *_q_value = const_cast<void*>(newValue);
32 returnValue = true;
33 }
34 pthread_mutex_unlock(&qAtomicMutex);
35diff --git a/src/corelib/arch/qatomic_generic.h b/src/corelib/arch/qatomic_generic.h
36index 621a767..4c14679 100644
37--- a/src/corelib/arch/qatomic_generic.h
38+++ b/src/corelib/arch/qatomic_generic.h
39@@ -105,7 +105,7 @@ Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered(volatile int *, int, int);
40 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *, int);
41 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddOrdered(volatile int *, int);
42
43-Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *, void *, void *);
44+Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *, const void *, const void *);
45 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *, void *);
46 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *, qptrdiff);
47
48--
491.7.0.4
50