Mischa Jonker | 19b1852 | 2012-11-04 01:16:14 +0000 | [diff] [blame] | 1 | From d4d07dac01796b2aa0fb501c14865cab7e42b3a9 Mon Sep 17 00:00:00 2001 |
| 2 | From: Mischa Jonker <mischa.jonker@synopsys.com> |
| 3 | Date: Sun, 4 Nov 2012 11:42:04 +0100 |
| 4 | Subject: [PATCH] Fix const-related build error in generic atomic ops |
| 5 | |
| 6 | It's still not entirely const-correct though. In all other architectures |
| 7 | this is obfuscated through the use of inline asm (which the compiler |
| 8 | doesn'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 | |
| 14 | diff --git a/src/corelib/arch/generic/qatomic_generic_unix.cpp b/src/corelib/arch/generic/qatomic_generic_unix.cpp |
| 15 | index 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); |
| 35 | diff --git a/src/corelib/arch/qatomic_generic.h b/src/corelib/arch/qatomic_generic.h |
| 36 | index 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 | -- |
| 49 | 1.7.0.4 |
| 50 | |