0004-fix-const-atomics.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. It's still not entirely const-correct though. In all other architectures
  6. this is obfuscated through the use of inline asm (which the compiler
  7. doesn't check). This patch obfuscates through const_cast
  8. ---
  9. src/corelib/arch/generic/qatomic_generic_unix.cpp | 8 ++++----
  10. src/corelib/arch/qatomic_generic.h | 2 +-
  11. 2 files changed, 5 insertions(+), 5 deletions(-)
  12. diff --git a/src/corelib/arch/generic/qatomic_generic_unix.cpp b/src/corelib/arch/generic/qatomic_generic_unix.cpp
  13. index 1c6cbf0..6fce81d 100644
  14. --- a/src/corelib/arch/generic/qatomic_generic_unix.cpp
  15. +++ b/src/corelib/arch/generic/qatomic_generic_unix.cpp
  16. @@ -85,13 +85,13 @@ int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd)
  17. Q_CORE_EXPORT
  18. bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value,
  19. - void *expectedValue,
  20. - void *newValue)
  21. + const void *expectedValue,
  22. + const void *newValue)
  23. {
  24. bool returnValue = false;
  25. pthread_mutex_lock(&qAtomicMutex);
  26. if (*_q_value == expectedValue) {
  27. - *_q_value = newValue;
  28. + *_q_value = const_cast<void*>(newValue);
  29. returnValue = true;
  30. }
  31. pthread_mutex_unlock(&qAtomicMutex);
  32. diff --git a/src/corelib/arch/qatomic_generic.h b/src/corelib/arch/qatomic_generic.h
  33. index 621a767..4c14679 100644
  34. --- a/src/corelib/arch/qatomic_generic.h
  35. +++ b/src/corelib/arch/qatomic_generic.h
  36. @@ -105,7 +105,7 @@ Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered(volatile int *, int, int);
  37. Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *, int);
  38. Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddOrdered(volatile int *, int);
  39. -Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *, void *, void *);
  40. +Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *, const void *, const void *);
  41. Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *, void *);
  42. Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *, qptrdiff);
  43. --
  44. 1.7.0.4