**
****************************************************************************/
+#include <QtCore/qglobal.h>
+
#ifndef QATOMIC_H
#define QATOMIC_H
-#include <QtCore/qglobal.h>
#include <QtCore/qbasicatomic.h>
QT_BEGIN_HEADER
QT_MODULE(Core)
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wextra"
+#endif
+
// High-level atomic integer operations
class Q_CORE_EXPORT QAtomicInt : public QBasicAtomicInt
{
public:
+ // Non-atomic API
inline QAtomicInt(int value = 0)
{
#ifdef QT_ARCH_PARISC
#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;
+ store(other.load());
}
inline QAtomicInt &operator=(int value)
{
- (void) QBasicAtomicInt::operator=(value);
+ this->store(value);
return *this;
}
inline QAtomicInt &operator=(const QAtomicInt &other)
{
- (void) QBasicAtomicInt::operator=(other);
+ this->store(other.load());
return *this;
}
-#ifdef qdoc
- bool operator==(int value) const;
- bool operator!=(int value) const;
- bool operator!() const;
- operator int() const;
+ inline bool operator==(int value) const
+ {
+ return this->load() == value;
+ }
+ inline bool operator!=(int value) const
+ {
+ return this->load() != value;
+ }
+
+ inline operator int() const
+ {
+ return this->load();
+ }
+
+ inline bool operator!() const
+ {
+ return !this->load();
+ }
+
+#ifdef qdoc
static bool isReferenceCountingNative();
static bool isReferenceCountingWaitFree();
#ifdef QT_ARCH_PARISC
this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1;
#endif
- QBasicAtomicPointer<T>::_q_value = value;
+ store(value);
}
inline QAtomicPointer(const QAtomicPointer<T> &other)
{
#ifdef QT_ARCH_PARISC
this->_q_lock[0] = this->_q_lock[1] = this->_q_lock[2] = this->_q_lock[3] = -1;
#endif
- QBasicAtomicPointer<T>::_q_value = other._q_value;
+ store(other.load());
}
inline QAtomicPointer<T> &operator=(T *value)
{
- (void) QBasicAtomicPointer<T>::operator=(value);
+ this->store(value);
return *this;
}
inline QAtomicPointer<T> &operator=(const QAtomicPointer<T> &other)
{
- (void) QBasicAtomicPointer<T>::operator=(other);
+ this->store(other.load());
return *this;
}
-#ifdef qdoc
- bool operator==(T *value) const;
- bool operator!=(T *value) const;
- bool operator!() const;
- operator T *() const;
- T *operator->() const;
+ inline bool operator==(T *value) const
+ {
+ return this->load() == value;
+ }
+
+ inline bool operator!=(T *value) const
+ {
+ return this->load() != value;
+ }
+
+ inline bool operator!() const
+ {
+ return !this->load();
+ }
+ inline operator T *() const
+ {
+ return this->load();
+ }
+
+ inline T *operator->() const
+ {
+ return this->load();
+ }
+
+#ifdef qdoc
static bool isTestAndSetNative();
static bool isTestAndSetWaitFree();
#endif
};
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)
+# pragma GCC diagnostic pop
+#endif
+
/*!
This is a helper for the assignment operators of implicitly
shared classes. Your assignment operator should look like this:
volatile int _q_value;
#endif
- // Non-atomic API
- inline bool operator==(int value) const
- {
- return _q_value == value;
- }
-
- inline bool operator!=(int value) const
- {
- return _q_value != value;
- }
-
- inline bool operator!() const
- {
- return _q_value == 0;
- }
-
- inline operator int() const
- {
- return _q_value;
- }
-
- 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;
- }
-
// Atomic API, implemented in qatomic_XXX.h
int load() const { return _q_value; }
T * volatile _q_value;
#endif
- // Non-atomic API
- inline bool operator==(T *value) const
- {
- return _q_value == value;
- }
-
- inline bool operator!=(T *value) const
- {
- return !operator==(value);
- }
-
- inline bool operator!() const
- {
- return operator==(0);
- }
-
- inline operator T *() const
- {
- return _q_value;
- }
-
- inline T *operator->() const
- {
- return _q_value;
- }
-
- inline QBasicAtomicPointer<T> &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;
- }
-
// Atomic API, implemented in qatomic_XXX.h
T *load() const { return _q_value; }