From 110a8c339fa078a4edd09a70239280e482b149f1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 3 Nov 2015 08:04:15 -0500 Subject: Remove qatomic_mips.h: the 3-operand testAndSet is broken MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "previous" value is always 1 when the compare-and-swap succeeded, instead of the previous value. Instead of fixing this, let's just remove this file a bit earlier than the rest. All of them will be removed in Qt 5.7 anyway, so let's leave MIPS atomics to the compiler. Task-number: QTBUG-49168 Change-Id: Idba8c29717f34c70a58fffff14133304595165f5 Reviewed-by: Dmitry Shachnev Reviewed-by: Oswald Buddenhagen Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira Reviewed-by: Lisandro Damián Nicanor Pérez Meyer --- src/corelib/arch/qatomic_mips.h | 351 -------------------------------------- src/corelib/thread/qbasicatomic.h | 2 - 2 files changed, 353 deletions(-) delete mode 100644 src/corelib/arch/qatomic_mips.h diff --git a/src/corelib/arch/qatomic_mips.h b/src/corelib/arch/qatomic_mips.h deleted file mode 100644 index 8c400e0076..0000000000 --- a/src/corelib/arch/qatomic_mips.h +++ /dev/null @@ -1,351 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2011 Thiago Macieira -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QATOMIC_MIPS_H -#define QATOMIC_MIPS_H - -#include - -QT_BEGIN_NAMESPACE - -#if 0 -// silence syncqt warnings -QT_END_NAMESPACE -#pragma qt_sync_skip_header_check -#pragma qt_sync_stop_processing -#endif - -#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE - -#define Q_ATOMIC_INT32_IS_SUPPORTED -#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT32_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_ALWAYS_NATIVE - -#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE - -template struct QBasicAtomicOps: QGenericAtomicOps > -{ - template - static void acquireMemoryFence(const T &) Q_DECL_NOTHROW; - template - static void releaseMemoryFence(const T &) Q_DECL_NOTHROW; - template - static void orderedMemoryFence(const T &) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; } - template static bool ref(T &_q_value) Q_DECL_NOTHROW; - template static bool deref(T &_q_value) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; } - template static bool - testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; } - template static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; } - template static - T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW; -}; - -template struct QAtomicOps : QBasicAtomicOps -{ - typedef T Type; -}; - -#if defined(Q_CC_GNU) - -#if defined(_MIPS_ARCH_MIPS1) || (!defined(Q_CC_CLANG) && defined(__mips) && __mips - 0 == 1) -# error "Sorry, the MIPS1 architecture is not supported" -# error "please set '-march=' to your architecture (e.g., -march=mips32)" -#endif - -template template inline -void QBasicAtomicOps::acquireMemoryFence(const T &) Q_DECL_NOTHROW -{ - asm volatile (".set push\n" - ".set mips32\n" - "sync 0x11\n" - ".set pop\n" ::: "memory"); -} - -template template inline -void QBasicAtomicOps::releaseMemoryFence(const T &) Q_DECL_NOTHROW -{ - asm volatile (".set push\n" - ".set mips32\n" - "sync 0x12\n" - ".set pop\n" ::: "memory"); -} - -template template inline -void QBasicAtomicOps::orderedMemoryFence(const T &) Q_DECL_NOTHROW -{ - asm volatile (".set push\n" - ".set mips32\n" - "sync 0\n" - ".set pop\n" ::: "memory"); -} - -template<> template inline -bool QBasicAtomicOps<4>::ref(T &_q_value) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "ll %[originalValue], %[_q_value]\n" - "addiu %[newValue], %[originalValue], %[one]\n" - "sc %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [one] "i" (1) - : "cc", "memory"); - return originalValue != T(-1); -} - -template<> template inline -bool QBasicAtomicOps<4>::deref(T &_q_value) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "ll %[originalValue], %[_q_value]\n" - "addiu %[newValue], %[originalValue], %[minusOne]\n" - "sc %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [minusOne] "i" (-1) - : "cc", "memory"); - return originalValue != 1; -} - -template<> template inline -bool QBasicAtomicOps<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW -{ - T result; - T tempValue; - asm volatile("0:\n" - "ll %[tempValue], %[_q_value]\n" - "xor %[result], %[tempValue], %[expectedValue]\n" - "bnez %[result], 0f\n" - "nop\n" - "move %[tempValue], %[newValue]\n" - "sc %[tempValue], %[_q_value]\n" - "beqz %[tempValue], 0b\n" - "nop\n" - "0:\n" - : [result] "=&r" (result), - [tempValue] "=&r" (tempValue), - [_q_value] "+m" (_q_value) - : [expectedValue] "r" (expectedValue), - [newValue] "r" (newValue) - : "cc", "memory"); - if (currentValue) - *currentValue = tempValue; - return result == 0; -} - -template<> template inline -T QBasicAtomicOps<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW -{ - T originalValue; - T tempValue; - asm volatile("0:\n" - "ll %[originalValue], %[_q_value]\n" - "move %[tempValue], %[newValue]\n" - "sc %[tempValue], %[_q_value]\n" - "beqz %[tempValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [tempValue] "=&r" (tempValue), - [_q_value] "+m" (_q_value) - : [newValue] "r" (newValue) - : "cc", "memory"); - return originalValue; -} - -template<> template inline -T QBasicAtomicOps<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "ll %[originalValue], %[_q_value]\n" - "addu %[newValue], %[originalValue], %[valueToAdd]\n" - "sc %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [valueToAdd] "r" (valueToAdd * QAtomicAdditiveType::AddScale) - : "cc", "memory"); - return originalValue; -} - -#if defined(Q_PROCESSOR_MIPS_64) - -#define Q_ATOMIC_INT64_IS_SUPPORTED -#define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT64_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_ALWAYS_NATIVE - -template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; }; - -template<> template inline -bool QBasicAtomicOps<8>::ref(T &_q_value) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "lld %[originalValue], %[_q_value]\n" - "addiu %[newValue], %[originalValue], %[one]\n" - "scd %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [one] "i" (1) - : "cc", "memory"); - return originalValue != T(-1); -} - -template<> template inline -bool QBasicAtomicOps<8>::deref(T &_q_value) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "lld %[originalValue], %[_q_value]\n" - "addiu %[newValue], %[originalValue], %[minusOne]\n" - "scd %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [minusOne] "i" (-1) - : "cc", "memory"); - return originalValue != 1; -} - -template<> template inline -bool QBasicAtomicOps<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW -{ - T result; - T tempValue; - asm volatile("0:\n" - "lld %[tempValue], %[_q_value]\n" - "xor %[result], %[tempValue], %[expectedValue]\n" - "bnez %[result], 0f\n" - "nop\n" - "move %[tempValue], %[newValue]\n" - "scd %[tempValue], %[_q_value]\n" - "beqz %[tempValue], 0b\n" - "nop\n" - "0:\n" - : [result] "=&r" (result), - [tempValue] "=&r" (tempValue), - [_q_value] "+m" (_q_value) - : [expectedValue] "r" (expectedValue), - [newValue] "r" (newValue) - : "cc", "memory"); - if (currentValue) - *currentValue = tempValue; - return result == 0; -} - -template<> template inline -T QBasicAtomicOps<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW -{ - T originalValue; - T tempValue; - asm volatile("0:\n" - "lld %[originalValue], %[_q_value]\n" - "move %[tempValue], %[newValue]\n" - "scd %[tempValue], %[_q_value]\n" - "beqz %[tempValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [tempValue] "=&r" (tempValue), - [_q_value] "+m" (_q_value) - : [newValue] "r" (newValue) - : "cc", "memory"); - return originalValue; -} - -template<> template inline -T QBasicAtomicOps<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "lld %[originalValue], %[_q_value]\n" - "addu %[newValue], %[originalValue], %[valueToAdd]\n" - "scd %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [valueToAdd] "r" (valueToAdd * QAtomicAdditiveType::AddScale) - : "cc", "memory"); - return originalValue; -} - -#endif // MIPS64 - -#else -# error "This compiler for MIPS is not supported" -#endif // Q_CC_GNU - -QT_END_NAMESPACE - -#endif // QATOMIC_MIPS_H diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index ecf39d699f..3c16cf5b9c 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -60,8 +60,6 @@ # include "QtCore/qatomic_armv5.h" #elif defined(Q_PROCESSOR_IA64) # include "QtCore/qatomic_ia64.h" -#elif defined(Q_PROCESSOR_MIPS) -# include "QtCore/qatomic_mips.h" #elif defined(Q_PROCESSOR_X86) # include -- cgit v1.2.3