diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 29d632ef04..60c4a7b174 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -105,7 +105,7 @@ inline constexpr T qbswap(T source) return T(qbswap_helper(typename QIntegerForSizeof::Unsigned(source))); } -#ifdef __SIZEOF_INT128__ +#ifdef QT_SUPPORTS_INT128 // extra definitions for q(u)int128, in case std::is_integral_v<~~> == false inline constexpr quint128 qbswap(quint128 source) { diff --git a/src/corelib/global/qtypes.h b/src/corelib/global/qtypes.h index 954f22a191..6a4b6acf39 100644 --- a/src/corelib/global/qtypes.h +++ b/src/corelib/global/qtypes.h @@ -58,7 +58,13 @@ typedef unsigned long long quint64; /* 64 bit unsigned */ typedef qint64 qlonglong; typedef quint64 qulonglong; -#if defined(__SIZEOF_INT128__) +#if defined(__SIZEOF_INT128__) && !defined(QT_NO_INT128) +# define QT_SUPPORTS_INT128 __SIZEOF_INT128__ +#else +# undef QT_SUPPORTS_INT128 +#endif + +#if defined(QT_SUPPORTS_INT128) __extension__ typedef __int128_t qint128; __extension__ typedef __uint128_t quint128; #endif @@ -107,7 +113,7 @@ template <> struct QIntegerForSize<1> { typedef quint8 Unsigned; typedef qin template <> struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; }; template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; }; template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; }; -#if defined(__SIZEOF_INT128__) +#if defined(QT_SUPPORTS_INT128) template <> struct QIntegerForSize<16> { typedef quint128 Unsigned; typedef qint128 Signed; }; #endif template struct QIntegerForSizeof: QIntegerForSize { }; diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index ddd24eb678..2cefb4d764 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -60,7 +60,7 @@ public: quint16 data16[8]; quint32 data32[4]; quint64 data64[2]; -#ifdef __SIZEOF_INT128__ +#ifdef QT_SUPPORTS_INT128 quint128 data128[1]; #endif @@ -100,7 +100,7 @@ public: bool isNull() const noexcept; -#ifdef __SIZEOF_INT128__ +#ifdef QT_SUPPORTS_INT128 constexpr QUuid(quint128 uuid, QSysInfo::Endian order = QSysInfo::BigEndian) noexcept; constexpr quint128 toUInt128(QSysInfo::Endian order = QSysInfo::BigEndian) const noexcept; #endif @@ -242,7 +242,7 @@ inline QUuid QUuid::fromBytes(const void *bytes, QSysInfo::Endian order) noexcep return QUuid(result, order); } -#ifdef __SIZEOF_INT128__ +#ifdef QT_SUPPORTS_INT128 constexpr QUuid::QUuid(quint128 uuid, QSysInfo::Endian order) noexcept : QUuid() { diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index b9fcf585fb..08f548a834 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -248,7 +248,7 @@ void tst_QUuid::id128() void tst_QUuid::uint128() { -#ifdef __SIZEOF_INT128__ +#ifdef QT_SUPPORTS_INT128 constexpr quint128 u = quint128(Q_UINT64_C(0xfc69b59ecc344436)) << 64 | Q_UINT64_C(0xa43cee95d128b8c5); // This is LE constexpr quint128 be = qToBigEndian(u);