diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 10 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 47 | ||||
-rw-r--r-- | src/corelib/global/qrandom.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobjectbuilder.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 2 | ||||
-rw-r--r-- | src/corelib/serialization/qcborvalue_p.h | 6 | ||||
-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 |
11 files changed, 19 insertions, 72 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index e47f284a42..b173dcf522 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -91,7 +91,6 @@ # define Q_OUTOFLINE_TEMPLATE inline # define Q_COMPILER_MANGLES_RETURN_TYPE # define Q_FUNC_INFO __FUNCSIG__ -# define Q_ALIGNOF(type) __alignof(type) # define Q_DECL_ALIGN(n) __declspec(align(n)) # define Q_ASSUME_IMPL(expr) __assume(expr) # define Q_UNREACHABLE_IMPL() __assume(0) @@ -222,7 +221,6 @@ # endif # define Q_FUNC_INFO __PRETTY_FUNCTION__ -# define Q_ALIGNOF(type) __alignof__(type) # define Q_TYPEOF(expr) __typeof__(expr) # define Q_DECL_DEPRECATED __attribute__ ((__deprecated__)) # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) @@ -272,7 +270,6 @@ # if __xlC__ < 0x400 # error "Compiler not supported" # elif __xlC__ >= 0x0600 -# define Q_ALIGNOF(type) __alignof__(type) # define Q_TYPEOF(expr) __typeof__(expr) # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) # define Q_PACKED __attribute__((__packed__)) @@ -352,7 +349,6 @@ # define Q_PACKED __attribute__ ((__packed__)) # define Q_FUNC_INFO __PRETTY_FUNCTION__ # define Q_TYPEOF(expr) __typeof__(expr) -# define Q_ALIGNOF(type) __alignof__(type) # define Q_UNREACHABLE_IMPL() # if defined(__cplusplus) # define Q_COMPILER_AUTO_TYPE @@ -450,7 +446,6 @@ # define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS /* see http://developers.sun.com/sunstudio/support/Ccompare.html */ # if __SUNPRO_CC >= 0x590 -# define Q_ALIGNOF(type) __alignof__(type) # define Q_TYPEOF(expr) __typeof__(expr) # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) # endif @@ -1128,9 +1123,8 @@ #endif #define Q_DECL_NOTHROW Q_DECL_NOEXCEPT -#if defined(Q_COMPILER_ALIGNOF) -# undef Q_ALIGNOF -# define Q_ALIGNOF(x) alignof(x) +#ifndef Q_ALIGNOF +# define Q_ALIGNOF(x) alignof(x) #endif #if defined(Q_COMPILER_ALIGNAS) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 7db7dba9b5..1803b686b9 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -499,53 +499,6 @@ Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOEXCEPT; # define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC) #endif -namespace QtPrivate { - template <class T> - struct AlignOfHelper - { - char c; - T type; - - AlignOfHelper(); - ~AlignOfHelper(); - }; - - template <class T> - struct AlignOf_Default - { - enum { Value = sizeof(AlignOfHelper<T>) - sizeof(T) }; - }; - - template <class T> struct AlignOf : AlignOf_Default<T> { }; - template <class T> struct AlignOf<T &> : AlignOf<T> {}; - template <class T> struct AlignOf<T &&> : AlignOf<T> {}; - template <size_t N, class T> struct AlignOf<T[N]> : AlignOf<T> {}; - -#if defined(Q_PROCESSOR_X86_32) && !defined(Q_OS_WIN) - template <class T> struct AlignOf_WorkaroundForI386Abi { enum { Value = sizeof(T) }; }; - - // x86 ABI weirdness - // Alignment of naked type is 8, but inside struct has alignment 4. - template <> struct AlignOf<double> : AlignOf_WorkaroundForI386Abi<double> {}; - template <> struct AlignOf<qint64> : AlignOf_WorkaroundForI386Abi<qint64> {}; - template <> struct AlignOf<quint64> : AlignOf_WorkaroundForI386Abi<quint64> {}; -#ifdef Q_CC_CLANG - // GCC and Clang seem to disagree wrt to alignment of arrays - template <size_t N> struct AlignOf<double[N]> : AlignOf_Default<double> {}; - template <size_t N> struct AlignOf<qint64[N]> : AlignOf_Default<qint64> {}; - template <size_t N> struct AlignOf<quint64[N]> : AlignOf_Default<quint64> {}; -#endif -#endif -} // namespace QtPrivate - -#define QT_EMULATED_ALIGNOF(T) \ - (size_t(QT_PREPEND_NAMESPACE(QtPrivate)::AlignOf<T>::Value)) - -#ifndef Q_ALIGNOF -#define Q_ALIGNOF(T) QT_EMULATED_ALIGNOF(T) -#endif - - /* quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e. diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index 445b520c76..e1494ab523 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -196,7 +196,7 @@ private: RandomEngine &engine() { return twister; } const RandomEngine &engine() const { return twister; } #else - std::aligned_storage<sizeof(RandomEngine), Q_ALIGNOF(RandomEngine)>::type buffer; + std::aligned_storage<sizeof(RandomEngine), alignof(RandomEngine)>::type buffer; RandomEngine &engine() { return reinterpret_cast<RandomEngine &>(buffer); } const RandomEngine &engine() const { return reinterpret_cast<const RandomEngine &>(buffer); } #endif diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index f77c4ce32f..aab9e05182 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -1103,7 +1103,7 @@ int QMetaStringTable::enter(const QByteArray &value) int QMetaStringTable::preferredAlignment() { - return Q_ALIGNOF(QByteArrayData); + return alignof(QByteArrayData); } // Returns the size (in bytes) required for serializing this string table. diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 449adf0bab..258da1a8d4 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1470,7 +1470,7 @@ static void customConstruct(QVariant::Private *d, const void *copy) } else { // Private::Data contains long long, and long double is the biggest standard type. const size_t maxAlignment = - qMax(Q_ALIGNOF(QVariant::Private::Data), Q_ALIGNOF(long double)); + qMax(alignof(QVariant::Private::Data), alignof(long double)); const size_t s = sizeof(QVariant::PrivateShared); const size_t offset = s + ((s * maxAlignment - s) % maxAlignment); void *data = operator new(offset + size); diff --git a/src/corelib/serialization/qcborvalue_p.h b/src/corelib/serialization/qcborvalue_p.h index 590c2d6e05..38ad54047f 100644 --- a/src/corelib/serialization/qcborvalue_p.h +++ b/src/corelib/serialization/qcborvalue_p.h @@ -147,8 +147,8 @@ public: qptrdiff offset = data.size(); // align offset - offset += Q_ALIGNOF(QtCbor::ByteData) - 1; - offset &= ~(Q_ALIGNOF(QtCbor::ByteData) - 1); + offset += alignof(QtCbor::ByteData) - 1; + offset &= ~(alignof(QtCbor::ByteData) - 1); qptrdiff increment = qptrdiff(sizeof(QtCbor::ByteData)) + len; @@ -170,7 +170,7 @@ public: return nullptr; size_t offset = size_t(e.value); - Q_ASSERT((offset % Q_ALIGNOF(QtCbor::ByteData)) == 0); + Q_ASSERT((offset % alignof(QtCbor::ByteData)) == 0); Q_ASSERT(offset + sizeof(QtCbor::ByteData) <= size_t(data.size())); auto b = reinterpret_cast<const QtCbor::ByteData *>(data.constData() + offset); 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); } |