File indexing completed on 2025-12-15 10:24:33
0001
0002
0003
0004
0005 #ifndef QTYPES_H
0006 #define QTYPES_H
0007
0008 #include <QtCore/qprocessordetection.h>
0009 #include <QtCore/qsystemdetection.h>
0010 #include <QtCore/qtconfigmacros.h>
0011 #include <QtCore/qassert.h>
0012
0013 #ifdef __cplusplus
0014 # include <cstddef>
0015 # if defined(_HAS_STD_BYTE) && _HAS_STD_BYTE == 0
0016 # error "Qt requires std::byte, but _HAS_STD_BYTE has been set to 0"
0017 # endif
0018 # include <cstdint>
0019 # if defined(__STDCPP_FLOAT16_T__) && __has_include(<stdfloat>)
0020
0021 # include <stdfloat>
0022 # endif
0023 # include <type_traits>
0024 #else
0025 # include <assert.h>
0026 #endif
0027
0028 #if 0
0029 #pragma qt_class(QtTypes)
0030 #pragma qt_class(QIntegerForSize)
0031 #pragma qt_sync_stop_processing
0032 #endif
0033
0034
0035
0036
0037 typedef unsigned char uchar;
0038 typedef unsigned short ushort;
0039 typedef unsigned int uint;
0040 typedef unsigned long ulong;
0041
0042 QT_BEGIN_NAMESPACE
0043
0044
0045
0046
0047
0048
0049
0050 typedef signed char qint8;
0051 typedef unsigned char quint8;
0052 typedef short qint16;
0053 typedef unsigned short quint16;
0054 typedef int qint32;
0055 typedef unsigned int quint32;
0056
0057
0058 #ifdef __cplusplus
0059 # define Q_INT64_C(c) static_cast<long long>(c ## LL)
0060 # define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL)
0061 #else
0062 # define Q_INT64_C(c) ((long long)(c ## LL))
0063 # define Q_UINT64_C(c) ((unsigned long long)(c ## ULL))
0064 #endif
0065 typedef long long qint64;
0066 typedef unsigned long long quint64;
0067
0068 typedef qint64 qlonglong;
0069 typedef quint64 qulonglong;
0070
0071 #ifdef Q_QDOC
0072 # define QT_SUPPORTS_INT128 16
0073 #elif defined(QT_COMPILER_SUPPORTS_INT128) && !defined(QT_NO_INT128)
0074 # define QT_SUPPORTS_INT128 QT_COMPILER_SUPPORTS_INT128
0075 # if defined(__GLIBCXX__) && defined(__STRICT_ANSI__)
0076 # undef QT_SUPPORTS_INT128
0077 # endif
0078 # if defined(__clang__) && defined(_MSVC_STL_VERSION)
0079 # undef QT_SUPPORTS_INT128
0080 # endif
0081 #else
0082 # undef QT_SUPPORTS_INT128
0083 #endif
0084
0085 #if defined(QT_SUPPORTS_INT128)
0086 __extension__ typedef __int128_t qint128;
0087 __extension__ typedef __uint128_t quint128;
0088
0089 #ifdef __cplusplus
0090 static_assert(std::is_signed_v<qint128>,
0091 "Qt requires <type_traits> and <limits> to work for q(u)int128.");
0092 #endif
0093
0094
0095 # ifdef __cplusplus
0096 # define QT_C_STYLE_CAST(type, x) static_cast<type>(x)
0097 # else
0098 # define QT_C_STYLE_CAST(type, x) ((type)(x))
0099 # endif
0100 # ifndef Q_UINT128_MAX
0101 # define Q_UINT128_MAX QT_C_STYLE_CAST(quint128, -1)
0102 # endif
0103 # define Q_INT128_MAX QT_C_STYLE_CAST(qint128, Q_UINT128_MAX / 2)
0104 # define Q_INT128_MIN (-Q_INT128_MAX - 1)
0105
0106 # ifdef __cplusplus
0107 namespace QtPrivate::NumberLiterals {
0108 namespace detail {
0109 template <quint128 accu, int base>
0110 constexpr quint128 construct() { return accu; }
0111
0112 template <quint128 accu, int base, char C, char...Cs>
0113 constexpr quint128 construct()
0114 {
0115 if constexpr (C != '\'') {
0116 const int digitValue = '0' <= C && C <= '9' ? C - '0' :
0117 'a' <= C && C <= 'z' ? C - 'a' + 10 :
0118 'A' <= C && C <= 'Z' ? C - 'A' + 10 :
0119 -1 ;
0120 static_assert(digitValue >= 0 && digitValue < base,
0121 "Invalid character");
0122
0123 static_assert(accu <= (Q_UINT128_MAX - digitValue) / base,
0124 "Overflow occurred");
0125 return construct<accu * base + digitValue, base, Cs...>();
0126 } else {
0127 return construct<accu, base, Cs...>();
0128 }
0129 }
0130
0131 template <char C, char...Cs>
0132 constexpr quint128 parse0xb()
0133 {
0134 constexpr quint128 accu = 0;
0135 if constexpr (C == 'x' || C == 'X')
0136 return construct<accu, 16, Cs...>();
0137 else if constexpr (C == 'b' || C == 'B')
0138 return construct<accu, 2, Cs...>();
0139 else
0140 return construct<accu, 8, C, Cs...>();
0141 }
0142
0143 template <char...Cs>
0144 constexpr quint128 parse0()
0145 {
0146 if constexpr (sizeof...(Cs) == 0)
0147 return 0;
0148 else
0149 return parse0xb<Cs...>();
0150 }
0151
0152 template <char C, char...Cs>
0153 constexpr quint128 parse()
0154 {
0155 if constexpr (C == '0')
0156 return parse0<Cs...>();
0157 else
0158 return construct<0, 10, C, Cs...>();
0159 }
0160 }
0161 template <char...Cs>
0162 constexpr quint128 operator""_quint128() noexcept
0163 { return QtPrivate::NumberLiterals::detail::parse<Cs...>(); }
0164 template <char...Cs>
0165 constexpr qint128 operator""_qint128() noexcept
0166 { return qint128(QtPrivate::NumberLiterals::detail::parse<Cs...>()); }
0167
0168 #ifndef Q_UINT128_C
0169 # define Q_UINT128_C(c) ([]{ using namespace QtPrivate::NumberLiterals; return c ## _quint128; }())
0170 #endif
0171 #ifndef Q_INT128_C
0172 # define Q_INT128_C(c) ([]{ using namespace QtPrivate::NumberLiterals; return c ## _qint128; }())
0173 #endif
0174
0175 }
0176 # endif
0177 #endif
0178
0179 #ifndef __cplusplus
0180
0181 static_assert(sizeof(ptrdiff_t) == sizeof(size_t), "Weird ptrdiff_t and size_t definitions");
0182 typedef ptrdiff_t qptrdiff;
0183 typedef ptrdiff_t qsizetype;
0184 typedef ptrdiff_t qintptr;
0185 typedef size_t quintptr;
0186
0187 #define PRIdQPTRDIFF "td"
0188 #define PRIiQPTRDIFF "ti"
0189
0190 #define PRIdQSIZETYPE "td"
0191 #define PRIiQSIZETYPE "ti"
0192
0193 #define PRIdQINTPTR "td"
0194 #define PRIiQINTPTR "ti"
0195
0196 #define PRIuQUINTPTR "zu"
0197 #define PRIoQUINTPTR "zo"
0198 #define PRIxQUINTPTR "zx"
0199 #define PRIXQUINTPTR "zX"
0200 #endif
0201
0202 #if defined(QT_COORD_TYPE)
0203 typedef QT_COORD_TYPE qreal;
0204 #else
0205 typedef double qreal;
0206 #endif
0207
0208 #if defined(__cplusplus)
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218 template <int> struct QIntegerForSize;
0219 template <> struct QIntegerForSize<1> { typedef quint8 Unsigned; typedef qint8 Signed; };
0220 template <> struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; };
0221 template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; };
0222 template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; };
0223 #if defined(QT_SUPPORTS_INT128)
0224 template <> struct QIntegerForSize<16> { typedef quint128 Unsigned; typedef qint128 Signed; };
0225 #endif
0226 template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
0227 typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Signed qregisterint;
0228 typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint;
0229 typedef QIntegerForSizeof<void *>::Unsigned quintptr;
0230 typedef QIntegerForSizeof<void *>::Signed qptrdiff;
0231 typedef qptrdiff qintptr;
0232 using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243 #if SIZE_MAX == 0xffffffffULL
0244 #define PRIuQUINTPTR "u"
0245 #define PRIoQUINTPTR "o"
0246 #define PRIxQUINTPTR "x"
0247 #define PRIXQUINTPTR "X"
0248
0249 #define PRIdQPTRDIFF "d"
0250 #define PRIiQPTRDIFF "i"
0251
0252 #define PRIdQINTPTR "d"
0253 #define PRIiQINTPTR "i"
0254
0255 #define PRIdQSIZETYPE "d"
0256 #define PRIiQSIZETYPE "i"
0257 #elif SIZE_MAX == 0xffffffffffffffffULL
0258 #define PRIuQUINTPTR "llu"
0259 #define PRIoQUINTPTR "llo"
0260 #define PRIxQUINTPTR "llx"
0261 #define PRIXQUINTPTR "llX"
0262
0263 #define PRIdQPTRDIFF "lld"
0264 #define PRIiQPTRDIFF "lli"
0265
0266 #define PRIdQINTPTR "lld"
0267 #define PRIiQINTPTR "lli"
0268
0269 #define PRIdQSIZETYPE "lld"
0270 #define PRIiQSIZETYPE "lli"
0271 #else
0272 #error Unsupported platform (unknown value for SIZE_MAX)
0273 #endif
0274
0275
0276 namespace QtPrivate {
0277 #if defined(__STDCPP_FLOAT16_T__)
0278 # define QFLOAT16_IS_NATIVE 1
0279 using NativeFloat16Type = std::float16_t;
0280 #elif defined(Q_CC_CLANG) && defined(__FLT16_MAX__) && 0
0281
0282 # define QFLOAT16_IS_NATIVE 1
0283 using NativeFloat16Type = decltype(__FLT16_MAX__);
0284 #elif defined(Q_CC_GNU_ONLY) && defined(__FLT16_MAX__) && defined(__ARM_FP16_FORMAT_IEEE)
0285 # define QFLOAT16_IS_NATIVE 1
0286 using NativeFloat16Type = __fp16;
0287 #elif defined(Q_CC_GNU_ONLY) && defined(__FLT16_MAX__) && defined(__SSE2__)
0288 # define QFLOAT16_IS_NATIVE 1
0289 using NativeFloat16Type = _Float16;
0290 #else
0291 # define QFLOAT16_IS_NATIVE 0
0292 using NativeFloat16Type = void;
0293 #endif
0294 }
0295
0296 #endif
0297
0298 QT_END_NAMESPACE
0299
0300 #endif