summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qendian.h17
-rw-r--r--src/corelib/global/qtypes.h7
2 files changed, 23 insertions, 1 deletions
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h
index 9cd0044cbc6..29d632ef04d 100644
--- a/src/corelib/global/qendian.h
+++ b/src/corelib/global/qendian.h
@@ -105,6 +105,23 @@ inline constexpr T qbswap(T source)
return T(qbswap_helper(typename QIntegerForSizeof<T>::Unsigned(source)));
}
+#ifdef __SIZEOF_INT128__
+// extra definitions for q(u)int128, in case std::is_integral_v<~~> == false
+inline constexpr quint128 qbswap(quint128 source)
+{
+ quint128 result = {};
+ result = qbswap_helper(quint64(source));
+ result <<= 64;
+ result |= qbswap_helper(quint64(source >> 64));
+ return result;
+}
+
+inline constexpr quint128 qbswap(qint128 source)
+{
+ return qint128(qbswap(quint128(source)));
+}
+#endif
+
// floating specializations
template<typename Float>
Float qbswapFloatHelper(Float source)
diff --git a/src/corelib/global/qtypes.h b/src/corelib/global/qtypes.h
index d08a919c136..412ab3af623 100644
--- a/src/corelib/global/qtypes.h
+++ b/src/corelib/global/qtypes.h
@@ -58,6 +58,11 @@ typedef unsigned long long quint64; /* 64 bit unsigned */
typedef qint64 qlonglong;
typedef quint64 qulonglong;
+#if defined(__SIZEOF_INT128__)
+__extension__ typedef __int128_t qint128;
+__extension__ typedef __uint128_t quint128;
+#endif
+
#ifndef __cplusplus
// In C++ mode, we define below using QIntegerForSize template
static_assert(sizeof(ptrdiff_t) == sizeof(size_t), "Weird ptrdiff_t and size_t definitions");
@@ -103,7 +108,7 @@ template <> struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qin
template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; };
#if defined(Q_CC_GNU) && defined(__SIZEOF_INT128__)
-template <> struct QIntegerForSize<16> { __extension__ typedef unsigned __int128 Unsigned; __extension__ typedef __int128 Signed; };
+template <> struct QIntegerForSize<16> { typedef quint128 Unsigned; typedef qint128 Signed; };
#endif
template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Signed qregisterint;