diff options
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 31 | ||||
-rw-r--r-- | src/corelib/global/qendian.h | 8 | ||||
-rw-r--r-- | src/corelib/global/qglobal.cpp | 23 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 66 | ||||
-rw-r--r-- | src/corelib/global/qhooks.cpp | 11 | ||||
-rw-r--r-- | src/corelib/global/qhooks_p.h | 1 | ||||
-rw-r--r-- | src/corelib/global/qlogging.cpp | 8 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.h | 4 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 23 | ||||
-rw-r--r-- | src/corelib/global/qnumeric_p.h | 111 | ||||
-rw-r--r-- | src/corelib/global/qsystemdetection.h | 65 | ||||
-rw-r--r-- | src/corelib/global/qtypeinfo.h | 14 |
12 files changed, 200 insertions, 165 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index ba830977ad..24d022059d 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1119,6 +1119,37 @@ #endif /* + * SG10's SD-6 feature detection and some useful extensions from Clang and GCC + * https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations + * http://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros + */ +#ifdef __has_builtin +# define QT_HAS_BUILTIN(x) __has_builtin(x) +#else +# define QT_HAS_BUILTIN(x) 0 +#endif +#ifdef __has_attribute +# define QT_HAS_ATTRIBUTE(x) __has_attribute(x) +#else +# define QT_HAS_ATTRIBUTE(x) 0 +#endif +#ifdef __has_cpp_attribute +# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +#else +# define QT_HAS_CPP_ATTRIBUTE(x) 0 +#endif +#ifdef __has_include +# define QT_HAS_INCLUDE(x) __has_include(x) +#else +# define QT_HAS_INCLUDE(x) 0 +#endif +#ifdef __has_include_next +# define QT_HAS_INCLUDE_NEXT(x) __has_include_next(x) +#else +# define QT_HAS_INCLUDE_NEXT(x) 0 +#endif + +/* * Warning/diagnostic handling */ diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 2ddefaec8b..dd0e5a7e5a 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -87,12 +87,6 @@ template <typename T> inline T qFromUnaligned(const uchar *src) */ template <typename T> T qbswap(T source); -#ifdef __has_builtin -# define QT_HAS_BUILTIN(x) __has_builtin(x) -#else -# define QT_HAS_BUILTIN(x) 0 -#endif - // GCC 4.3 implemented all the intrinsics, but the 16-bit one only got implemented in 4.8; // Clang 2.6 implemented the 32- and 64-bit but waited until 3.2 to implement the 16-bit one #if (defined(Q_CC_GNU) && Q_CC_GNU >= 403) || QT_HAS_BUILTIN(__builtin_bswap32) @@ -154,8 +148,6 @@ template <> inline quint16 qbswap<quint16>(quint16 source) } #endif // GCC & Clang intrinsics -#undef QT_HAS_BUILTIN - // signed specializations template <> inline qint64 qbswap<qint64>(qint64 source) { diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 81925642f8..c1ab2d69fa 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1183,30 +1183,35 @@ bool qSharedBuild() Q_DECL_NOTHROW \macro Q_OS_DARWIN \relates <QtGlobal> - Defined on Darwin-based operating systems such as OS X and iOS, - including any open source version(s) of Darwin. + Defined on Darwin-based operating systems such as OS X, iOS, watchOS, and tvOS. */ /*! - \macro Q_OS_MAC + \macro Q_OS_OSX \relates <QtGlobal> - Defined on Darwin-based operating systems distributed by Apple, which - currently includes OS X and iOS, but not the open source versions of Darwin. + Defined on OS X. */ /*! - \macro Q_OS_OSX + \macro Q_OS_IOS \relates <QtGlobal> - Defined on OS X. + Defined on iOS. */ /*! - \macro Q_OS_IOS + \macro Q_OS_WATCHOS \relates <QtGlobal> - Defined on iOS. + Defined on watchOS. + */ + +/*! + \macro Q_OS_TVOS + \relates <QtGlobal> + + Defined on tvOS. */ /*! diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index db8c60831f..64d9f79faf 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -915,8 +915,6 @@ QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantic # endif #endif -#if defined(Q_COMPILER_DECLTYPE) || defined(Q_CC_GNU) -/* make use of decltype or GCC's __typeof__ extension */ template <typename T> class QForeachContainer { QForeachContainer &operator=(const QForeachContainer &) Q_DECL_EQ_DELETE; @@ -927,17 +925,6 @@ public: int control; }; -// We need to use __typeof__ if we don't have decltype or if the compiler -// hasn't been updated to the fix of Core Language Defect Report 382 -// (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#382). -// GCC 4.3 and 4.4 have support for decltype, but are affected by DR 382. -# if defined(Q_COMPILER_DECLTYPE) && \ - (defined(Q_CC_CLANG) || defined(Q_CC_INTEL) || !defined(Q_CC_GNU) || Q_CC_GNU >= 405) -# define QT_FOREACH_DECLTYPE(x) typename QtPrivate::remove_reference<decltype(x)>::type -# else -# define QT_FOREACH_DECLTYPE(x) __typeof__((x)) -# endif - // Explanation of the control word: // - it's initialized to 1 // - that means both the inner and outer loops start @@ -947,61 +934,12 @@ public: // the outer loop to continue executing // - if there was a break inside the inner loop, it will exit with control still // set to 1; in that case, the outer loop will invert it to 0 and will exit too -# define Q_FOREACH(variable, container) \ -for (QForeachContainer<QT_FOREACH_DECLTYPE(container)> _container_((container)); \ +#define Q_FOREACH(variable, container) \ +for (QForeachContainer<typename QtPrivate::remove_reference<decltype(container)>::type> _container_((container)); \ _container_.control && _container_.i != _container_.e; \ ++_container_.i, _container_.control ^= 1) \ for (variable = *_container_.i; _container_.control; _container_.control = 0) -#else - -struct QForeachContainerBase {}; - -template <typename T> -class QForeachContainer : public QForeachContainerBase { - QForeachContainer &operator=(const QForeachContainer &) Q_DECL_EQ_DELETE; -public: - inline QForeachContainer(const T& t): c(t), brk(0), i(c.begin()), e(c.end()){} - QForeachContainer(const QForeachContainer &other) - : c(other.c), brk(other.brk), i(other.i), e(other.e) {} - const T c; - mutable int brk; - mutable typename T::const_iterator i, e; - inline bool condition() const { return (!brk++ && i != e); } -}; - -template <typename T> inline T *qForeachPointer(const T &) { return 0; } - -template <typename T> inline QForeachContainer<T> qForeachContainerNew(const T& t) -{ return QForeachContainer<T>(t); } - -template <typename T> -inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase *base, const T *) -{ return static_cast<const QForeachContainer<T> *>(base); } - -#if defined(Q_CC_DIAB) -// VxWorks DIAB generates unresolvable symbols, if container is a function call -# define Q_FOREACH(variable,container) \ - if(0){}else \ - for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \ - qForeachContainer(&_container_, (__typeof__(container) *) 0)->condition(); \ - ++qForeachContainer(&_container_, (__typeof__(container) *) 0)->i) \ - for (variable = *qForeachContainer(&_container_, (__typeof__(container) *) 0)->i; \ - qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk; \ - --qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk) - -#else -# define Q_FOREACH(variable, container) \ - for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \ - qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \ - ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \ - for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \ - qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \ - --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk) -#endif // MSVC6 || MIPSpro - -#endif - #define Q_FOREVER for(;;) #ifndef QT_NO_KEYWORDS # ifndef foreach diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp index 382f45f592..40a7c88f13 100644 --- a/src/corelib/global/qhooks.cpp +++ b/src/corelib/global/qhooks.cpp @@ -37,7 +37,7 @@ QT_BEGIN_NAMESPACE // Only add to the end, and bump version if you do. quintptr Q_CORE_EXPORT qtHookData[] = { - 2, // hook data version + 3, // hook data version QHooks::LastHookIndex, // size of qtHookData QT_VERSION, @@ -52,6 +52,15 @@ quintptr Q_CORE_EXPORT qtHookData[] = { 0, // Startup, void(*)(), called once QCoreApplication is operational + 0, + + // TypeInformationVersion, an integral value, bumped whenever private + // object sizes or member offsets that are used in Qt Creator's + // data structure "pretty printing" change. + // + // The required sizes and offsets are tested in tests/auto/other/toolsupport. + // When this fails and the change was intentional, adjust the test and + // adjust this value here. 0 }; diff --git a/src/corelib/global/qhooks_p.h b/src/corelib/global/qhooks_p.h index 3ff4980abe..2beb58f8a7 100644 --- a/src/corelib/global/qhooks_p.h +++ b/src/corelib/global/qhooks_p.h @@ -61,6 +61,7 @@ enum HookIndex { AddQObject = 3, RemoveQObject = 4, Startup = 5, + TypeInformationVersion = 6, LastHookIndex }; diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 20c31f7ef8..47591a3fa8 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -75,17 +75,13 @@ # include "private/qcore_unix_p.h" #endif -#ifndef __has_include -# define __has_include(x) 0 -#endif - #ifndef QT_BOOTSTRAPPED #if !defined QT_NO_REGULAREXPRESSION # ifdef __UCLIBC__ # if __UCLIBC_HAS_BACKTRACE__ # define QLOGGING_HAVE_BACKTRACE # endif -# elif (defined(__GLIBC__) && defined(__GLIBCXX__)) || (__has_include(<cxxabi.h>) && __has_include(<execinfo.h>)) +# elif (defined(__GLIBC__) && defined(__GLIBCXX__)) || (QT_HAS_INCLUDE(<cxxabi.h>) && QT_HAS_INCLUDE(<execinfo.h>)) # define QLOGGING_HAVE_BACKTRACE # endif #endif @@ -94,7 +90,7 @@ extern char *__progname; #endif -#if defined(Q_OS_LINUX) && (defined(__GLIBC__) || __has_include(<sys/syscall.h>)) +#if defined(Q_OS_LINUX) && (defined(__GLIBC__) || QT_HAS_INCLUDE(<sys/syscall.h>)) # include <sys/syscall.h> static long qt_gettid() { diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index c4f5415a01..45594d1914 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -482,7 +482,8 @@ public: AA_DontShowIconsInMenus = 2, AA_NativeWindows = 3, AA_DontCreateNativeWidgetSiblings = 4, - AA_MacPluginApplication = 5, + AA_PluginApplication = 5, + AA_MacPluginApplication = AA_PluginApplication, // ### Qt 6: remove me AA_DontUseNativeMenuBar = 6, AA_MacDontSwapCtrlAndMeta = 7, AA_Use96Dpi = 8, @@ -498,6 +499,7 @@ public: AA_SetPalette = 19, AA_EnableHighDpiScaling = 20, AA_DisableHighDpiScaling = 21, + AA_UseStyleSheetPropagationInWidgetStyles = 22, // ### Qt 6: remove me // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index e789daafbd..df376405e0 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -120,13 +120,21 @@ widgets stay non-native unless specifically set by the Qt::WA_NativeWindow attribute. - \value AA_MacPluginApplication Stops the Qt mac application from doing - specific initializations that do not necessarily make sense when using Qt - to author a plugin. This includes avoiding loading our nib for the main - menu and not taking possession of the native menu bar. When setting this + \value AA_PluginApplication Indicates that Qt is used to author a plugin. Depending + on the operating system, it suppresses specific initializations that do not + necessarily make sense in the plugin case. + + For example on OS X, this includes avoiding loading our nib for the main + menu and not taking possession of the native menu bar. Setting this attribute to true will also set the AA_DontUseNativeMenuBar attribute to true. It also disables native event filters. + This attribute has been added in Qt 5.7. It must be set before + \l {QGuiApplication}{Q(Gui)Application} is constructed. + + \value AA_MacPluginApplication This attribute has been deprecated. + Use AA_PluginApplication instead. + \value AA_DontUseNativeMenuBar All menubars created while this attribute is set to true won't be used as a native menubar (e.g, the menubar at the top of the main screen on OS X or at the bottom in Windows CE). @@ -217,6 +225,13 @@ environment variable to 0. This value has been added in Qt 5.6. This attribute must be set before Q(Gui)Application is constructed. + \value AA_UseStyleSheetPropagationInWidgetStyles By default, Qt Style Sheets + disable regular QWidget palette and font propagation. When this flag + is enabled, font and palette changes propagate as though the user had + manually called the corresponding QWidget methods. See + \l{The Style Sheet Syntax#Inheritance}{The Style Sheet Syntax - Inheritance} + for more details. This value has been added in Qt 5.7. + The following values are obsolete: \value AA_ImmediateWidgetCreation This attribute is no longer fully diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index e5f9d8e13e..b56cdef939 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -47,7 +47,7 @@ // #include "QtCore/qglobal.h" - +#include <cmath> #include <limits> #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) @@ -56,12 +56,57 @@ # include <immintrin.h> // for _addcarry_u<nn> #endif -#ifndef __has_builtin -# define __has_builtin(x) 0 +#if defined(Q_CC_MSVC) +#include <float.h> +#endif + +#if !defined(Q_CC_MSVC) && (defined(Q_OS_QNX) || !defined(__cplusplus) || __cplusplus < 201103L) +#include <math.h> +QT_BEGIN_NAMESPACE +namespace qnumeric_std_wrapper { +// the 'using namespace std' below is cases where the stdlib already put the math.h functions in the std namespace and undefined the macros. +static inline bool math_h_isnan(double d) { using namespace std; return isnan(d); } +static inline bool math_h_isinf(double d) { using namespace std; return isinf(d); } +static inline bool math_h_isfinite(double d) { using namespace std; return isfinite(d); } +static inline bool math_h_isnan(float f) { using namespace std; return isnan(f); } +static inline bool math_h_isinf(float f) { using namespace std; return isinf(f); } +static inline bool math_h_isfinite(float f) { using namespace std; return isfinite(f); } +} +QT_END_NAMESPACE +// These macros from math.h conflict with the real functions in the std namespace. +#undef signbit +#undef isnan +#undef isinf +#undef isfinite #endif QT_BEGIN_NAMESPACE +namespace qnumeric_std_wrapper { +#if defined(Q_CC_MSVC) && _MSC_VER < 1800 +static inline bool isnan(double d) { return !!_isnan(d); } +static inline bool isinf(double d) { return !_finite(d) && !_isnan(d); } +static inline bool isfinite(double d) { return !!_finite(d); } +static inline bool isnan(float f) { return !!_isnanf(f); } +static inline bool isinf(float f) { return !_finitef(f) && !_isnan(f); } +static inline bool isfinite(float f) { return !!_finite(f); } +#elif !defined(Q_CC_MSVC) && (defined(Q_OS_QNX) || !defined(__cplusplus) || __cplusplus < 201103L) +static inline bool isnan(double d) { return math_h_isnan(d); } +static inline bool isinf(double d) { return math_h_isinf(d); } +static inline bool isfinite(double d) { return math_h_isfinite(d); } +static inline bool isnan(float f) { return math_h_isnan(f); } +static inline bool isinf(float f) { return math_h_isinf(f); } +static inline bool isfinite(float f) { return math_h_isfinite(f); } +#else +static inline bool isnan(double d) { return std::isnan(d); } +static inline bool isinf(double d) { return std::isinf(d); } +static inline bool isfinite(double d) { return std::isfinite(d); } +static inline bool isnan(float f) { return std::isnan(f); } +static inline bool isinf(float f) { return std::isinf(f); } +static inline bool isfinite(float f) { return std::isfinite(f); } +#endif +} + #if !defined(Q_CC_MIPS) static const union { unsigned char c[8]; double d; } qt_be_inf_bytes = { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } }; @@ -143,62 +188,32 @@ static inline double qt_qnan() static inline bool qt_is_inf(double d) { - uchar *ch = (uchar *)&d; - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - return (ch[0] & 0x7f) == 0x7f && ch[1] == 0xf0; - } else { - return (ch[7] & 0x7f) == 0x7f && ch[6] == 0xf0; - } + return qnumeric_std_wrapper::isinf(d); } static inline bool qt_is_nan(double d) { - uchar *ch = (uchar *)&d; - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - return (ch[0] & 0x7f) == 0x7f && ch[1] > 0xf0; - } else { - return (ch[7] & 0x7f) == 0x7f && ch[6] > 0xf0; - } + return qnumeric_std_wrapper::isnan(d); } static inline bool qt_is_finite(double d) { - uchar *ch = (uchar *)&d; - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - return (ch[0] & 0x7f) != 0x7f || (ch[1] & 0xf0) != 0xf0; - } else { - return (ch[7] & 0x7f) != 0x7f || (ch[6] & 0xf0) != 0xf0; - } + return qnumeric_std_wrapper::isfinite(d); } -static inline bool qt_is_inf(float d) +static inline bool qt_is_inf(float f) { - uchar *ch = (uchar *)&d; - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - return (ch[0] & 0x7f) == 0x7f && ch[1] == 0x80; - } else { - return (ch[3] & 0x7f) == 0x7f && ch[2] == 0x80; - } + return qnumeric_std_wrapper::isinf(f); } -static inline bool qt_is_nan(float d) +static inline bool qt_is_nan(float f) { - uchar *ch = (uchar *)&d; - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - return (ch[0] & 0x7f) == 0x7f && ch[1] > 0x80; - } else { - return (ch[3] & 0x7f) == 0x7f && ch[2] > 0x80; - } + return qnumeric_std_wrapper::isnan(f); } -static inline bool qt_is_finite(float d) +static inline bool qt_is_finite(float f) { - uchar *ch = (uchar *)&d; - if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { - return (ch[0] & 0x7f) != 0x7f || (ch[1] & 0x80) != 0x80; - } else { - return (ch[3] & 0x7f) != 0x7f || (ch[2] & 0x80) != 0x80; - } + return qnumeric_std_wrapper::isfinite(f); } // @@ -230,28 +245,28 @@ mul_overflow(T v1, T v2, T *r) #endif // GCC 5 and Clang have builtins to detect overflows -#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || __has_builtin(__builtin_uadd_overflow) +#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || QT_HAS_BUILTIN(__builtin_uadd_overflow) template <> inline bool add_overflow(unsigned v1, unsigned v2, unsigned *r) { return __builtin_uadd_overflow(v1, v2, r); } #endif -#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || __has_builtin(__builtin_uaddl_overflow) +#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || QT_HAS_BUILTIN(__builtin_uaddl_overflow) template <> inline bool add_overflow(unsigned long v1, unsigned long v2, unsigned long *r) { return __builtin_uaddl_overflow(v1, v2, r); } #endif -#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || __has_builtin(__builtin_uaddll_overflow) +#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || QT_HAS_BUILTIN(__builtin_uaddll_overflow) template <> inline bool add_overflow(unsigned long long v1, unsigned long long v2, unsigned long long *r) { return __builtin_uaddll_overflow(v1, v2, r); } #endif -#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || __has_builtin(__builtin_umul_overflow) +#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || QT_HAS_BUILTIN(__builtin_umul_overflow) template <> inline bool mul_overflow(unsigned v1, unsigned v2, unsigned *r) { return __builtin_umul_overflow(v1, v2, r); } #endif -#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || __has_builtin(__builtin_umull_overflow) +#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || QT_HAS_BUILTIN(__builtin_umull_overflow) template <> inline bool mul_overflow(unsigned long v1, unsigned long v2, unsigned long *r) { return __builtin_umull_overflow(v1, v2, r); } #endif -#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || __has_builtin(__builtin_umulll_overflow) +#if (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && Q_CC_GNU >= 500) || QT_HAS_BUILTIN(__builtin_umulll_overflow) template <> inline bool mul_overflow(unsigned long long v1, unsigned long long v2, unsigned long long *r) { return __builtin_umulll_overflow(v1, v2, r); } # define HAVE_MUL64_OVERFLOW diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index 751c6a9a0e..9ca376b84a 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -41,10 +41,11 @@ /* The operating system, must be one of: (Q_OS_x) - DARWIN - Any Darwin system - MAC - OS X and iOS + DARWIN - Any Darwin system (OS X, iOS, watchOS, tvOS) OSX - OS X IOS - iOS + WATCHOS - watchOS + TVOS - tvOS MSDOS - MS-DOS and Windows OS2 - OS/2 OS2EMX - XFree86 on OS/2 (not PM) @@ -87,12 +88,32 @@ */ #if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__)) -# define Q_OS_DARWIN -# define Q_OS_BSD4 -# ifdef __LP64__ -# define Q_OS_DARWIN64 +# include <TargetConditionals.h> +# if defined(TARGET_OS_MAC) && TARGET_OS_MAC +# define Q_OS_DARWIN +# define Q_OS_BSD4 +# ifdef __LP64__ +# define Q_OS_DARWIN64 +# else +# define Q_OS_DARWIN32 +# endif +# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +# if defined(TARGET_OS_TV) && TARGET_OS_TV +# define Q_OS_TVOS +# elif defined(TARGET_OS_WATCH) && TARGET_OS_WATCH +# define Q_OS_WATCHOS +# else +# // TARGET_OS_IOS is only available in newer SDKs, +# // so assume any other iOS-based platform is iOS for now +# define Q_OS_IOS +# endif +# else +# // there is no "real" OS X define (rdar://22640089), +# // assume any non iOS-based platform is OS X for now +# define Q_OS_OSX +# endif # else -# define Q_OS_DARWIN32 +# error "Qt has not been ported to this Apple platform - see http://www.qt.io/developers" # endif #elif defined(__ANDROID__) || defined(ANDROID) # define Q_OS_ANDROID @@ -181,28 +202,26 @@ # define Q_OS_WIN #endif -#if defined(Q_OS_DARWIN) -# define Q_OS_MAC -# if defined(Q_OS_DARWIN64) -# define Q_OS_MAC64 -# elif defined(Q_OS_DARWIN32) -# define Q_OS_MAC32 -# endif -# include <TargetConditionals.h> -# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE -# define Q_OS_IOS -# elif defined(TARGET_OS_MAC) && TARGET_OS_MAC -# define Q_OS_OSX -# define Q_OS_MACX // compatibility synonym -# endif -#endif - #if defined(Q_OS_WIN) # undef Q_OS_UNIX #elif !defined(Q_OS_UNIX) # define Q_OS_UNIX #endif +// Compatibility synonyms +#ifdef Q_OS_DARWIN +#define Q_OS_MAC +#endif +#ifdef Q_OS_DARWIN32 +#define Q_OS_MAC32 +#endif +#ifdef Q_OS_DARWIN64 +#define Q_OS_MAC64 +#endif +#ifdef Q_OS_OSX +#define Q_OS_MACX +#endif + #ifdef Q_OS_DARWIN # include <Availability.h> # include <AvailabilityMacros.h> diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index b42e5998fc..cd0a83ae80 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -276,13 +276,25 @@ Q_DECLARE_TYPEINFO(double, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE); #endif + #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) -// We can't do it now because it would break BC on QList<char32_t> +// ### Qt 6: remove the other branch +// This was required so that QList<T> for these types allocates out of the array storage +# ifdef Q_COMPILER_UNICODE_STRINGS Q_DECLARE_TYPEINFO(char16_t, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(char32_t, Q_PRIMITIVE_TYPE); +# endif # if !defined(Q_CC_MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) Q_DECLARE_TYPEINFO(wchar_t, Q_PRIMITIVE_TYPE); # endif +#else +# ifdef Q_COMPILER_UNICODE_STRINGS +Q_DECLARE_TYPEINFO(char16_t, Q_RELOCATABLE_TYPE); +Q_DECLARE_TYPEINFO(char32_t, Q_RELOCATABLE_TYPE); +# endif +# if !defined(Q_CC_MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) +Q_DECLARE_TYPEINFO(wchar_t, Q_RELOCATABLE_TYPE); +# endif #endif // Qt 6 QT_END_NAMESPACE |