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