diff options
Diffstat (limited to 'src/corelib/global/qglobal.h')
-rw-r--r-- | src/corelib/global/qglobal.h | 135 |
1 files changed, 1 insertions, 134 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index b475c9cc64..82c6e5e037 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -7,7 +7,6 @@ #if 0 #pragma qt_class(QtGlobal) -#pragma qt_class(QIntegerForSize) #endif #ifdef __cplusplus @@ -98,6 +97,7 @@ inline void qt_noop(void) {} #include <QtCore/qcompilerdetection.h> #include <QtCore/qassert.h> +#include <QtCore/qtypes.h> #if defined (__ELF__) # define Q_OF_ELF @@ -115,73 +115,6 @@ inline void qt_noop(void) {} QT_BEGIN_NAMESPACE /* - Size-dependent types (architechture-dependent byte order) - - Make sure to update QMetaType when changing these typedefs -*/ - -typedef signed char qint8; /* 8 bit signed */ -typedef unsigned char quint8; /* 8 bit unsigned */ -typedef short qint16; /* 16 bit signed */ -typedef unsigned short quint16; /* 16 bit unsigned */ -typedef int qint32; /* 32 bit signed */ -typedef unsigned int quint32; /* 32 bit unsigned */ -// Unlike LL / ULL in C++, for historical reasons, we force the -// result to be of the requested type. -#ifdef __cplusplus -# define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */ -# define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */ -#else -# define Q_INT64_C(c) ((long long)(c ## LL)) /* signed 64 bit constant */ -# define Q_UINT64_C(c) ((unsigned long long)(c ## ULL)) /* unsigned 64 bit constant */ -#endif -typedef long long qint64; /* 64 bit signed */ -typedef unsigned long long quint64; /* 64 bit unsigned */ - -typedef qint64 qlonglong; -typedef quint64 qulonglong; - -#ifndef __cplusplus -// In C++ mode, we define below using QIntegerForSize template -Q_STATIC_ASSERT_X(sizeof(ptrdiff_t) == sizeof(size_t), "Weird ptrdiff_t and size_t definitions"); -typedef ptrdiff_t qptrdiff; -typedef ptrdiff_t qsizetype; -typedef ptrdiff_t qintptr; -typedef size_t quintptr; - -#define PRIdQPTRDIFF "td" -#define PRIiQPTRDIFF "ti" - -#define PRIdQSIZETYPE "td" -#define PRIiQSIZETYPE "ti" - -#define PRIdQINTPTR "td" -#define PRIiQINTPTR "ti" - -#define PRIuQUINTPTR "zu" -#define PRIoQUINTPTR "zo" -#define PRIxQUINTPTR "zx" -#define PRIXQUINTPTR "zX" -#endif - -/* - Useful type definitions for Qt -*/ - -QT_BEGIN_INCLUDE_NAMESPACE -typedef unsigned char uchar; -typedef unsigned short ushort; -typedef unsigned int uint; -typedef unsigned long ulong; -QT_END_INCLUDE_NAMESPACE - -#if defined(QT_COORD_TYPE) -typedef QT_COORD_TYPE qreal; -#else -typedef double qreal; -#endif - -/* Some classes do not permit copies to be made of an object. These classes contains a private copy constructor and assignment operator to disable copying (the compiler gives an error message). @@ -297,72 +230,6 @@ Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char *qVersion(void) Q_DECL_NOEXCEPT; # define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC) #endif -/* - quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e. - - sizeof(void *) == sizeof(quintptr) - && sizeof(void *) == sizeof(qptrdiff) - - size_t and qsizetype are not guaranteed to be the same size as a pointer, but - they usually are. We actually check for that in qglobal.cpp. -*/ -template <int> struct QIntegerForSize; -template <> struct QIntegerForSize<1> { typedef quint8 Unsigned; typedef qint8 Signed; }; -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(Q_CC_GNU) && defined(__SIZEOF_INT128__) -template <> struct QIntegerForSize<16> { __extension__ typedef unsigned __int128 Unsigned; __extension__ typedef __int128 Signed; }; -#endif -template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { }; -typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Signed qregisterint; -typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint; -typedef QIntegerForSizeof<void *>::Unsigned quintptr; -typedef QIntegerForSizeof<void *>::Signed qptrdiff; -typedef qptrdiff qintptr; -using qsizetype = QIntegerForSizeof<std::size_t>::Signed; - -// These custom definitions are necessary as we're not defining our -// datatypes in terms of the language ones, but in terms of integer -// types that have the sime size. For instance, on a 32-bit platform, -// qptrdiff is int, while ptrdiff_t may be aliased to long; therefore -// using %td to print a qptrdiff would be wrong (and raise -Wformat -// warnings), although both int and long have same bit size on that -// platform. -// -// We know that sizeof(size_t) == sizeof(void *) == sizeof(qptrdiff). -#if SIZE_MAX == 4294967295ULL -#define PRIuQUINTPTR "u" -#define PRIoQUINTPTR "o" -#define PRIxQUINTPTR "x" -#define PRIXQUINTPTR "X" - -#define PRIdQPTRDIFF "d" -#define PRIiQPTRDIFF "i" - -#define PRIdQINTPTR "d" -#define PRIiQINTPTR "i" - -#define PRIdQSIZETYPE "d" -#define PRIiQSIZETYPE "i" -#elif SIZE_MAX == 18446744073709551615ULL -#define PRIuQUINTPTR "llu" -#define PRIoQUINTPTR "llo" -#define PRIxQUINTPTR "llx" -#define PRIXQUINTPTR "llX" - -#define PRIdQPTRDIFF "lld" -#define PRIiQPTRDIFF "lli" - -#define PRIdQINTPTR "lld" -#define PRIiQINTPTR "lli" - -#define PRIdQSIZETYPE "lld" -#define PRIiQSIZETYPE "lli" -#else -#error Unsupported platform (unknown value for SIZE_MAX) -#endif - /* moc compats (signals/slots) */ #ifndef QT_MOC_COMPAT # define QT_MOC_COMPAT |