diff options
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qarraydata.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qarraydataops.h | 4 | ||||
-rw-r--r-- | src/corelib/tools/qcollator.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qcontiguouscache.h | 14 | ||||
-rw-r--r-- | src/corelib/tools/qfreelist_p.h | 14 | ||||
-rw-r--r-- | src/corelib/tools/qhash.cpp | 10 | ||||
-rw-r--r-- | src/corelib/tools/qlinkedlist.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_p.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qrefcount.h | 14 | ||||
-rw-r--r-- | src/corelib/tools/qregexp.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qshareddata.h | 4 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer.cpp | 10 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 16 | ||||
-rw-r--r-- | src/corelib/tools/qsimd.cpp | 4 | ||||
-rw-r--r-- | src/corelib/tools/qsimd_p.h | 4 |
15 files changed, 53 insertions, 53 deletions
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 844cde5563..234a44f6b6 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -224,9 +224,9 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, & ~(alignment - 1); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) - header->ref.atomic.store(bool(!(options & Unsharable))); + header->ref.atomic.storeRelaxed(bool(!(options & Unsharable))); #else - header->ref.atomic.store(1); + header->ref.atomic.storeRelaxed(1); #endif header->size = 0; header->alloc = capacity; diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 7e1b43f9b1..8e19525f07 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -106,7 +106,7 @@ struct QPodArrayOps void destroyAll() // Call from destructors, ONLY! { Q_ASSERT(this->isMutable()); - Q_ASSERT(this->ref.atomic.load() == 0); + Q_ASSERT(this->ref.atomic.loadRelaxed() == 0); // As this is to be called only from destructor, it doesn't need to be // exception safe; size not updated. @@ -204,7 +204,7 @@ struct QGenericArrayOps // As this is to be called only from destructor, it doesn't need to be // exception safe; size not updated. - Q_ASSERT(this->ref.atomic.load() == 0); + Q_ASSERT(this->ref.atomic.loadRelaxed() == 0); const T *const b = this->begin(); const T *i = this->end(); diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp index 6e85027462..958216bde8 100644 --- a/src/corelib/tools/qcollator.cpp +++ b/src/corelib/tools/qcollator.cpp @@ -166,7 +166,7 @@ QCollator &QCollator::operator=(const QCollator &other) */ void QCollator::detach() { - if (d->ref.load() != 1) { + if (d->ref.loadRelaxed() != 1) { QCollatorPrivate *x = new QCollatorPrivate(d->locale); if (!d->ref.deref()) delete d; diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 592e31bfd2..7b74b4f526 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -100,8 +100,8 @@ public: inline ~QContiguousCache() { if (!d) return; if (!d->ref.deref()) freeData(p); } - inline void detach() { if (d->ref.load() != 1) detach_helper(); } - inline bool isDetached() const { return d->ref.load() == 1; } + inline void detach() { if (d->ref.loadRelaxed() != 1) detach_helper(); } + inline bool isDetached() const { return d->ref.loadRelaxed() == 1; } #if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } #endif @@ -176,7 +176,7 @@ void QContiguousCache<T>::detach_helper() union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x; x.d = allocateData(d->alloc); - x.d->ref.store(1); + x.d->ref.storeRelaxed(1); x.d->count = d->count; x.d->start = d->start; x.d->offset = d->offset; @@ -215,7 +215,7 @@ void QContiguousCache<T>::setCapacity(int asize) detach(); union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x; x.d = allocateData(asize); - x.d->ref.store(1); + x.d->ref.storeRelaxed(1); x.d->alloc = asize; x.d->count = qMin(d->count, asize); x.d->offset = d->offset + d->count - x.d->count; @@ -251,7 +251,7 @@ void QContiguousCache<T>::setCapacity(int asize) template <typename T> void QContiguousCache<T>::clear() { - if (d->ref.load() == 1) { + if (d->ref.loadRelaxed() == 1) { if (QTypeInfo<T>::isComplex) { int oldcount = d->count; T * i = p->array + d->start; @@ -267,7 +267,7 @@ void QContiguousCache<T>::clear() } else { union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x; x.d = allocateData(d->alloc); - x.d->ref.store(1); + x.d->ref.storeRelaxed(1); x.d->alloc = d->alloc; x.d->count = x.d->start = x.d->offset = 0; x.d->sharable = true; @@ -287,7 +287,7 @@ QContiguousCache<T>::QContiguousCache(int cap) { Q_ASSERT(cap >= 0); d = allocateData(cap); - d->ref.store(1); + d->ref.storeRelaxed(1); d->alloc = cap; d->count = d->start = d->offset = 0; d->sharable = true; diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h index d72d6e1b4b..dcaf5688dc 100644 --- a/src/corelib/tools/qfreelist_p.h +++ b/src/corelib/tools/qfreelist_p.h @@ -171,7 +171,7 @@ class QFreeList // qDebug("QFreeList: allocating %d elements (%ld bytes) with offset %d", size, size * sizeof(ElementType), offset); ElementType *v = new ElementType[size]; for (int i = 0; i < size; ++i) - v[i].next.store(offset + i + 1); + v[i].next.storeRelaxed(offset + i + 1); return v; } @@ -218,21 +218,21 @@ template <typename T, typename ConstantsType> inline QFreeList<T, ConstantsType>::~QFreeList() { for (int i = 0; i < ConstantsType::BlockCount; ++i) - delete [] _v[i].load(); + delete [] _v[i].loadRelaxed(); } template <typename T, typename ConstantsType> inline typename QFreeList<T, ConstantsType>::ConstReferenceType QFreeList<T, ConstantsType>::at(int x) const { const int block = blockfor(x); - return (_v[block].load())[x].t(); + return (_v[block].loadRelaxed())[x].t(); } template <typename T, typename ConstantsType> inline typename QFreeList<T, ConstantsType>::ReferenceType QFreeList<T, ConstantsType>::operator[](int x) { const int block = blockfor(x); - return (_v[block].load())[x].t(); + return (_v[block].loadRelaxed())[x].t(); } template <typename T, typename ConstantsType> @@ -257,7 +257,7 @@ inline int QFreeList<T, ConstantsType>::next() } } - newid = v[at].next.load() | (id & ~ConstantsType::IndexMask); + newid = v[at].next.loadRelaxed() | (id & ~ConstantsType::IndexMask); } while (!_next.testAndSetRelease(id, newid)); // qDebug("QFreeList::next(): returning %d (_next now %d, serial %d)", // id & ConstantsType::IndexMask, @@ -271,12 +271,12 @@ inline void QFreeList<T, ConstantsType>::release(int id) { int at = id & ConstantsType::IndexMask; const int block = blockfor(at); - ElementType *v = _v[block].load(); + ElementType *v = _v[block].loadRelaxed(); int x, newid; do { x = _next.loadAcquire(); - v[at].next.store(x & ConstantsType::IndexMask); + v[at].next.storeRelaxed(x & ConstantsType::IndexMask); newid = incrementserial(x, id); } while (!_next.testAndSetRelease(x, newid)); diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 6b003fe739..a53d6db997 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -321,7 +321,7 @@ static QBasicAtomicInt qt_qhash_seed = Q_BASIC_ATOMIC_INITIALIZER(-1); */ static void qt_initialize_qhash_seed() { - if (qt_qhash_seed.load() == -1) { + if (qt_qhash_seed.loadRelaxed() == -1) { int x(qt_create_qhash_seed() & INT_MAX); qt_qhash_seed.testAndSetRelaxed(-1, x); } @@ -340,7 +340,7 @@ static void qt_initialize_qhash_seed() int qGlobalQHashSeed() { qt_initialize_qhash_seed(); - return qt_qhash_seed.load(); + return qt_qhash_seed.loadRelaxed(); } /*! \relates QHash @@ -372,14 +372,14 @@ void qSetGlobalQHashSeed(int newSeed) return; if (newSeed == -1) { int x(qt_create_qhash_seed() & INT_MAX); - qt_qhash_seed.store(x); + qt_qhash_seed.storeRelaxed(x); } else { if (newSeed) { // can't use qWarning here (reentrancy) fprintf(stderr, "qSetGlobalQHashSeed: forced seed value is not 0, cannot guarantee that the " "hashing functions will produce a stable value."); } - qt_qhash_seed.store(newSeed & INT_MAX); + qt_qhash_seed.storeRelaxed(newSeed & INT_MAX); } } @@ -509,7 +509,7 @@ QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *), d->userNumBits = userNumBits; d->numBits = numBits; d->numBuckets = numBuckets; - d->seed = (this == &shared_null) ? uint(qt_qhash_seed.load()) : seed; + d->seed = (this == &shared_null) ? uint(qt_qhash_seed.loadRelaxed()) : seed; d->sharable = true; d->strictAlignment = nodeAlign > 8; d->reserved = 0; diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 6bc053a4c0..d4e5bca0ed 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -340,7 +340,7 @@ void QLinkedList<T>::freeData(QLinkedListData *x) { Node *y = reinterpret_cast<Node*>(x); Node *i = y->n; - Q_ASSERT(x->ref.atomic.load() == 0); + Q_ASSERT(x->ref.atomic.loadRelaxed() == 0); while (i != y) { Node *n = i; i = i->n; diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 59cc33700d..1e3da35a02 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -337,7 +337,7 @@ public: { QLocalePrivate *retval = new QLocalePrivate; retval->m_data = data; - retval->ref.store(0); + retval->ref.storeRelaxed(0); retval->m_numberOptions = numberOptions; return retval; } diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h index 71adb41f28..2e5388ad9a 100644 --- a/src/corelib/tools/qrefcount.h +++ b/src/corelib/tools/qrefcount.h @@ -52,7 +52,7 @@ class RefCount { public: inline bool ref() noexcept { - int count = atomic.load(); + int count = atomic.loadRelaxed(); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (count == 0) // !isSharable return false; @@ -63,7 +63,7 @@ public: } inline bool deref() noexcept { - int count = atomic.load(); + int count = atomic.loadRelaxed(); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (count == 0) // !isSharable return false; @@ -86,24 +86,24 @@ public: bool isSharable() const noexcept { // Sharable === Shared ownership. - return atomic.load() != 0; + return atomic.loadRelaxed() != 0; } #endif bool isStatic() const noexcept { // Persistent object, never deleted - return atomic.load() == -1; + return atomic.loadRelaxed() == -1; } bool isShared() const noexcept { - int count = atomic.load(); + int count = atomic.loadRelaxed(); return (count != 1) && (count != 0); } - void initializeOwned() noexcept { atomic.store(1); } - void initializeUnsharable() noexcept { atomic.store(0); } + void initializeOwned() noexcept { atomic.storeRelaxed(1); } + void initializeUnsharable() noexcept { atomic.storeRelaxed(0); } QBasicAtomicInt atomic; }; diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index e64610b93b..128df84053 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -1707,7 +1707,7 @@ void QRegExpEngine::dump() const void QRegExpEngine::setup() { - ref.store(1); + ref.storeRelaxed(1); #ifndef QT_NO_REGEXP_CAPTURE f.resize(32); nf = 0; diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index 816583c766..ab54c76720 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -75,7 +75,7 @@ public: typedef T Type; typedef T *pointer; - inline void detach() { if (d && d->ref.load() != 1) detach_helper(); } + inline void detach() { if (d && d->ref.loadRelaxed() != 1) detach_helper(); } inline T &operator*() { detach(); return *d; } inline const T &operator*() const { return *d; } inline T *operator->() { detach(); return d; } @@ -163,7 +163,7 @@ public: inline const T *constData() const { return d; } inline T *take() { T *x = d; d = nullptr; return x; } - inline void detach() { if (d && d->ref.load() != 1) detach_helper(); } + inline void detach() { if (d && d->ref.loadRelaxed() != 1) detach_helper(); } inline void reset() { diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index e4de5a2ba9..f185d2f23f 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1380,7 +1380,7 @@ void QtSharedPointer::ExternalRefCountData::setQObjectShared(const QObject *, bo */ void QtSharedPointer::ExternalRefCountData::checkQObjectShared(const QObject *) { - if (strongref.load() < 0) + if (strongref.loadRelaxed() < 0) qWarning("QSharedPointer: cannot create a QSharedPointer from a QObject-tracking QWeakPointer"); } @@ -1390,7 +1390,7 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge QObjectPrivate *d = QObjectPrivate::get(const_cast<QObject *>(obj)); Q_ASSERT_X(!d->wasDeleted, "QWeakPointer", "Detected QWeakPointer creation in a QObject being deleted"); - ExternalRefCountData *that = d->sharedRefcount.load(); + ExternalRefCountData *that = d->sharedRefcount.loadRelaxed(); if (that) { that->weakref.ref(); return that; @@ -1398,8 +1398,8 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge // we can create the refcount data because it doesn't exist ExternalRefCountData *x = new ExternalRefCountData(Qt::Uninitialized); - x->strongref.store(-1); - x->weakref.store(2); // the QWeakPointer that called us plus the QObject itself + x->strongref.storeRelaxed(-1); + x->weakref.storeRelaxed(2); // the QWeakPointer that called us plus the QObject itself ExternalRefCountData *ret; if (d->sharedRefcount.testAndSetOrdered(nullptr, x, ret)) { // ought to be release+acquire; this is acq_rel+acquire @@ -1407,7 +1407,7 @@ QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::ge } else { // ~ExternalRefCountData has a Q_ASSERT, so we use this trick to // only execute this if Q_ASSERTs are enabled - Q_ASSERT((x->weakref.store(0), true)); + Q_ASSERT((x->weakref.storeRelaxed(0), true)); delete x; ret->weakref.ref(); } diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index f352e433c5..198cc58c38 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -154,11 +154,11 @@ namespace QtSharedPointer { inline ExternalRefCountData(DestroyerFn d) : destroyer(d) { - strongref.store(1); - weakref.store(1); + strongref.storeRelaxed(1); + weakref.storeRelaxed(1); } inline ExternalRefCountData(Qt::Initialization) { } - ~ExternalRefCountData() { Q_ASSERT(!weakref.load()); Q_ASSERT(strongref.load() <= 0); } + ~ExternalRefCountData() { Q_ASSERT(!weakref.loadRelaxed()); Q_ASSERT(strongref.loadRelaxed() <= 0); } void destroy() { destroyer(this); } @@ -522,12 +522,12 @@ public: if (o) { // increase the strongref, but never up from zero // or less (-1 is used by QWeakPointer on untracked QObject) - int tmp = o->strongref.load(); + int tmp = o->strongref.loadRelaxed(); while (tmp > 0) { // try to increment from "tmp" to "tmp + 1" if (o->strongref.testAndSetRelaxed(tmp, tmp + 1)) break; // succeeded - tmp = o->strongref.load(); // failed, try again + tmp = o->strongref.loadRelaxed(); // failed, try again } if (tmp > 0) { @@ -540,7 +540,7 @@ public: qSwap(d, o); qSwap(this->value, actual); - if (!d || d->strongref.load() == 0) + if (!d || d->strongref.loadRelaxed() == 0) this->value = nullptr; // dereference saved data @@ -566,7 +566,7 @@ public: typedef const value_type &const_reference; typedef qptrdiff difference_type; - bool isNull() const noexcept { return d == nullptr || d->strongref.load() == 0 || value == nullptr; } + bool isNull() const noexcept { return d == nullptr || d->strongref.loadRelaxed() == 0 || value == nullptr; } operator RestrictedBool() const noexcept { return isNull() ? nullptr : &QWeakPointer::value; } bool operator !() const noexcept { return isNull(); } @@ -709,7 +709,7 @@ public: // a weak pointer's data but the weak pointer itself inline T *internalData() const noexcept { - return d == nullptr || d->strongref.load() == 0 ? nullptr : value; + return d == nullptr || d->strongref.loadRelaxed() == 0 ? nullptr : value; } Data *d; diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index ddd715f745..ecf1822e42 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -563,9 +563,9 @@ quint64 qDetectCpuFeatures() features_string + features_indices[qCountTrailingZeroBits(missing)]); } - qt_cpu_features[0].store(f | quint32(QSimdInitialized)); + qt_cpu_features[0].storeRelaxed(f | quint32(QSimdInitialized)); #ifndef Q_ATOMIC_INT64_IS_SUPPORTED - qt_cpu_features[1].store(f >> 32); + qt_cpu_features[1].storeRelaxed(f >> 32); #endif return f; } diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index c36e1e484f..db2f546651 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -348,9 +348,9 @@ Q_CORE_EXPORT quint64 qDetectCpuFeatures(); static inline quint64 qCpuFeatures() { - quint64 features = qt_cpu_features[0].load(); + quint64 features = qt_cpu_features[0].loadRelaxed(); #ifndef Q_ATOMIC_INT64_IS_SUPPORTED - features |= quint64(qt_cpu_features[1].load()) << 32; + features |= quint64(qt_cpu_features[1].loadRelaxed()) << 32; #endif if (Q_UNLIKELY(features == 0)) { features = qDetectCpuFeatures(); |