diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-10-21 15:19:18 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-10-29 10:37:02 +0100 |
commit | 226a60baf50c9c91a98c01c3dd9c0ced750f8d0e (patch) | |
tree | d9c57735a34f963eaafbe895f094d0009d262408 /src/corelib/tools | |
parent | 8bcecd86fac60475a7236787b4b89460fa89d612 (diff) |
Replace Q_ALIGNOF usage in qtbase with C++11 alignof keyword
The macro is not documented, so not part of the public Qt API. It is
made obsolete by the alignof keyword in C++11.
Remove the usage of the macro across qtbase, in particular the
workarounds for compilers that didn't support alignof, and that will
not be supported in Qt 6.
The macro definition is left in place, no need to break existing
code.
Task-number: QTBUG-76414
Change-Id: I1cfedcd4dd748128696cdfb546d97aae4f98c3da
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qarraydata.cpp | 8 | ||||
-rw-r--r-- | src/corelib/tools/qarraydata.h | 6 | ||||
-rw-r--r-- | src/corelib/tools/qcontiguouscache.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qhash.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qmap.h | 4 |
5 files changed, 11 insertions, 11 deletions
diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index 36a221f728..cc71a040fa 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -193,7 +193,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, size_t capacity, AllocationOptions options) noexcept { // Alignment is a power of two - Q_ASSERT(alignment >= Q_ALIGNOF(QArrayData) + Q_ASSERT(alignment >= alignof(QArrayData) && !(alignment & (alignment - 1))); // Don't allocate empty headers @@ -207,12 +207,12 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, size_t headerSize = sizeof(QArrayData); - // Allocate extra (alignment - Q_ALIGNOF(QArrayData)) padding bytes so we + // Allocate extra (alignment - alignof(QArrayData)) padding bytes so we // can properly align the data array. This assumes malloc is able to // provide appropriate alignment for the header -- as it should! // Padding is skipped when allocating a header for RawData. if (!(options & RawData)) - headerSize += (alignment - Q_ALIGNOF(QArrayData)); + headerSize += (alignment - alignof(QArrayData)); if (headerSize > size_t(MaxAllocSize)) return nullptr; @@ -256,7 +256,7 @@ void QArrayData::deallocate(QArrayData *data, size_t objectSize, size_t alignment) noexcept { // Alignment is a power of two - Q_ASSERT(alignment >= Q_ALIGNOF(QArrayData) + Q_ASSERT(alignment >= alignof(QArrayData) && !(alignment & (alignment - 1))); Q_UNUSED(objectSize) Q_UNUSED(alignment) diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index dcd95924c1..695cc957d6 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -222,7 +222,7 @@ struct QTypedArrayData { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); return static_cast<QTypedArrayData *>(QArrayData::allocate(sizeof(T), - Q_ALIGNOF(AlignmentDummy), capacity, options)); + alignof(AlignmentDummy), capacity, options)); } static QTypedArrayData *reallocateUnaligned(QTypedArrayData *data, size_t capacity, @@ -236,7 +236,7 @@ struct QTypedArrayData static void deallocate(QArrayData *data) { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); - QArrayData::deallocate(data, sizeof(T), Q_ALIGNOF(AlignmentDummy)); + QArrayData::deallocate(data, sizeof(T), alignof(AlignmentDummy)); } static QTypedArrayData *fromRawData(const T *data, size_t n, @@ -295,7 +295,7 @@ struct QArrayDataPointerRef #define Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER(type, size) \ Q_STATIC_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(size,\ - ((sizeof(QArrayData) + (Q_ALIGNOF(type) - 1)) & ~(Q_ALIGNOF(type) - 1) )) \ + ((sizeof(QArrayData) + (alignof(type) - 1)) & ~(alignof(type) - 1) )) \ /**/ //////////////////////////////////////////////////////////////////////////////// diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 7b74b4f526..3151c57b43 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -166,7 +166,7 @@ private: } int alignOfTypedData() const { - return qMax<int>(sizeof(void*), Q_ALIGNOF(Data)); + return qMax<int>(sizeof(void*), alignof(Data)); } }; diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 236e433101..d915415893 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -235,7 +235,7 @@ class QHash return reinterpret_cast<Node *>(node); } - static inline int alignOfNode() { return qMax<int>(sizeof(void*), Q_ALIGNOF(Node)); } + static inline int alignOfNode() { return qMax<int>(sizeof(void*), alignof(Node)); } public: inline QHash() noexcept : d(const_cast<QHashData *>(&QHashData::shared_null)) { } diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index 18c681581f..e1a78982fd 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -219,7 +219,7 @@ struct QMapData : public QMapDataBase Node *createNode(const Key &k, const T &v, Node *parent = nullptr, bool left = false) { - Node *n = static_cast<Node *>(QMapDataBase::createNode(sizeof(Node), Q_ALIGNOF(Node), + Node *n = static_cast<Node *>(QMapDataBase::createNode(sizeof(Node), alignof(Node), parent, left)); QT_TRY { new (&n->key) Key(k); @@ -243,7 +243,7 @@ struct QMapData : public QMapDataBase void destroy() { if (root()) { root()->destroySubTree(); - freeTree(header.left, Q_ALIGNOF(Node)); + freeTree(header.left, alignof(Node)); } freeData(this); } |