diff options
Diffstat (limited to 'src/corelib/global/qglobal.cpp')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 22fc20d47e..ea9d207177 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -112,6 +112,38 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n); Q_STATIC_ASSERT_X(sizeof(int) == 4, "Qt assumes that int is 32 bits"); Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorrectly"); +Q_STATIC_ASSERT_X(sizeof(float) == 4, "Qt assumes that float is 32 bits"); + +// While we'd like to check for __STDC_IEC_559__, as per ISO/IEC 9899:2011 +// Annex F (C11, normative for C++11), there are a few corner cases regarding +// denormals where GHS compiler is relying hardware behavior that is not IEC +// 559 compliant. So split the check in several subchecks. + +// On GHC the compiler reports std::numeric_limits<float>::is_iec559 as false. +// This is all right according to our needs. +#if !defined(Q_CC_GHS) +Q_STATIC_ASSERT_X(std::numeric_limits<float>::is_iec559, + "Qt assumes IEEE 754 floating point"); +#endif + +// Technically, presence of NaN and infinities are implied from the above check, +// but double checking our environment doesn't hurt... +Q_STATIC_ASSERT_X(std::numeric_limits<float>::has_infinity && + std::numeric_limits<float>::has_quiet_NaN && + std::numeric_limits<float>::has_signaling_NaN, + "Qt assumes IEEE 754 floating point"); + +// is_iec559 checks for ISO/IEC/IEEE 60559:2011 (aka IEEE 754-2008) compliance, +// but that allows for a non-binary radix. We need to recheck that. +// Note how __STDC_IEC_559__ would instead check for IEC 60559:1989, aka +// ANSI/IEEE 754−1985, which specifically implies binary floating point numbers. +Q_STATIC_ASSERT_X(std::numeric_limits<float>::radix == 2, + "Qt assumes binary IEEE 754 floating point"); + +// not required by the definition of size_t, but we depend on this +Q_STATIC_ASSERT_X(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size"); +Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qssize_t)); // implied by the definition +Q_STATIC_ASSERT((std::is_same<qssize_t, qptrdiff>::value)); /*! \class QFlag @@ -774,6 +806,21 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in */ /*! + \typedef qssize_t + \relates <QtGlobal> + \since 5.10 + + Integral type providing Posix' \c ssize_t for all platforms. + + This type is guaranteed to be the same size as a \c size_t on all + platforms supported by Qt. + + Note that qssize_t is signed. Use \c size_t for unsigned values. + + \sa qptrdiff +*/ + +/*! \enum QtMsgType \relates <QtGlobal> @@ -3058,7 +3105,7 @@ void qt_assert_x(const char *where, const char *what, const char *file, int line Deliberately not exported as part of the Qt API, but used in both qsimplerichtext.cpp and qgfxraster_qws.cpp */ -Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n) +Q_CORE_EXPORT Q_DECL_CONST_FUNCTION unsigned int qt_int_sqrt(unsigned int n) { // n must be in the range 0...UINT_MAX/2-1 if (n >= (UINT_MAX>>2)) { @@ -4429,8 +4476,11 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters) stderr. Under Windows, the message is sent to the debugger. On QNX the message is sent to slogger2. This function does nothing if \c QT_NO_WARNING_OUTPUT was defined - during compilation; it exits if the environment variable \c - QT_FATAL_WARNINGS is not empty. + during compilation; it exits if at the nth warning corresponding to the + counter in environment variable \c QT_FATAL_WARNINGS. That is, if the + environment variable contains the value 1, it will exit on the 1st message; + if it contains the value 10, it will exit on the 10th message. Any + non-numeric value is equivalent to 1. This function takes a format string and a list of arguments, similar to the C printf() function. The format should be a Latin-1 |