QTypes: add q{u,}int128 as a first-class, integer type
This is supported on all 64-bit platforms by Clang and GCC and will be used by QUuid, with support in QDataStream and partial support in QTextStream. CBOR also has a reserved "additional information" field for 128-bit quantities, but it's not allowable right now. This conflicts with the quint128 type in QtBluetooth, which was not an integral type. It has been removed in 1e903be81f43da4e31385bb7866bb4d3f07e5eba. Change-Id: Id8e48e8f498c4a029619fffd172893c81aed3481 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
b40ab2f8a6
commit
befda1acca
@ -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)
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user