From: Debian Qt/KDE Maintainers Date: Wed, 9 Nov 2016 16:50:49 +0000 (+0000) Subject: parisc-atomic X-Git-Tag: archive/raspbian/4%4.8.7+dfsg-15+rpi1~1^2~7 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2d039149e5cd3c8ac87ca09564d9f438353feb11;p=qt4-x11.git parisc-atomic Gbp-Pq: Name parisc-atomic.patch --- diff --git a/src/corelib/arch/parisc/arch.pri b/src/corelib/arch/parisc/arch.pri index fab2897f0..509ab84c2 100644 --- a/src/corelib/arch/parisc/arch.pri +++ b/src/corelib/arch/parisc/arch.pri @@ -1,5 +1,3 @@ # # HP PA-RISC architecture # -SOURCES += $$QT_ARCH_CPP/q_ldcw.s \ - $$QT_ARCH_CPP/qatomic_parisc.cpp diff --git a/src/corelib/arch/qatomic_parisc.h b/src/corelib/arch/qatomic_parisc.h index c444e75de..b520e04f8 100644 --- a/src/corelib/arch/qatomic_parisc.h +++ b/src/corelib/arch/qatomic_parisc.h @@ -101,41 +101,19 @@ template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndAddWaitFree() { return false; } -extern "C" { - Q_CORE_EXPORT void q_atomic_lock(int *lock); - Q_CORE_EXPORT void q_atomic_unlock(int *lock); -} - -// Reference counting - inline bool QBasicAtomicInt::ref() { - q_atomic_lock(_q_lock); - bool ret = (++_q_value != 0); - q_atomic_unlock(_q_lock); - return ret; + return __sync_add_and_fetch(&_q_value, 1); } inline bool QBasicAtomicInt::deref() { - q_atomic_lock(_q_lock); - bool ret = (--_q_value != 0); - q_atomic_unlock(_q_lock); - return ret; + return __sync_sub_and_fetch(&_q_value, 1); } -// Test-and-set for integers - inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue) { - q_atomic_lock(_q_lock); - if (_q_value == expectedValue) { - _q_value = newValue; - q_atomic_unlock(_q_lock); - return true; - } - q_atomic_unlock(_q_lock); - return false; + return __sync_bool_compare_and_swap(&_q_value, expectedValue, newValue); } inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) @@ -153,15 +131,9 @@ inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue) return testAndSetOrdered(expectedValue, newValue); } -// Fetch-and-store for integers - inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) { - q_atomic_lock(_q_lock); - int returnValue = _q_value; - _q_value = newValue; - q_atomic_unlock(_q_lock); - return returnValue; + return __sync_lock_test_and_set(&_q_value, newValue); } inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue) @@ -179,15 +151,9 @@ inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue) return fetchAndStoreOrdered(newValue); } -// Fetch-and-add for integers - inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd) { - q_atomic_lock(_q_lock); - int originalValue = _q_value; - _q_value += valueToAdd; - q_atomic_unlock(_q_lock); - return originalValue; + return __sync_fetch_and_add(&_q_value, valueToAdd); } inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd) @@ -205,19 +171,10 @@ inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd) return fetchAndAddOrdered(valueToAdd); } -// Test and set for pointers - template Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetOrdered(T *expectedValue, T *newValue) { - q_atomic_lock(_q_lock); - if (_q_value == expectedValue) { - _q_value = newValue; - q_atomic_unlock(_q_lock); - return true; - } - q_atomic_unlock(_q_lock); - return false; + return __sync_bool_compare_and_swap(&_q_value, expectedValue, newValue); } template @@ -238,16 +195,10 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetRelease(T *expectedValu return testAndSetOrdered(expectedValue, newValue); } -// Fetch and store for pointers - template Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreOrdered(T *newValue) { - q_atomic_lock(_q_lock); - T *returnValue = (_q_value); - _q_value = newValue; - q_atomic_unlock(_q_lock); - return returnValue; + return __sync_lock_test_and_set(&_q_value, newValue); } template @@ -268,16 +219,10 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreRelease(T *newValue) return fetchAndStoreOrdered(newValue); } -// Fetch and add for pointers - template Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddOrdered(qptrdiff valueToAdd) { - q_atomic_lock(_q_lock); - T *returnValue = (_q_value); - _q_value += valueToAdd; - q_atomic_unlock(_q_lock); - return returnValue; + return __sync_fetch_and_add(&_q_value, valueToAdd * sizeof(T)); } template diff --git a/src/corelib/thread/qatomic.h b/src/corelib/thread/qatomic.h index b8c0718b2..7bb0809d7 100644 --- a/src/corelib/thread/qatomic.h +++ b/src/corelib/thread/qatomic.h @@ -57,16 +57,10 @@ class Q_CORE_EXPORT QAtomicInt : public QBasicAtomicInt public: inline QAtomicInt(int value = 0) { -#ifdef QT_ARCH_PARISC - this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1; -#endif _q_value = value; } inline QAtomicInt(const QAtomicInt &other) { -#ifdef QT_ARCH_PARISC - this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1; -#endif _q_value = other._q_value; } @@ -127,16 +121,10 @@ class QAtomicPointer : public QBasicAtomicPointer public: inline QAtomicPointer(T *value = 0) { -#ifdef QT_ARCH_PARISC - this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1; -#endif QBasicAtomicPointer::_q_value = value; } inline QAtomicPointer(const QAtomicPointer &other) { -#ifdef QT_ARCH_PARISC - this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1; -#endif QBasicAtomicPointer::_q_value = other._q_value; } diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index ed04f9477..8238f8918 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -53,9 +53,6 @@ QT_MODULE(Core) class Q_CORE_EXPORT QBasicAtomicInt { 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; @@ -87,9 +84,6 @@ public: inline QBasicAtomicInt &operator=(int value) { -#ifdef QT_ARCH_PARISC - this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1; -#endif _q_value = value; return *this; } @@ -131,9 +125,6 @@ template class QBasicAtomicPointer { public: -#ifdef QT_ARCH_PARISC - int _q_lock[4]; -#endif #if defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE) union { T * volatile _q_value; @@ -176,9 +167,6 @@ public: inline QBasicAtomicPointer &operator=(T *value) { -#ifdef QT_ARCH_PARISC - this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1; -#endif _q_value = value; return *this; } @@ -210,9 +198,7 @@ public: T *fetchAndAddOrdered(qptrdiff valueToAdd); }; -#ifdef QT_ARCH_PARISC -# define Q_BASIC_ATOMIC_INITIALIZER(a) {{-1,-1,-1,-1},(a)} -#elif defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE) +#if defined(QT_ARCH_WINDOWS) || defined(QT_ARCH_WINDOWSCE) # define Q_BASIC_ATOMIC_INITIALIZER(a) { {(a)} } #else # define Q_BASIC_ATOMIC_INITIALIZER(a) { (a) }