From c4759d19f8428b64b46bfd1e07a5cfda2937e7d1 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 10 Feb 2012 12:18:41 +0100 Subject: Remove the SH atomic implementation... ... but keep SH-4a, which provides a more efficient implementation. The implementation removed here was very similar to the code removed by commit dc5388e79b71d796c1207681235cf007c39810bd. Support for SH can be provided by qatomic_gcc.h, or re-added in the future if absolutely necessary. Change-Id: Ic38b57c9513fc9c3c99ba7e102780a3939b735b9 Reviewed-by: Thiago Macieira --- src/corelib/arch/arch.pri | 1 - src/corelib/arch/qatomic_arch.h | 2 - src/corelib/arch/qatomic_sh.h | 330 ------------------------------------- src/corelib/arch/sh/arch.pri | 4 - src/corelib/arch/sh/qatomic_sh.cpp | 72 -------- 5 files changed, 409 deletions(-) delete mode 100644 src/corelib/arch/qatomic_sh.h delete mode 100644 src/corelib/arch/sh/arch.pri delete mode 100644 src/corelib/arch/sh/qatomic_sh.cpp (limited to 'src/corelib/arch') diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri index 08ab17e0f4..b94fa01309 100644 --- a/src/corelib/arch/arch.pri +++ b/src/corelib/arch/arch.pri @@ -26,7 +26,6 @@ integrity:HEADERS += arch/qatomic_integrity.h arch/qatomic_mips.h \ arch/qatomic_s390.h \ arch/qatomic_x86_64.h \ - arch/qatomic_sh.h \ arch/qatomic_sh4a.h \ arch/qatomic_gcc.h \ arch/qatomic_cxx11.h diff --git a/src/corelib/arch/qatomic_arch.h b/src/corelib/arch/qatomic_arch.h index 59c8de3cde..140cb4702a 100644 --- a/src/corelib/arch/qatomic_arch.h +++ b/src/corelib/arch/qatomic_arch.h @@ -64,8 +64,6 @@ QT_BEGIN_HEADER # include "QtCore/qatomic_s390.h" #elif defined(QT_ARCH_SPARC) # include "QtCore/qatomic_sparc.h" -#elif defined(QT_ARCH_SH) -# include "QtCore/qatomic_sh.h" #elif defined(QT_ARCH_SH4A) # include "QtCore/qatomic_sh4a.h" #else diff --git a/src/corelib/arch/qatomic_sh.h b/src/corelib/arch/qatomic_sh.h deleted file mode 100644 index d16aaf26b1..0000000000 --- a/src/corelib/arch/qatomic_sh.h +++ /dev/null @@ -1,330 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QATOMIC_SH_H -#define QATOMIC_SH_H - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NOT_NATIVE - -inline bool QBasicAtomicInt::isReferenceCountingNative() -{ return false; } -inline bool QBasicAtomicInt::isReferenceCountingWaitFree() -{ return false; } - -#define Q_ATOMIC_INT_TEST_AND_SET_IS_NOT_NATIVE - -inline bool QBasicAtomicInt::isTestAndSetNative() -{ return false; } -inline bool QBasicAtomicInt::isTestAndSetWaitFree() -{ return false; } - -#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_NOT_NATIVE - -inline bool QBasicAtomicInt::isFetchAndStoreNative() -{ return false; } -inline bool QBasicAtomicInt::isFetchAndStoreWaitFree() -{ return false; } - -#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_NOT_NATIVE - -inline bool QBasicAtomicInt::isFetchAndAddNative() -{ return false; } -inline bool QBasicAtomicInt::isFetchAndAddWaitFree() -{ return false; } - -#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE - -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isTestAndSetNative() -{ return false; } -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isTestAndSetWaitFree() -{ return false; } - -#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NOT_NATIVE - -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndStoreNative() -{ return false; } -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndStoreWaitFree() -{ return false; } - -#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NOT_NATIVE - -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndAddNative() -{ return false; } -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::isFetchAndAddWaitFree() -{ return false; } - -extern Q_CORE_EXPORT volatile char qt_atomic_lock; -Q_CORE_EXPORT void qt_atomic_yield(int *count); - -inline int qt_atomic_tasb(volatile char *ptr) -{ - register int ret; - asm volatile("tas.b @%2\n" - "movt %0" - : "=&r"(ret), "=m"(*ptr) - : "r"(ptr) - : "cc", "memory"); - return ret; -} - -// Reference counting - -inline bool QBasicAtomicInt::ref() -{ - int count = 0; - while (qt_atomic_tasb(&qt_atomic_lock) == 0) - qt_atomic_yield(&count); - int originalValue = _q_value++; - qt_atomic_lock = 0; - return originalValue != -1; -} - -inline bool QBasicAtomicInt::deref() -{ - int count = 0; - while (qt_atomic_tasb(&qt_atomic_lock) == 0) - qt_atomic_yield(&count); - int originalValue = _q_value--; - qt_atomic_lock = 0; - return originalValue != 1; -} - -// Test and set for integers - -inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue) -{ - bool returnValue = false; - int count = 0; - while (qt_atomic_tasb(&qt_atomic_lock) == 0) - qt_atomic_yield(&count); - if (_q_value == expectedValue) { - _q_value = newValue; - returnValue = true; - } - qt_atomic_lock = 0; - return returnValue; -} - -inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - -inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - -inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - -// Fetch and store for integers - -inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) -{ - int count = 0; - while (qt_atomic_tasb(&qt_atomic_lock) == 0) - qt_atomic_yield(&count); - int originalValue = _q_value; - _q_value = newValue; - qt_atomic_lock = 0; - return originalValue; -} - -inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue) -{ - return fetchAndStoreOrdered(newValue); -} - -inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue) -{ - return fetchAndStoreOrdered(newValue); -} - -inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue) -{ - return fetchAndStoreOrdered(newValue); -} - -// Fetch and add for integers - -inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd) -{ - int count = 0; - while (qt_atomic_tasb(&qt_atomic_lock) == 0) - qt_atomic_yield(&count); - int originalValue = _q_value; - _q_value += valueToAdd; - qt_atomic_lock = 0; - return originalValue; -} - -inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd) -{ - return fetchAndAddOrdered(valueToAdd); -} - -inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd) -{ - return fetchAndAddOrdered(valueToAdd); -} - -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) -{ - bool returnValue = false; - int count = 0; - while (qt_atomic_tasb(&qt_atomic_lock) == 0) - qt_atomic_yield(&count); - if (_q_value == expectedValue) { - _q_value = newValue; - returnValue = true; - } - qt_atomic_lock = 0; - return returnValue; -} - -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetRelaxed(T *expectedValue, T *newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetAcquire(T *expectedValue, T *newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - -template -Q_INLINE_TEMPLATE bool QBasicAtomicPointer::testAndSetRelease(T *expectedValue, T *newValue) -{ - return testAndSetOrdered(expectedValue, newValue); -} - -// Fetch and store for pointers - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreOrdered(T *newValue) -{ - int count = 0; - while (qt_atomic_tasb(&qt_atomic_lock) == 0) - qt_atomic_yield(&count); - T *originalValue = _q_value; - _q_value = newValue; - qt_atomic_lock = 0; - return originalValue; -} - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreRelaxed(T *newValue) -{ - return fetchAndStoreOrdered(newValue); -} - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndStoreAcquire(T *newValue) -{ - return fetchAndStoreOrdered(newValue); -} - -template -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) -{ - int count = 0; - while (qt_atomic_tasb(&qt_atomic_lock) == 0) - qt_atomic_yield(&count); - T *originalValue = (_q_value); - _q_value += valueToAdd; - qt_atomic_lock = 0; - return originalValue; -} - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddRelaxed(qptrdiff valueToAdd) -{ - return fetchAndAddOrdered(valueToAdd); -} - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddAcquire(qptrdiff valueToAdd) -{ - return fetchAndAddOrdered(valueToAdd); -} - -template -Q_INLINE_TEMPLATE T *QBasicAtomicPointer::fetchAndAddRelease(qptrdiff valueToAdd) -{ - return fetchAndAddOrdered(valueToAdd); -} - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QATOMIC_SH_H diff --git a/src/corelib/arch/sh/arch.pri b/src/corelib/arch/sh/arch.pri deleted file mode 100644 index 67fbb16c10..0000000000 --- a/src/corelib/arch/sh/arch.pri +++ /dev/null @@ -1,4 +0,0 @@ -# -# SH (Renesas SuperH) architecture -# -SOURCES += $$QT_ARCH_CPP/qatomic_sh.cpp diff --git a/src/corelib/arch/sh/qatomic_sh.cpp b/src/corelib/arch/sh/qatomic_sh.cpp deleted file mode 100644 index 5cd1b593d8..0000000000 --- a/src/corelib/arch/sh/qatomic_sh.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#ifdef _POSIX_PRIORITY_SCHEDULING -# include -#endif -#include - -QT_BEGIN_NAMESPACE - -QT_USE_NAMESPACE - -Q_CORE_EXPORT volatile char qt_atomic_lock = 0; - -Q_CORE_EXPORT void qt_atomic_yield(int *count) -{ -#ifdef _POSIX_PRIORITY_SCHEDULING - if((*count)++ < 50) { - sched_yield(); - } else -#endif - { - struct timespec tm; - tm.tv_sec = 0; - tm.tv_nsec = 2000001; - nanosleep(&tm, NULL); - *count = 0; - } -} - -QT_END_NAMESPACE -- cgit v1.2.3