Get rid of bootstrapped atomics
C++11 atomics should be available everywhere, even it bootstrapped builds. This will allow further simplificattions. Task-number: QTBUG-103847 Change-Id: Ic8aaec5667ef7616a6aa1f0dfc2f64d327308501 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
7d7d4671bd
commit
c5b816393d
@ -226,7 +226,6 @@ qt_internal_add_module(Core
|
|||||||
text/qutf8stringview.h
|
text/qutf8stringview.h
|
||||||
text/qvsnprintf.cpp
|
text/qvsnprintf.cpp
|
||||||
thread/qatomic.h
|
thread/qatomic.h
|
||||||
thread/qatomic_bootstrap.h
|
|
||||||
thread/qatomic_cxx11.h
|
thread/qatomic_cxx11.h
|
||||||
thread/qbasicatomic.h
|
thread/qbasicatomic.h
|
||||||
thread/qgenericatomic.h
|
thread/qgenericatomic.h
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// Copyright (C) 2011 Thiago Macieira <thiago@kde.org>
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
|
||||||
|
|
||||||
#ifndef QATOMIC_BOOTSTRAP_H
|
|
||||||
#define QATOMIC_BOOTSTRAP_H
|
|
||||||
|
|
||||||
#include <QtCore/qgenericatomic.h>
|
|
||||||
|
|
||||||
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_INT8_IS_SUPPORTED
|
|
||||||
template<> struct QAtomicOpsSupport<1> { enum { IsSupported = 1 }; };
|
|
||||||
#define Q_ATOMIC_INT16_IS_SUPPORTED
|
|
||||||
template<> struct QAtomicOpsSupport<2> { enum { IsSupported = 1 }; };
|
|
||||||
#define Q_ATOMIC_INT32_IS_SUPPORTED
|
|
||||||
#define Q_ATOMIC_INT64_IS_SUPPORTED
|
|
||||||
template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; };
|
|
||||||
|
|
||||||
template <typename T> struct QAtomicOps: QGenericAtomicOps<QAtomicOps<T> >
|
|
||||||
{
|
|
||||||
typedef T Type;
|
|
||||||
|
|
||||||
static bool ref(T &_q_value) noexcept
|
|
||||||
{
|
|
||||||
return ++_q_value != 0;
|
|
||||||
}
|
|
||||||
static bool deref(T &_q_value) noexcept
|
|
||||||
{
|
|
||||||
return --_q_value != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue = nullptr) noexcept
|
|
||||||
{
|
|
||||||
if (currentValue)
|
|
||||||
*currentValue = _q_value;
|
|
||||||
if (_q_value == expectedValue) {
|
|
||||||
_q_value = newValue;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static T fetchAndStoreRelaxed(T &_q_value, T newValue) noexcept
|
|
||||||
{
|
|
||||||
T tmp = _q_value;
|
|
||||||
_q_value = newValue;
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename AdditiveType> static
|
|
||||||
T fetchAndAddRelaxed(T &_q_value, AdditiveType valueToAdd) noexcept
|
|
||||||
{
|
|
||||||
T returnValue = _q_value;
|
|
||||||
_q_value += valueToAdd;
|
|
||||||
return returnValue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif // QATOMIC_BOOTSTRAP_H
|
|
@ -149,7 +149,7 @@ template <> inline bool QAtomicTraits<2>::isLockFree()
|
|||||||
{ return false; }
|
{ return false; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if QT_CONFIG(std_atomic64)
|
#if !defined(QT_BOOTSTRAPPED) && QT_CONFIG(std_atomic64)
|
||||||
template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; };
|
template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; };
|
||||||
# define Q_ATOMIC_INT64_IS_SUPPORTED
|
# define Q_ATOMIC_INT64_IS_SUPPORTED
|
||||||
# if ATOMIC_LLONG_LOCK_FREE == 2
|
# if ATOMIC_LLONG_LOCK_FREE == 2
|
||||||
|
@ -7,19 +7,7 @@
|
|||||||
#ifndef QBASICATOMIC_H
|
#ifndef QBASICATOMIC_H
|
||||||
#define QBASICATOMIC_H
|
#define QBASICATOMIC_H
|
||||||
|
|
||||||
#if defined(QT_BOOTSTRAPPED)
|
#include <QtCore/qatomic_cxx11.h>
|
||||||
# include <QtCore/qatomic_bootstrap.h>
|
|
||||||
|
|
||||||
// If C++11 atomics are supported, use them!
|
|
||||||
// Note that constexpr support is sometimes disabled in QNX or INTEGRITY builds,
|
|
||||||
// but their libraries have <atomic>.
|
|
||||||
#elif defined(Q_COMPILER_ATOMICS)
|
|
||||||
# include <QtCore/qatomic_cxx11.h>
|
|
||||||
|
|
||||||
// No fallback
|
|
||||||
#else
|
|
||||||
# error "Qt requires C++11 support"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_MSVC(4522)
|
QT_WARNING_DISABLE_MSVC(4522)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user