diff options
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/archdetect.cpp | 131 | ||||
-rw-r--r-- | src/corelib/global/global.pri | 7 | ||||
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 94 | ||||
-rw-r--r-- | src/corelib/global/qflags.h | 17 | ||||
-rw-r--r-- | src/corelib/global/qglobal.cpp | 585 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 41 | ||||
-rw-r--r-- | src/corelib/global/qglobalstatic.h | 2 | ||||
-rw-r--r-- | src/corelib/global/qhooks.cpp | 69 | ||||
-rw-r--r-- | src/corelib/global/qhooks_p.h | 74 | ||||
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 65 | ||||
-rw-r--r-- | src/corelib/global/qlogging.cpp | 111 | ||||
-rw-r--r-- | src/corelib/global/qlogging.h | 4 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.h | 1 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 20 | ||||
-rw-r--r-- | src/corelib/global/qnumeric.cpp | 2 | ||||
-rw-r--r-- | src/corelib/global/qsysinfo.h | 12 | ||||
-rw-r--r-- | src/corelib/global/qsystemdetection.h | 12 | ||||
-rw-r--r-- | src/corelib/global/qtypeinfo.h | 2 |
18 files changed, 1081 insertions, 168 deletions
diff --git a/src/corelib/global/archdetect.cpp b/src/corelib/global/archdetect.cpp new file mode 100644 index 0000000000..9540e391ba --- /dev/null +++ b/src/corelib/global/archdetect.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Intel Corporation +** Contact: http://www.qt-project.org/legal +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qprocessordetection.h" + +// main part: processor type +#if defined(Q_PROCESSOR_ALPHA) +# define ARCH_PROCESSOR "alpha" +#elif defined(Q_PROCESSOR_ARM_32) +# define ARCH_PROCESSOR "arm" +#elif defined(Q_PROCESSOR_ARM_64) +# define ARCH_PROCESSOR "arm64" +#elif defined(Q_PROCESSOR_AVR32) +# define ARCH_PROCESSOR "avr32" +#elif defined(Q_PROCESSOR_BLACKFIN) +# define ARCH_PROCESSOR "bfin" +#elif defined(Q_PROCESSOR_X86_32) +# define ARCH_PROCESSOR "i386" +#elif defined(Q_PROCESSOR_X86_64) +# define ARCH_PROCESSOR "x86_64" +#elif defined(Q_PROCESSOR_IA64) +# define ARCH_PROCESSOR "ia64" +#elif defined(Q_PROCESSOR_MIPS_64) +# define ARCH_PROCESSOR "mips64" +#elif defined(Q_PROCESSOR_MIPS) +# define ARCH_PROCESSOR "mips" +#elif defined(Q_PROCESSOR_POWER_32) +# define ARCH_PROCESSOR "power" +#elif defined(Q_PROCESSOR_POWER_64) +# define ARCH_PROCESSOR "power64" +#elif defined(Q_PROCESSOR_S390_X) +# define ARCH_PROCESSOR "s390x" +#elif defined(Q_PROCESSOR_S390) +# define ARCH_PROCESSOR "s390" +#elif defined(Q_PROCESSOR_SH) +# define ARCH_PROCESSOR "sh" +#elif defined(Q_PROCESSOR_SPARC_V9) +# define ARCH_PROCESSOR "sparcv9" +#elif defined(Q_PROCESSOR_SPARC) +# define ARCH_PROCESSOR "sparc" +#else +# define ARCH_PROCESSOR "unknown" +#endif + +// endinanness +#if defined(Q_LITTLE_ENDIAN) +# define ARCH_ENDIANNESS "little_endian" +#elif defined(Q_BIG_ENDIAN) +# define ARCH_ENDIANNESS "big_endian" +#endif + +// pointer type +#if defined(Q_OS_WIN64) || (defined(Q_OS_WINRT) && defined(_M_X64)) +# define ARCH_POINTER "llp64" +#elif defined(__LP64__) || QT_POINTER_SIZE - 0 == 8 +# define ARCH_POINTER "lp64" +#else +# define ARCH_POINTER "ilp32" +#endif + +// qreal type, if not double (includes the dash) +#ifdef QT_COORD_TYPE_STRING +# define ARCH_COORD_TYPE "-qreal_" QT_COORD_TYPE_STRING +#else +# define ARCH_COORD_TYPE "" +#endif + +// secondary: ABI string (includes the dash) +#if defined(__ARM_EABI__) || defined(__mips_eabi) +# define ARCH_ABI1 "-eabi" +#elif defined(_MIPS_SIM) +# if _MIPS_SIM == _ABIO32 +# define ARCH_ABI1 "-o32" +# elif _MIPS_SIM == _ABIN32 +# define ARCH_ABI1 "-n32" +# elif _MIPS_SIM == _ABI64 +# define ARCH_ABI1 "-n64" +# elif _MIPS_SIM == _ABIO64 +# define ARCH_ABI1 "-o64" +# endif +#else +# define ARCH_ABI1 "" +#endif +#if defined(__ARM_PCS_VFP) || defined(__mips_hard_float) +# define ARCH_ABI2 "-hardfloat" +#else +# define ARCH_ABI2 "" +#endif + +#define ARCH_ABI ARCH_ABI1 ARCH_ABI2 + +#define ARCH_FULL ARCH_PROCESSOR "-" ARCH_ENDIANNESS "-" ARCH_POINTER ARCH_COORD_TYPE ARCH_ABI diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index efa585ff3e..fb0e7fd708 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -16,15 +16,18 @@ HEADERS += \ global/qsysinfo.h \ global/qisenum.h \ global/qtypetraits.h \ - global/qflags.h + global/qflags.h \ + global/qhooks_p.h SOURCES += \ + global/archdetect.cpp \ global/qglobal.cpp \ global/qglobalstatic.cpp \ global/qlibraryinfo.cpp \ global/qmalloc.cpp \ global/qnumeric.cpp \ - global/qlogging.cpp + global/qlogging.cpp \ + global/qhooks.cpp # qlibraryinfo.cpp includes qconfig.cpp INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index b12f944357..24c5bfa741 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -89,7 +89,9 @@ # define Q_CC_MSVC # define Q_CC_MSVC_NET # define Q_OUTOFLINE_TEMPLATE inline -# define Q_NO_TEMPLATE_FRIENDS +# if _MSC_VER < 1600 +# define Q_NO_TEMPLATE_FRIENDS +# endif # define Q_COMPILER_MANGLES_RETURN_TYPE # define Q_FUNC_INFO __FUNCSIG__ # define Q_ALIGNOF(type) __alignof(type) @@ -200,6 +202,8 @@ # define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false) # define Q_NORETURN __attribute__((__noreturn__)) # define Q_REQUIRED_RESULT __attribute__ ((__warn_unused_result__)) +# define Q_DECL_PURE_FUNCTION __attribute__((pure)) +# define Q_DECL_CONST_FUNCTION __attribute__((const)) # if !defined(QT_MOC_CPP) # define Q_PACKED __attribute__ ((__packed__)) # ifndef __ARM_EABI__ @@ -439,59 +443,55 @@ /* * C++11 support * - * Paper Macro + * Paper Macro SD-6 macro * N2341 Q_COMPILER_ALIGNAS * N2341 Q_COMPILER_ALIGNOF * N2427 Q_COMPILER_ATOMICS - * N2761 Q_COMPILER_ATTRIBUTES + * N2761 Q_COMPILER_ATTRIBUTES __cpp_attributes = 200809 * N2541 Q_COMPILER_AUTO_FUNCTION * N1984 N2546 Q_COMPILER_AUTO_TYPE * N2437 Q_COMPILER_CLASS_ENUM - * N2235 Q_COMPILER_CONSTEXPR - * N2343 N3276 Q_COMPILER_DECLTYPE + * N2235 Q_COMPILER_CONSTEXPR __cpp_constexpr = 200704 + * N2343 N3276 Q_COMPILER_DECLTYPE __cpp_decltype = 200707 * N2346 Q_COMPILER_DEFAULT_MEMBERS * N2346 Q_COMPILER_DELETE_MEMBERS * N1986 Q_COMPILER_DELEGATING_CONSTRUCTORS * N2437 Q_COMPILER_EXPLICIT_CONVERSIONS - * N3206 N3272 Q_COMPILER_EXPLICIT_OVERRIDES (v0.9 and above only) + * N3206 N3272 Q_COMPILER_EXPLICIT_OVERRIDES * N1987 Q_COMPILER_EXTERN_TEMPLATES * N2540 Q_COMPILER_INHERITING_CONSTRUCTORS * N2672 Q_COMPILER_INITIALIZER_LISTS - * N2658 N2927 Q_COMPILER_LAMBDA (v1.0 and above only) + * N2658 N2927 Q_COMPILER_LAMBDA __cpp_lambdas = 200907 * N2756 Q_COMPILER_NONSTATIC_MEMBER_INIT * N2855 N3050 Q_COMPILER_NOEXCEPT * N2431 Q_COMPILER_NULLPTR * N2930 Q_COMPILER_RANGE_FOR - * N2442 Q_COMPILER_RAW_STRINGS + * N2442 Q_COMPILER_RAW_STRINGS __cpp_raw_strings = 200710 * N2439 Q_COMPILER_REF_QUALIFIERS - * N2118 N2844 N3053 Q_COMPILER_RVALUE_REFS (Note: GCC 4.3 implements only the oldest) - * N1720 Q_COMPILER_STATIC_ASSERT + * N2118 N2844 N3053 Q_COMPILER_RVALUE_REFS __cpp_rvalue_references = 200610 + * N1720 Q_COMPILER_STATIC_ASSERT __cpp_static_assert = 200410 * N2258 Q_COMPILER_TEMPLATE_ALIAS * N2659 Q_COMPILER_THREAD_LOCAL - * N2765 Q_COMPILER_UDL - * N2442 Q_COMPILER_UNICODE_STRINGS + * N2660 Q_COMPILER_THREADSAFE_STATICS + * N2765 Q_COMPILER_UDL __cpp_user_defined_literals = 200809 + * N2442 Q_COMPILER_UNICODE_STRINGS __cpp_unicode_literals = 200710 * N2640 Q_COMPILER_UNIFORM_INIT * N2544 Q_COMPILER_UNRESTRICTED_UNIONS * N1653 Q_COMPILER_VARIADIC_MACROS - * N2242 N2555 Q_COMPILER_VARIADIC_TEMPLATES - * - * C++1y proposed features + * N2242 N2555 Q_COMPILER_VARIADIC_TEMPLATES __cpp_variadic_templates = 200704 * - * N3472 Q_COMPILER_BINARY_LITERALS - * N3649 Q_COMPILER_GENERIC_LAMBDA - * N3638 Q_COMPILER_LAMBDA_CAPTURES - * N3652 Q_COMPILER_RELAXED_CONSTEXPR_FUNCTIONS - * N3386 N3638 Q_COMPILER_RETURN_TYPE_DEDUCTION - * N3651 Q_COMPILER_VARIABLE_TEMPLATES - * - * C++14 Technical Specifications / C++17: - * N3639 Q_COMPILER_VLA (see also Q_COMPILER_RESTRICTED_VLA) + * For any future version of the C++ standard, we use only the SD-6 macro. + * For full listing, see + * http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations * + * C++ extensions: + * Q_COMPILER_RESTRICTED_VLA variable-length arrays, prior to __cpp_runtime_arrays */ #ifdef Q_CC_INTEL # define Q_COMPILER_RESTRICTED_VLA # define Q_COMPILER_VARIADIC_MACROS // C++11 feature supported as an extension in other modes, too +# define Q_COMPILER_THREADSAFE_STATICS # if __INTEL_COMPILER < 1200 # define Q_NO_TEMPLATE_FRIENDS # endif @@ -533,18 +533,28 @@ // causes issues with QArrayData and QtPrivate::RefCount - Intel issue ID 6000056211, bug DPD200534796 //# define Q_COMPILER_CONSTEXPR # define Q_COMPILER_DELEGATING_CONSTRUCTORS +# define Q_COMPILER_EXPLICIT_CONVERSIONS # define Q_COMPILER_EXPLICIT_OVERRIDES # define Q_COMPILER_NONSTATIC_MEMBER_INIT +# define Q_COMPILER_RANGE_FOR # define Q_COMPILER_RAW_STRINGS # define Q_COMPILER_REF_QUALIFIERS # define Q_COMPILER_UNRESTRICTED_UNIONS # endif +# if __INTEL_COMPILER >= 1500 +# define Q_COMPILER_ALIGNAS +# define Q_COMPILER_ALIGNOF +# define Q_COMPILER_INHERITING_CONSTRUCTORS +# define Q_COMPILER_THREAD_LOCAL +# define Q_COMPILER_UDL +# endif # endif #endif #if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) /* General C++ features */ # define Q_COMPILER_RESTRICTED_VLA +# define Q_COMPILER_THREADSAFE_STATICS # if !__has_feature(cxx_exceptions) # ifndef QT_NO_EXCEPTIONS # define QT_NO_EXCEPTIONS @@ -671,8 +681,7 @@ # endif # endif -/* C++1y features, see http://clang.llvm.org/cxx_status.html and - * http://clang.llvm.org/docs/LanguageExtensions.html#checks-for-standard-language-features */ +/* C++1y features, deprecated macros. Do not update this list. */ # if __cplusplus > 201103L //# if __has_feature(cxx_binary_literals) //# define Q_COMPILER_BINARY_LITERALS // see above @@ -700,6 +709,7 @@ #if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG) # define Q_COMPILER_RESTRICTED_VLA +# define Q_COMPILER_THREADSAFE_STATICS # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 // GCC supports binary literals in C, C++98 and C++11 modes # define Q_COMPILER_BINARY_LITERALS @@ -773,7 +783,7 @@ # endif # if __cplusplus > 201103L # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 - /* C++1y features in GCC 4.9 */ + /* C++1y features in GCC 4.9 - deprecated, do not update this list */ //# define Q_COMPILER_BINARY_LITERALS // already supported since GCC 4.3 as an extension # define Q_COMPILER_LAMBDA_CAPTURES # define Q_COMPILER_RETURN_TYPE_DEDUCTION @@ -782,6 +792,7 @@ #endif #if defined(Q_CC_MSVC) && !defined(Q_CC_INTEL) +# if defined(__cplusplus) # if _MSC_VER >= 1400 /* C++11 features supported in VC8 = VC2005: */ # define Q_COMPILER_VARIADIC_MACROS @@ -804,8 +815,10 @@ /* C++11 features supported in VC10 = VC2010: */ # define Q_COMPILER_AUTO_FUNCTION # define Q_COMPILER_AUTO_TYPE -# define Q_COMPILER_LAMBDA # define Q_COMPILER_DECLTYPE +# define Q_COMPILER_EXTERN_TEMPLATES +# define Q_COMPILER_LAMBDA +# define Q_COMPILER_NULLPTR # define Q_COMPILER_RVALUE_REFS # define Q_COMPILER_STATIC_ASSERT // MSVC's library has std::initializer_list, but the compiler does not support the braces initialization @@ -817,7 +830,6 @@ # undef Q_DECL_OVERRIDE /* undo 2005/2008 settings... */ # undef Q_DECL_FINAL /* undo 2005/2008 settings... */ # define Q_COMPILER_EXPLICIT_OVERRIDES /* ...and use std C++11 now */ -# define Q_COMPILER_RANGE_FOR # define Q_COMPILER_CLASS_ENUM # define Q_COMPILER_ATOMICS # endif /* VC 11 */ @@ -840,6 +852,7 @@ # define Q_COMPILER_INITIALIZER_LISTS # endif /* VC 12 SP 2 RC */ +# endif /* __cplusplus */ #endif /* Q_CC_MSVC */ #ifdef __cplusplus @@ -864,6 +877,13 @@ # undef Q_COMPILER_RVALUE_REFS # undef Q_COMPILER_REF_QUALIFIERS # endif +# if defined(Q_COMPILER_THREADSAFE_STATICS) && defined(Q_OS_MAC) +// Mac OS X: Apple's low-level implementation of the C++ support library +// (libc++abi.dylib, shared between libstdc++ and libc++) has deadlocks. The +// C++11 standard requires the deadlocks to be removed, so this will eventually +// be fixed; for now, let's disable this. +# undef Q_COMPILER_THREADSAFE_STATICS +# endif #endif /* @@ -989,17 +1009,11 @@ #ifndef Q_DECL_NS_RETURNS_AUTORELEASED # define Q_DECL_NS_RETURNS_AUTORELEASED #endif - -/* - Workaround for static const members on MSVC++. -*/ - -#if defined(Q_CC_MSVC) -# define QT_STATIC_CONST static -# define QT_STATIC_CONST_IMPL -#else -# define QT_STATIC_CONST static const -# define QT_STATIC_CONST_IMPL const +#ifndef Q_DECL_PURE_FUNCTION +# define Q_DECL_PURE_FUNCTION +#endif +#ifndef Q_DECL_CONST_FUNCTION +# define Q_DECL_CONST_FUNCTION Q_DECL_PURE_FUNCTION #endif /* diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index bdfc453e08..097f2760b4 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -47,6 +47,10 @@ #include <QtCore/qtypeinfo.h> #include <QtCore/qtypetraits.h> +#ifdef Q_COMPILER_INITIALIZER_LISTS +#include <initializer_list> +#endif + QT_BEGIN_NAMESPACE class QFlag @@ -116,6 +120,11 @@ public: Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {} Q_DECL_CONSTEXPR inline QFlags(QFlag f) : i(f) {} +#ifdef Q_COMPILER_INITIALIZER_LISTS + Q_DECL_CONSTEXPR inline QFlags(std::initializer_list<Enum> flags) + : i(initializer_list_helper(flags.begin(), flags.end())) {} +#endif + inline QFlags &operator&=(int mask) { i &= mask; return *this; } inline QFlags &operator&=(uint mask) { i &= mask; return *this; } inline QFlags &operator&=(Enum mask) { i &= Int(mask); return *this; } @@ -139,6 +148,14 @@ public: Q_DECL_CONSTEXPR inline bool testFlag(Enum f) const { return (i & Int(f)) == Int(f) && (Int(f) != 0 || i == Int(f) ); } private: +#ifdef Q_COMPILER_INITIALIZER_LISTS + Q_DECL_CONSTEXPR static inline Int initializer_list_helper(typename std::initializer_list<Enum>::const_iterator it, + typename std::initializer_list<Enum>::const_iterator end) + { + return (it == end ? Int(0) : (Int(*it) | initializer_list_helper(it + 1, end))); + } +#endif + Int i; }; diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 6b5638d336..66f2923370 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Intel Corporation ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -80,6 +81,17 @@ #include <private/qjni_p.h> #endif +#if defined(Q_OS_BLACKBERRY) +# include <bps/deviceinfo.h> +#endif + +#ifdef Q_OS_UNIX +#include <sys/utsname.h> +#include <private/qcore_unix_p.h> +#endif + +#include "archdetect.cpp" + QT_BEGIN_NAMESPACE #if !QT_DEPRECATED_SINCE(5, 0) @@ -258,6 +270,16 @@ Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); */ /*! + \fn QFlags::QFlags(std::initializer_list<Enum> flags) + \since 5.4 + + Constructs a QFlags object initialized with all \a flags + combined using the bitwise OR operator. + + \sa operator|=(), operator|() +*/ + +/*! \fn QFlags &QFlags::operator=(const QFlags &other) Assigns \a other to this object and returns a reference to this @@ -568,8 +590,8 @@ Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); 64-bit integer literals in a platform-independent way. The Q_CHECK_PTR() macro prints a warning containing the source code's file name and line number, saying that the program ran out of - memory, if the pointer is 0. The qPrintable() macro represent an - easy way of printing text. + memory, if the pointer is 0. The qPrintable() and qUtf8Printable() + macros represent an easy way of printing text. Finally, the QT_POINTER_SIZE macro expands to the size of a pointer in bytes, and the QT_VERSION and QT_VERSION_STR macros @@ -1096,6 +1118,7 @@ bool qSharedBuild() Q_DECL_NOTHROW \value MV_10_7 OS X 10.7 \value MV_10_8 OS X 10.8 \value MV_10_9 OS X 10.9 + \value MV_10_10 OS X 10.10 \value MV_Unknown An unknown and currently unsupported platform \value MV_CHEETAH Apple codename for MV_10_0 @@ -1108,6 +1131,7 @@ bool qSharedBuild() Q_DECL_NOTHROW \value MV_LION Apple codename for MV_10_7 \value MV_MOUNTAINLION Apple codename for MV_10_8 \value MV_MAVERICKS Apple codename for MV_10_9 + \value MV_YOSEMITE Apple codename for MV_10_10 \value MV_IOS iOS (any) \value MV_IOS_4_3 iOS 4.3 @@ -1117,6 +1141,7 @@ bool qSharedBuild() Q_DECL_NOTHROW \value MV_IOS_6_1 iOS 6.1 \value MV_IOS_7_0 iOS 7.0 \value MV_IOS_7_1 iOS 7.1 + \value MV_IOS_8_0 iOS 8.0 \sa WinVersion */ @@ -1500,6 +1525,8 @@ bool qSharedBuild() Q_DECL_NOTHROW \relates <QtGlobal> Defined if the application is compiled for Alpha processors. + + \sa QSysInfo::buildCpuArchitecture() */ /*! @@ -1509,6 +1536,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for ARM processors. Qt currently supports three optional ARM revisions: \l Q_PROCESSOR_ARM_V5, \l Q_PROCESSOR_ARM_V6, and \l Q_PROCESSOR_ARM_V7. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_ARM_V5 @@ -1516,6 +1545,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for ARMv5 processors. The \l Q_PROCESSOR_ARM macro is also defined when Q_PROCESSOR_ARM_V5 is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_ARM_V6 @@ -1524,6 +1555,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for ARMv6 processors. The \l Q_PROCESSOR_ARM and \l Q_PROCESSOR_ARM_V5 macros are also defined when Q_PROCESSOR_ARM_V6 is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_ARM_V7 @@ -1532,6 +1565,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for ARMv7 processors. The \l Q_PROCESSOR_ARM, \l Q_PROCESSOR_ARM_V5, and \l Q_PROCESSOR_ARM_V6 macros are also defined when Q_PROCESSOR_ARM_V7 is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! @@ -1539,6 +1574,8 @@ bool qSharedBuild() Q_DECL_NOTHROW \relates <QtGlobal> Defined if the application is compiled for AVR32 processors. + + \sa QSysInfo::buildCpuArchitecture() */ /*! @@ -1546,6 +1583,8 @@ bool qSharedBuild() Q_DECL_NOTHROW \relates <QtGlobal> Defined if the application is compiled for Blackfin processors. + + \sa QSysInfo::buildCpuArchitecture() */ /*! @@ -1554,6 +1593,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for IA-64 processors. This includes all Itanium and Itanium 2 processors. + + \sa QSysInfo::buildCpuArchitecture() */ /*! @@ -1564,6 +1605,8 @@ bool qSharedBuild() Q_DECL_NOTHROW supports seven MIPS revisions: \l Q_PROCESSOR_MIPS_I, \l Q_PROCESSOR_MIPS_II, \l Q_PROCESSOR_MIPS_III, \l Q_PROCESSOR_MIPS_IV, \l Q_PROCESSOR_MIPS_V, \l Q_PROCESSOR_MIPS_32, and \l Q_PROCESSOR_MIPS_64. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_MIPS_I @@ -1571,6 +1614,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for MIPS-I processors. The \l Q_PROCESSOR_MIPS macro is also defined when Q_PROCESSOR_MIPS_I is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_MIPS_II @@ -1579,6 +1624,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for MIPS-II processors. The \l Q_PROCESSOR_MIPS and \l Q_PROCESSOR_MIPS_I macros are also defined when Q_PROCESSOR_MIPS_II is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_MIPS_32 @@ -1587,6 +1634,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for MIPS32 processors. The \l Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, and \l Q_PROCESSOR_MIPS_II macros are also defined when Q_PROCESSOR_MIPS_32 is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_MIPS_III @@ -1595,6 +1644,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for MIPS-III processors. The \l Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, and \l Q_PROCESSOR_MIPS_II macros are also defined when Q_PROCESSOR_MIPS_III is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_MIPS_IV @@ -1604,6 +1655,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, \l Q_PROCESSOR_MIPS_II, and \l Q_PROCESSOR_MIPS_III macros are also defined when Q_PROCESSOR_MIPS_IV is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_MIPS_V @@ -1613,6 +1666,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, \l Q_PROCESSOR_MIPS_II, \l Q_PROCESSOR_MIPS_III, and \l Q_PROCESSOR_MIPS_IV macros are also defined when Q_PROCESSOR_MIPS_V is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_MIPS_64 @@ -1622,6 +1677,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Q_PROCESSOR_MIPS, \l Q_PROCESSOR_MIPS_I, \l Q_PROCESSOR_MIPS_II, \l Q_PROCESSOR_MIPS_III, \l Q_PROCESSOR_MIPS_IV, and \l Q_PROCESSOR_MIPS_V macros are also defined when Q_PROCESSOR_MIPS_64 is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! @@ -1631,6 +1688,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for POWER processors. Qt currently supports two Power variants: \l Q_PROCESSOR_POWER_32 and \l Q_PROCESSOR_POWER_64. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_POWER_32 @@ -1639,6 +1698,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for 32-bit Power processors. The \l Q_PROCESSOR_POWER macro is also defined when Q_PROCESSOR_POWER_32 is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_POWER_64 @@ -1647,6 +1708,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for 64-bit Power processors. The \l Q_PROCESSOR_POWER macro is also defined when Q_PROCESSOR_POWER_64 is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! @@ -1655,6 +1718,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for S/390 processors. Qt supports one optional variant of S/390: Q_PROCESSOR_S390_X. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_S390_X @@ -1662,6 +1727,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for S/390x processors. The \l Q_PROCESSOR_S390 macro is also defined when Q_PROCESSOR_S390_X is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! @@ -1670,6 +1737,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for SuperH processors. Qt currently supports one SuperH revision: \l Q_PROCESSOR_SH_4A. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_SH_4A @@ -1677,6 +1746,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for SuperH 4A processors. The \l Q_PROCESSOR_SH macro is also defined when Q_PROCESSOR_SH_4A is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! @@ -1685,6 +1756,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for SPARC processors. Qt currently supports one optional SPARC revision: \l Q_PROCESSOR_SPARC_V9. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_SPARC_V9 @@ -1693,6 +1766,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for SPARC V9 processors. The \l Q_PROCESSOR_SPARC macro is also defined when Q_PROCESSOR_SPARC_V9 is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! @@ -1701,6 +1776,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for x86 processors. Qt currently supports two x86 variants: \l Q_PROCESSOR_X86_32 and \l Q_PROCESSOR_X86_64. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_X86_32 @@ -1709,6 +1786,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for 32-bit x86 processors. This includes all i386, i486, i586, and i686 processors. The \l Q_PROCESSOR_X86 macro is also defined when Q_PROCESSOR_X86_32 is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! \macro Q_PROCESSOR_X86_64 @@ -1717,6 +1796,8 @@ bool qSharedBuild() Q_DECL_NOTHROW Defined if the application is compiled for 64-bit x86 processors. This includes all AMD64, Intel 64, and other x86_64/x64 processors. The \l Q_PROCESSOR_X86 macro is also defined when Q_PROCESSOR_X86_64 is defined. + + \sa QSysInfo::buildCpuArchitecture() */ /*! @@ -1838,7 +1919,7 @@ QSysInfo::WinVersion QSysInfo::windowsVersion() if (winver) return winver; #ifdef Q_OS_WINRT - winver = QSysInfo::WV_WINDOWS8; + winver = QSysInfo::WV_WINDOWS8_1; #else winver = QSysInfo::WV_NT; const OSVERSIONINFO osver = winOsVersion(); @@ -1931,9 +2012,479 @@ QSysInfo::WinVersion QSysInfo::windowsVersion() return winver; } +static const char *winVer_helper() +{ + switch (int(QSysInfo::WindowsVersion)) { + case QSysInfo::WV_NT: + return "NT"; + case QSysInfo::WV_2000: + return "2000"; + case QSysInfo::WV_XP: + return "XP"; + case QSysInfo::WV_2003: + return "2003"; + case QSysInfo::WV_VISTA: + return "Vista"; + case QSysInfo::WV_WINDOWS7: + return "7"; + case QSysInfo::WV_WINDOWS8: + return "8"; + case QSysInfo::WV_WINDOWS8_1: + return "8.1"; + + case QSysInfo::WV_CE: + return "CE"; + case QSysInfo::WV_CENET: + return "CENET"; + case QSysInfo::WV_CE_5: + return "CE5"; + case QSysInfo::WV_CE_6: + return "CE6"; + } + // unknown, future version + return 0; +} + const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion(); #endif +#if defined(Q_OS_UNIX) +# if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || defined(Q_OS_FREEBSD) +# define USE_ETC_OS_RELEASE +# endif +struct QUnixOSVersion +{ + // from uname(2) + QString sysName; + QString sysNameLower; + QString sysRelease; + +# if !defined(Q_OS_ANDROID) && !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_MAC) + // from /etc/os-release or guessed + QString versionIdentifier; // ${ID}_$VERSION_ID + QString versionText; // $PRETTY_NAME +# endif +}; + +# ifdef USE_ETC_OS_RELEASE +static QString unquote(const char *begin, const char *end) +{ + if (*begin == '"') { + Q_ASSERT(end[-1] == '"'); + return QString::fromLatin1(begin + 1, end - begin - 2); + } + return QString::fromLatin1(begin, end - begin); +} + +static bool readEtcOsRelease(QUnixOSVersion &v) +{ + // we're avoiding QFile here + int fd = qt_safe_open("/etc/os-release", O_RDONLY); + if (fd == -1) + return false; + + QT_STATBUF sbuf; + if (QT_FSTAT(fd, &sbuf) == -1) { + qt_safe_close(fd); + return false; + } + + QString partialIdentifier; + QByteArray buffer(sbuf.st_size, Qt::Uninitialized); + buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size)); + qt_safe_close(fd); + + const char *ptr = buffer.constData(); + const char *end = buffer.constEnd(); + const char *eol; + for ( ; ptr != end; ptr = eol + 1) { + static const char idString[] = "ID="; + static const char prettyNameString[] = "PRETTY_NAME="; + static const char versionIdString[] = "VERSION_ID="; + + // find the end of the line after ptr + eol = static_cast<const char *>(memchr(ptr, '\n', end - ptr)); + if (!eol) + eol = end - 1; + + int cmp = strncmp(ptr, idString, strlen(idString)); + if (cmp < 0) + continue; + if (cmp == 0) { + ptr += strlen(idString); + QString id = unquote(ptr, eol); + if (partialIdentifier.isNull()) + partialIdentifier = id; + else + v.versionIdentifier = id + QLatin1Char('_') + partialIdentifier; + continue; + } + + cmp = strncmp(ptr, prettyNameString, strlen(prettyNameString)); + if (cmp < 0) + continue; + if (cmp == 0) { + ptr += strlen(prettyNameString); + v.versionText = unquote(ptr, eol); + continue; + } + + cmp = strncmp(ptr, versionIdString, strlen(versionIdString)); + if (cmp < 0) + continue; + if (cmp == 0) { + ptr += strlen(versionIdString); + QString id = unquote(ptr, eol); + if (partialIdentifier.isNull()) + partialIdentifier = id; + else + v.versionIdentifier = partialIdentifier + QLatin1Char('_') + id; + continue; + } + } + + return true; +} +# endif // USE_ETC_OS_RELEASE + +static QUnixOSVersion detectUnixVersion() +{ + QUnixOSVersion v; + struct utsname u; + if (uname(&u) != -1) { + v.sysName = QString::fromLatin1(u.sysname); + v.sysNameLower = v.sysName.toLower(); + v.sysRelease = QString::fromLatin1(u.release); + } else { + v.sysName = QLatin1String("Detection failed"); + // leave sysNameLower & sysRelease unset + } + +# if !defined(Q_OS_ANDROID) && !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_MAC) +# ifdef USE_ETC_OS_RELEASE + if (readEtcOsRelease(v)) + return v; +# endif + + if (!v.sysNameLower.isEmpty()) { + // will produce "qnx_6.5" or "sunos_5.9" + v.versionIdentifier = v.sysNameLower + QLatin1Char('_') + v.sysRelease; + } +# endif + + return v; +} +#endif // Q_OS_UNIX + + +/*! + \since 5.4 + + Returns the architecture of the CPU that Qt was compiled for, in text + format. Note that this may not match the actual CPU that the application is + running on if there's an emulation layer or if the CPU supports multiple + architectures (like x86-64 processors supporting i386 applications). + + Values returned by this function are stable and will not change over time, + so applications can rely on the returned value as an identifier, except + that new CPU types may be added over time. + + Typical returned values are (note: list not exhaustive): + \list + \li "arm" + \li "i386" + \li "mips" + \li "x86_64" + \li "power" + \li "sparc" + \endlist + + \sa QSysInfo::buildAbi() +*/ +QString QSysInfo::buildCpuArchitecture() +{ + return QStringLiteral(ARCH_PROCESSOR); +} + +/*! + \since 5.4 + + Returns the full architecture string that Qt was compiled for. This string + is useful for identifying different, incompatible builds. For example, it + can be used as an identifier to request an upgrade package from a server. + + The values returned from this function are kept stable as follows: the + mandatory components of the result will not change in future versions of + Qt, but optional suffixes may be added. + + The returned value is composed of three or more parts, separated by dashes + ("-"). They are: + + \table + \header \li Component \li Value + \row \li CPU Architecture \li The same as QSysInfo::buildCpuArchitecture(), such as "arm", "i386", "mips" or "x86_64" + \row \li Endianness \li "little_endian" or "big_endian" + \row \li Word size \li Whether it's a 32- or 64-bit application. Possible values are: + "llp64" (Windows 64-bit), "lp64" (Unix 64-bit), "ilp32" (32-bit) + \row \li (Optional) ABI \li Zero or more components identifying different ABIs possible in this architecture. + Currently, Qt has optional ABI components for ARM and MIPS processors: one + component is the main ABI (such as "eabi", "o32", "n32", "o64"); another is + whether the calling convention is using hardware floating point registers ("hardfloat" + is present). + + Additionally, if Qt was configured with \c{-qreal float}, the ABI option tag "qreal_float" + will be present. If Qt was configured with another type as qreal, that type is present after + "qreal_", with all characters other than letters and digits escaped by an underscore, followed + by two hex digits. For example, \c{-qreal long double} becomes "qreal_long_20double". + \endtable + + \sa QSysInfo::buildCpuArchitecture() +*/ +QString QSysInfo::buildAbi() +{ +#ifdef Q_COMPILER_UNICODE_STRINGS + // ARCH_FULL is a concatenation of strings (incl. ARCH_PROCESSOR), which breaks + // QStringLiteral on MSVC. Since the concatenation behavior we want is specified + // the same C++11 paper as the Unicode strings, we'll use that macro and hope + // that Microsoft implements the new behavior when they add support for Unicode strings. + return QStringLiteral(ARCH_FULL); +#else + return QLatin1String(ARCH_FULL); +#endif +} + +static QString unknownText() +{ + return QStringLiteral("unknown"); +} + +/*! + \since 5.4 + + Returns the type of the operating system Qt was compiled for. It's also the + operating system the application is running on, unless the host operating + system is running a form of compatibility layer. + + Values returned by this function are stable and will not change over time, + so applications can rely on the returned value as an identifier, except + that new OS types may be added over time. + + \b{Android note}: this function returns "android" for Linux systems running + Android userspace, notably when using the Bionic library. For all other + Linux systems, regardless of C library being used, it returns "linux". + + \b{BlackBerry note}: this function returns "blackberry" for QNX systems + running the BlackBerry userspace, but "qnx" for all other QNX-based + systems. + + \b{Darwin, OS X and iOS note}: this function returns "osx" for OS X + systems, "ios" for iOS systems and "darwin" in case the system could not be + determined. + + \b{FreeBSD note}: this function returns "freebsd" for systems running the + FreeBSD kernel, regardless of whether the userspace runs the traditional + BSD code or whether it's the GNU system (Debian GNU/kFreeBSD). + + \sa QFileSelector, prettyOsName() +*/ +QString QSysInfo::osType() +{ + // similar, but not identical to QFileSelectorPrivate::platformSelectors +#if defined(Q_OS_WINPHONE) + return QStringLiteral("winphone"); +#elif defined(Q_OS_WINRT) + return QStringLiteral("winrt"); +#elif defined(Q_OS_WINCE) + return QStringLiteral("wince"); +#elif defined(Q_OS_WIN) + return QStringLiteral("windows"); + +#elif defined(Q_OS_BLACKBERRY) + return QStringLiteral("blackberry"); +#elif defined(Q_OS_QNX) + return QStringLiteral("qnx"); + +#elif defined(Q_OS_ANDROID) + return QStringLiteral("android"); +#elif defined(Q_OS_LINUX) + return QStringLiteral("linux"); + +#elif defined(Q_OS_IOS) + return QStringLiteral("ios"); +#elif defined(Q_OS_OSX) + return QStringLiteral("osx"); +#elif defined(Q_OS_DARWIN) + return QStringLiteral("darwin"); + +#elif defined(Q_OS_FREEBSD_KERNEL) + return QStringLiteral("freebsd"); +#elif defined(Q_OS_UNIX) + QUnixOSVersion unixOsVersion = detectUnixVersion(); + if (!unixOsVersion.sysNameLower.isEmpty()) + return unixOsVersion.sysNameLower; +#endif + return unknownText(); +} + +/*! + \since 5.4 + + Returns the version of the host operating system in string form. For both + OS X and iOS systems, this returns just the main OS version, such as "7.1", + "10.6" and "10.7". For Windows systems, this returns the same types + detected by winVersion(), without the word "Windows". For Linux-based + systems, it will try to determine the Linux distribution and version. + + If the version could not be determined, this function returns "unknown" for + Windows and a combination of the osType() and osKernelVersion() for Unix + systems. + + \sa prettyOsName(), osKernelVersion() +*/ +QString QSysInfo::osVersion() +{ +#if defined(Q_OS_IOS) + int major = (int(MacintoshVersion) >> 4) & 0xf; + int minor = int(MacintoshVersion) & 0xf; + if (Q_LIKELY(major < 10 && minor < 10)) { + char buf[4] = { char(major + '0'), '.', char(minor + '0'), '\0' }; + return QString::fromLatin1(buf, 3); + } + return QString::number(major) + QLatin1Char('.') + QString::number(minor); +#elif defined(Q_OS_OSX) + int minor = int(MacintoshVersion) - 2; // we're not running on Mac OS 9 + Q_ASSERT(minor < 100); + char buf[] = "10.0\0"; + if (Q_LIKELY(minor < 10)) { + buf[3] += minor; + } else { + buf[3] += minor / 10; + buf[4] = '0' + minor % 10; + } + return QString::fromLatin1(buf); +#elif defined(Q_OS_WIN) + const char *version = winVer_helper(); + if (version) + return QString::fromLatin1(version).toLower(); + // fall through + +// Android and Blackberry should not fall through to the Unix code +#elif defined(Q_OS_ANDROID) + // TBD +#elif defined(Q_OS_BLACKBERRY) + deviceinfo_details_t *deviceInfo; + if (deviceinfo_get_details(&deviceInfo) == BPS_SUCCESS) { + QString bbVersion = QString::fromLatin1(deviceinfo_details_get_device_os_version(deviceInfo)); + deviceinfo_free_details(&deviceInfo); + return bbVersion; + } +#elif defined(Q_OS_UNIX) + QUnixOSVersion unixOsVersion = detectUnixVersion(); + if (!unixOsVersion.versionIdentifier.isEmpty()) + return unixOsVersion.versionIdentifier; +#endif + + // fallback + return unknownText(); +} + +/*! + \since 5.4 + + Returns a prettier form of osVersion(), containing other information like + the operating system type, codenames and other information. The result of + this function is suitable for displaying to the user, but not for long-term + storage, as the string may change with updates to Qt. + + \sa osType(), osVersion() +*/ +QString QSysInfo::prettyOsName() +{ +#if defined(Q_OS_IOS) + return QLatin1String("iOS ") + osVersion(); +#elif defined(Q_OS_OSX) + // get the known codenames + const char *basename = 0; + switch (int(MacintoshVersion)) { + case MV_CHEETAH: + case MV_PUMA: + case MV_JAGUAR: + case MV_PANTHER: + case MV_TIGER: + // This version of Qt does not run on those versions of OS X + // so this case label will never be reached + Q_UNREACHABLE(); + break; + case MV_LEOPARD: + basename = "Mac OS X Leopard ("; + break; + case MV_SNOWLEOPARD: + basename = "Mac OS X Snow Leopard ("; + break; + case MV_LION: + basename = "Mac OS X Lion ("; + break; + case MV_MOUNTAINLION: + basename = "OS X Mountain Lion ("; + break; + case MV_MAVERICKS: + basename = "OS X Mavericks ("; + break; + case MV_YOSEMITE: + basename = "OS X Yosemite ("; + break; + } + if (basename) + return QLatin1String(basename) + osVersion() + QLatin1Char(')'); + + // a future version of OS X + return QLatin1String("OS X ") + osVersion(); +#elif defined(Q_OS_WINPHONE) + return QLatin1String("Windows Phone ") + QLatin1String(winVer_helper()); +#elif defined(Q_OS_WIN) + return QLatin1String("Windows ") + QLatin1String(winVer_helper()); +#elif defined(Q_OS_ANDROID) + return QLatin1String("Android ") + osVersion(); +#elif defined(Q_OS_BLACKBERRY) + return QLatin1String("BlackBerry ") + osVersion(); +#elif defined(Q_OS_UNIX) + QUnixOSVersion unixOsVersion = detectUnixVersion(); + if (unixOsVersion.versionText.isEmpty()) + return unixOsVersion.sysName; + else + return unixOsVersion.sysName + QLatin1String(" (") + unixOsVersion.versionText + QLatin1Char(')'); +#else + return unknownText(); +#endif +} + +/*! + \since 5.4 + + Returns the release version of the operating system. On Windows, it returns + the version of the kernel, which does not match the version number of the + OS (e.g., Windows 8 has NT kernel version 6.2). On Unix systems, including + Android, BlackBerry and OS X, it returns the same as the \c{uname -r} + command would return. + + If the version could not be determined, this function may return an empty + string. + + \sa osVersion(), prettyOsName() +*/ +QString QSysInfo::osKernelVersion() +{ +#ifdef Q_OS_WINRT + // TBD + return QString(); +#elif defined(Q_OS_WIN) + const OSVERSIONINFO osver = winOsVersion(); + return QString::number(int(osver.dwMajorVersion)) + QLatin1Char('.') + QString::number(int(osver.dwMinorVersion)) + + QLatin1Char('.') + QString::number(int(osver.dwBuildNumber)); +#else + return detectUnixVersion().sysRelease; +#endif +} /*! \macro void Q_ASSERT(bool test) @@ -2815,17 +3366,31 @@ int qrand() qPrintable() is used. This is because the array returned by QString::toLocal8Bit() will fall out of scope. + \note qDebug(), qWarning(), qCritical(), qFatal() expect %s + arguments to be UTF-8 encoded, while qPrintable() converts to + local 8-bit encoding. Therefore qUtf8Printable() should be used + for logging strings instead of qPrintable(). + + \sa qUtf8Printable() +*/ + +/*! + \macro const char *qUtf8Printable(const QString &str) + \relates <QtGlobal> + \since 5.4 + + Returns \a str as a \c{const char *}. This is equivalent to + \a{str}.toUtf8().constData(). + + The char pointer will be invalid after the statement in which + qUtf8Printable() is used. This is because the array returned by + QString::toUtf8() will fall out of scope. + Example: \snippet code/src_corelib_global_qglobal.cpp 37 - \note qDebug(), qWarning(), qCritical(), qFatal() expect %s - arguments to be UTF-8 encoded, while qPrintable() converts to - local 8-bit encoding. Therefore using qPrintable for logging - strings is only safe if the argument contains only ASCII - characters. - - \sa qDebug(), qWarning(), qCritical(), qFatal() + \sa qPrintable(), qDebug(), qWarning(), qCritical(), qFatal() */ /*! diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 255eb6c00b..5210d80953 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -45,11 +45,11 @@ #include <stddef.h> -#define QT_VERSION_STR "5.3.2" +#define QT_VERSION_STR "5.4.0" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x050302 +#define QT_VERSION 0x050400 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ @@ -649,6 +649,10 @@ inline void qUnused(T &x) { (void)x; } # define qPrintable(string) QString(string).toLocal8Bit().constData() #endif +#ifndef qUtf8Printable +# define qUtf8Printable(string) QString(string).toUtf8().constData() +#endif + class QString; Q_CORE_EXPORT QString qt_error_string(int errorCode = -1); @@ -865,22 +869,37 @@ Q_CORE_EXPORT void qFreeAligned(void *ptr); # endif #endif -#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT) -/* make use of typeof-extension */ +#if defined(Q_COMPILER_DECLTYPE) || (defined(Q_CC_GNU) && !defined(Q_CC_RVCT)) +/* make use of decltype or GCC's __typeof__ extension */ template <typename T> class QForeachContainer { public: - inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { } + inline QForeachContainer(const T& t) : c(t), i(c.begin()), e(c.end()), control(1) { } const T c; - int brk; typename T::const_iterator i, e; + int control; }; -#define Q_FOREACH(variable, container) \ -for (QForeachContainer<__typeof__((container))> _container_((container)); \ - !_container_.brk && _container_.i != _container_.e; \ - __extension__ ({ ++_container_.brk; ++_container_.i; })) \ - for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;})) +# ifdef Q_COMPILER_DECLTYPE +# 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 +// - if there were no breaks, at the end of the inner loop, it's set to 0, which +// causes it to exit (the inner loop is run exactly once) +// - at the end of the outer loop, it's inverted, so it becomes 1 again, allowing +// 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)); \ + _container_.control && _container_.i != _container_.e; \ + ++_container_.i, _container_.control ^= 1) \ + for (variable = *_container_.i; _container_.control; _container_.control = 0) #else diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index ad39452cf4..e9330a4b9e 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -57,7 +57,7 @@ enum GuardValues { }; } -#if defined(QT_NO_THREAD) || (defined(Q_CC_GNU) && !defined(Q_OS_MAC)) +#if defined(QT_NO_THREAD) || defined(Q_COMPILER_THREADSAFE_STATICS) // some compilers support thread-safe statics // The IA-64 C++ ABI requires this, so we know that all GCC versions since 3.4 // support it. C++11 also requires this behavior. diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp new file mode 100644 index 0000000000..0032e87401 --- /dev/null +++ b/src/corelib/global/qhooks.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Volker Krause <volker.krause@kdab.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qhooks_p.h" + +QT_BEGIN_NAMESPACE + +// Only add to the end, and bump version if you do. +quintptr Q_CORE_EXPORT qtHookData[] = { + 1, // hook data version + QHooks::LastHookIndex, // size of qtHookData + QT_VERSION, + + // AddQObject, void(*)(QObject*), called for every constructed QObject + // Note: this is called from the QObject constructor, ie. the sub-class + // constructors haven't run yet. + 0, + + // RemoveQObject, void(*)(QObject*), called for every destructed QObject + // Note: this is called from the QObject destructor, ie. the object + // you get as an argument is already largely invalid. + 0, + + // Startup, void(*)(), called once QCoreApplication is operational + 0 +}; + +Q_STATIC_ASSERT(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0])); + +QT_END_NAMESPACE + diff --git a/src/corelib/global/qhooks_p.h b/src/corelib/global/qhooks_p.h new file mode 100644 index 0000000000..012f91fa66 --- /dev/null +++ b/src/corelib/global/qhooks_p.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Volker Krause <volker.krause@kdab.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QHOOKS_H +#define QHOOKS_H + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + +class QObject; + +namespace QHooks { + +enum HookIndex { + HookDataVersion = 0, + HookDataSize = 1, + QtVersion = 2, + AddQObject = 3, + RemoveQObject = 4, + Startup = 5, + LastHookIndex +}; + +typedef void(*AddQObjectCallback)(QObject*); +typedef void(*RemoveQObjectCallback)(QObject*); +typedef void(*StartupCallback)(); + +} + +extern quintptr Q_CORE_EXPORT qtHookData[]; + +QT_END_NAMESPACE + +#endif diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 174c1d0d8d..f2ebeb6a03 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Intel Corporation ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -67,6 +68,7 @@ QString qt_libraryInfoFile() #endif #include "qconfig.cpp" +#include "archdetect.cpp" QT_BEGIN_NAMESPACE @@ -255,7 +257,37 @@ QLibraryInfo::buildDate() } #endif //QT_NO_DATESTRING -#if defined(Q_CC_CLANG) // must be before GNU, because clang claims to be GNU too +#if defined(Q_CC_INTEL) // must be before GNU, Clang and MSVC because ICC/ICL claim to be them +# ifdef __INTEL_CLANG_COMPILER +# define ICC_COMPAT "Clang" +# elif defined(__INTEL_MS_COMPAT_LEVEL) +# define ICC_COMPAT "Microsoft" +# elif defined(__GNUC__) +# define ICC_COMPAT "GCC" +# else +# define ICC_COMPAT "no" +# endif +# if __INTEL_COMPILER == 1300 +# define ICC_VERSION "13.0" +# elif __INTEL_COMPILER == 1310 +# define ICC_VERSION "13.1" +# elif __INTEL_COMPILER == 1400 +# define ICC_VERSION "14.0" +# elif __INTEL_COMPILER == 1500 +# define ICC_VERSION "15.0" +# else +# define ICC_VERSION QT_STRINGIFY(__INTEL_COMPILER) +# endif +# ifdef __INTEL_COMPILER_UPDATE +# define COMPILER_STRING "Intel(R) C++ " ICC_VERSION "." QT_STRINGIFY(__INTEL_COMPILER_UPDATE) \ + " build " QT_STRINGIFY(__INTEL_COMPILER_BUILD_DATE) " [" \ + ICC_COMPAT " compatibility]" +# else +# define COMPILER_STRING "Intel(R) C++ " ICC_VERSION \ + " build " QT_STRINGIFY(__INTEL_COMPILER_BUILD_DATE) " [" \ + ICC_COMPAT " compatibility]" +# endif +#elif defined(Q_CC_CLANG) // must be before GNU, because clang claims to be GNU too # ifdef __apple_build_version__ // Apple clang has other version numbers # define COMPILER_STRING "Clang " __clang_version__ " (Apple)" # else @@ -273,11 +305,22 @@ QLibraryInfo::buildDate() # elif _MSC_VER < 1900 # define COMPILER_STRING "MSVC 2013" # else -# define COMPILER_STRING "MSVC <unknown version>" +# define COMPILER_STRING "MSVC _MSC_VER " QT_STRINGIFY(_MSC_VER) # endif #else # define COMPILER_STRING "<unknown compiler>" #endif +#ifdef QT_NO_DEBUG +# define DEBUG_STRING " release" +#else +# define DEBUG_STRING " debug" +#endif +#ifdef QT_SHARED +# define SHARED_STRING " shared (dynamic)" +#else +# define SHARED_STRING " static" +#endif +#define QT_BUILD_STR "Qt " QT_VERSION_STR " (" ARCH_FULL SHARED_STRING DEBUG_STRING " build; by " COMPILER_STRING ")" /*! Returns a string describing how this version of Qt was built. @@ -289,21 +332,7 @@ QLibraryInfo::buildDate() const char *QLibraryInfo::build() Q_DECL_NOTHROW { - static const char data[] = "Qt " QT_VERSION_STR " (" __DATE__ ", " - COMPILER_STRING ", " -#if QT_POINTER_SIZE == 4 - "32" -#else - "64" -#endif - " bit, " -#ifdef QT_NO_DEBUG - "release" -#else - "debug" -#endif - " build)"; - return data; + return QT_BUILD_STR; } /*! @@ -590,7 +619,7 @@ extern const char qt_core_interpreter[] __attribute__((section(".interp"))) extern "C" void qt_core_boilerplate(); void qt_core_boilerplate() { - printf("This is the QtCore library version " QT_VERSION_STR "\n" + printf("This is the QtCore library version " QT_BUILD_STR "\n" "Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).\n" "Contact: http://www.qt-project.org/legal\n" "\n" diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index ca0fb1bb23..8174d125a3 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -48,6 +48,8 @@ #include "qmutex.h" #include "qloggingcategory.h" #ifndef QT_BOOTSTRAPPED +#include "qelapsedtimer.h" +#include "qdatetime.h" #include "qcoreapplication.h" #include "qthread.h" #include "private/qloggingregistry_p.h" @@ -171,89 +173,15 @@ static inline void convert_to_wchar_t_elided(wchar_t *d, size_t space, const cha } #endif -#if !defined(QT_NO_EXCEPTIONS) -/*! - \internal - Uses a local buffer to output the message. Not locale safe + cuts off - everything after character 255, but will work in out of memory situations. - Stop the execution afterwards. -*/ -static void qEmergencyOut(QtMsgType msgType, const char *msg, va_list ap) Q_DECL_NOEXCEPT -{ - char emergency_buf[256] = { '\0' }; - emergency_buf[sizeof emergency_buf - 1] = '\0'; -#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) && (defined(Q_OS_WINCE) || defined(Q_OS_WINRT)) \ - || defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) - wchar_t emergency_bufL[sizeof emergency_buf]; -#endif - - if (msg) - qvsnprintf(emergency_buf, sizeof emergency_buf - 1, msg, ap); - -#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) -# if defined(Q_OS_WINCE) || defined(Q_OS_WINRT) - convert_to_wchar_t_elided(emergency_bufL, sizeof emergency_buf, emergency_buf); - OutputDebugStringW(emergency_bufL); -# else - if (qWinLogToStderr()) { - fprintf(stderr, "%s\n", emergency_buf); - fflush(stderr); - } else { - OutputDebugStringA(emergency_buf); - } -# endif -#else - fprintf(stderr, "%s\n", emergency_buf); - fflush(stderr); -#endif - - if (isFatal(msgType)) { -#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR) - // get the current report mode - int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW); - _CrtSetReportMode(_CRT_ERROR, reportMode); -# ifndef Q_OS_WINCE // otherwise already converted to wchar_t above - convert_to_wchar_t_elided(emergency_bufL, sizeof emergency_buf, emergency_buf); -# endif - int ret = _CrtDbgReportW(_CRT_ERROR, _CRT_WIDE(__FILE__), __LINE__, - _CRT_WIDE(QT_VERSION_STR), - emergency_bufL); - if (ret == 1) - _CrtDbgBreak(); -#endif - -#if (defined(Q_OS_UNIX) || defined(Q_CC_MINGW)) - abort(); // trap; generates core dump -#else - exit(1); // goodbye cruel world -#endif - } -} -#endif - /*! \internal */ static void qt_message(QtMsgType msgType, const QMessageLogContext &context, const char *msg, va_list ap, QString &buf) { -#if !defined(QT_NO_EXCEPTIONS) - if (std::uncaught_exception()) { - qEmergencyOut(msgType, msg, ap); - return; - } -#endif - if (msg) { - QT_TRY { - buf = QString().vsprintf(msg, ap); - } QT_CATCH(const std::bad_alloc &) { -#if !defined(QT_NO_EXCEPTIONS) - qEmergencyOut(msgType, msg, ap); - // don't rethrow - we use qWarning and friends in destructors. - return; -#endif - } - } + + if (msg) + buf = QString().vsprintf(msg, ap); qt_message_print(msgType, context, buf); } @@ -834,6 +762,7 @@ static const char functionTokenC[] = "%{function}"; static const char pidTokenC[] = "%{pid}"; static const char appnameTokenC[] = "%{appname}"; static const char threadidTokenC[] = "%{threadid}"; +static const char timeTokenC[] = "%{time"; //not a typo: this command has arguments static const char ifCategoryTokenC[] = "%{if-category}"; static const char ifDebugTokenC[] = "%{if-debug}"; static const char ifWarningTokenC[] = "%{if-warning}"; @@ -854,9 +783,14 @@ struct QMessagePattern { // 0 terminated arrays of literal tokens / literal or placeholder tokens const char **literals; const char **tokens; + QString timeFormat; bool fromEnvironment; static QBasicMutex mutex; +#ifndef QT_BOOTSTRAPPED + QElapsedTimer timer; + QDateTime startTime; +#endif }; QBasicMutex QMessagePattern::mutex; @@ -865,7 +799,13 @@ QMessagePattern::QMessagePattern() : literals(0) , tokens(0) , fromEnvironment(false) +#ifndef QT_BOOTSTRAPPED + , startTime(QDateTime::currentDateTime()) +#endif { +#ifndef QT_BOOTSTRAPPED + timer.start(); +#endif const QString envPattern = QString::fromLocal8Bit(qgetenv("QT_MESSAGE_PATTERN")); if (envPattern.isEmpty()) { setPattern(QLatin1String(defaultPattern)); @@ -953,6 +893,12 @@ void QMessagePattern::setPattern(const QString &pattern) tokens[i] = appnameTokenC; else if (lexeme == QLatin1String(threadidTokenC)) tokens[i] = threadidTokenC; + else if (lexeme.startsWith(QLatin1String(timeTokenC))) { + tokens[i] = timeTokenC; + int spaceIdx = lexeme.indexOf(QChar::fromLatin1(' ')); + if (spaceIdx > 0) + timeFormat = lexeme.mid(spaceIdx + 1, lexeme.length() - spaceIdx - 2); + } #define IF_TOKEN(LEVEL) \ else if (lexeme == QLatin1String(LEVEL)) { \ @@ -1122,6 +1068,12 @@ Q_CORE_EXPORT QString qMessageFormatString(QtMsgType type, const QMessageLogCont } else if (token == threadidTokenC) { message.append(QLatin1String("0x")); message.append(QString::number(qlonglong(QThread::currentThread()->currentThread()), 16)); + } else if (token == timeTokenC) { + quint64 ms = pattern->timer.elapsed(); + if (pattern->timeFormat.isEmpty()) + message.append(QString().sprintf("%6d.%03d", uint(ms / 1000), uint(ms % 1000))); + else + message.append(pattern->startTime.addMSecs(ms).toString(pattern->timeFormat)); #endif } else if (token == ifCategoryTokenC) { if (!context.category || (strcmp(context.category, "default") == 0)) @@ -1503,6 +1455,9 @@ void qErrnoWarning(int code, const char *msg, ...) \row \li \c %{pid} \li QCoreApplication::applicationPid() \row \li \c %{threadid} \li ID of current thread \row \li \c %{type} \li "debug", "warning", "critical" or "fatal" + \row \li \c %{time} \li time of the message, in seconds since the process started + \row \li \c %{time format} \li system time when the message occurred, formatted by + passing the \c format to \l QDateTime::toString() \endtable You can also use conditionals on the type of the message using \c %{if-debug}, @@ -1514,7 +1469,7 @@ void qErrnoWarning(int code, const char *msg, ...) Example: \code - QT_MESSAGE_PATTERN="[%{if-debug}D%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}" + QT_MESSAGE_PATTERN="[%{time yyyyMMdd h:mm:ss.zzz t} %{if-debug}D%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}] %{file}:%{line} - %{message}" \endcode The default \a pattern is "%{if-category}%{category}: %{endif}%{message}". diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index 6ebffa3ba1..043f799414 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -65,9 +65,9 @@ class QMessageLogContext { Q_DISABLE_COPY(QMessageLogContext) public: - Q_DECL_CONSTEXPR QMessageLogContext() : version(1), line(0), file(0), function(0), category(0) {} + Q_DECL_CONSTEXPR QMessageLogContext() : version(2), line(0), file(0), function(0), category(0) {} Q_DECL_CONSTEXPR QMessageLogContext(const char *fileName, int lineNumber, const char *functionName, const char *categoryName) - : version(1), line(lineNumber), file(fileName), function(functionName), category(categoryName) {} + : version(2), line(lineNumber), file(fileName), function(functionName), category(categoryName) {} void copy(const QMessageLogContext &logContext); diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 839d352d36..3ec859dbb7 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -521,6 +521,7 @@ public: AA_ForceRasterWidgets = 14, AA_UseDesktopOpenGL = 15, AA_UseOpenGLES = 16, + AA_UseSoftwareOpenGL = 17, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 4227dd358e..e5c708e29a 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -168,14 +168,26 @@ \value AA_ForceRasterWidgets Make top-level widgets use pure raster surfaces, and do not support non-native GL-based child widgets. - \value AA_UseDesktopOpenGL Forces the usage of the desktop OpenGL on - platforms that use dynamic loading of the OpenGL implementation. + \value AA_UseDesktopOpenGL Forces the usage of desktop OpenGL (for example, + \e opengl32.dll or \e libGL.so) on platforms that use dynamic loading + of the OpenGL implementation. This value has been added in Qt 5.3. - \value AA_UseOpenGLES Forces the usage of OpenGL ES 2.0 on platforms that - use dynamic loading of the OpenGL implementation. + \value AA_UseOpenGLES Forces the usage of OpenGL ES 2.0 or higher on + platforms that use dynamic loading of the OpenGL implementation. This value has been added in Qt 5.3. + \value AA_UseSoftwareOpenGL Forces the usage of a software based OpenGL + implementation on platforms that use dynamic loading of the OpenGL + implementation. This will typically be a patched build of + \l{http://www.mesa3d.org/llvmpipe.html}{Mesa llvmpipe}, providing + OpenGL 2.1. The value may have no effect if no such OpenGL + implementation is available. The default name of this library is + QtSoftwareOpenGL.dll and can be overridden by setting the environment + variable \e QT_OPENGL_DLL. See the platform-specific pages, for + instance \l{Qt for Windows}, for more information. This value has + been added in Qt 5.4. + The following values are obsolete: \value AA_ImmediateWidgetCreation This attribute is no longer fully diff --git a/src/corelib/global/qnumeric.cpp b/src/corelib/global/qnumeric.cpp index 7d8bd8c3c6..21d0209dd7 100644 --- a/src/corelib/global/qnumeric.cpp +++ b/src/corelib/global/qnumeric.cpp @@ -140,6 +140,7 @@ static inline quint32 f2i(float f) \endcode \sa qFuzzyCompare() + \since 5.2 \relates <QtGlobal> */ Q_CORE_EXPORT quint32 qFloatDistance(float a, float b) @@ -197,6 +198,7 @@ static inline quint64 d2i(double d) \sa qFuzzyCompare() + \since 5.2 \relates <QtGlobal> */ Q_CORE_EXPORT quint64 qFloatDistance(double a, double b) diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h index 38735c12de..45d54c3873 100644 --- a/src/corelib/global/qsysinfo.h +++ b/src/corelib/global/qsysinfo.h @@ -136,6 +136,7 @@ public: MV_10_7 = 0x0009, MV_10_8 = 0x000A, MV_10_9 = 0x000B, + MV_10_10 = 0x000C, /* codenames */ MV_CHEETAH = MV_10_0, @@ -148,6 +149,7 @@ public: MV_LION = MV_10_7, MV_MOUNTAINLION = MV_10_8, MV_MAVERICKS = MV_10_9, + MV_YOSEMITE = MV_10_10, /* iOS */ MV_IOS = 1 << 8, @@ -157,11 +159,19 @@ public: MV_IOS_6_0 = Q_MV_IOS(6, 0), MV_IOS_6_1 = Q_MV_IOS(6, 1), MV_IOS_7_0 = Q_MV_IOS(7, 0), - MV_IOS_7_1 = Q_MV_IOS(7, 1) + MV_IOS_7_1 = Q_MV_IOS(7, 1), + MV_IOS_8_0 = Q_MV_IOS(8, 0) }; static const MacVersion MacintoshVersion; static MacVersion macVersion(); #endif + + static QString buildCpuArchitecture(); + static QString buildAbi(); + static QString osType(); + static QString osKernelVersion(); + static QString osVersion(); + static QString prettyOsName(); }; QT_END_NAMESPACE diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h index 0431e10133..b2e99ac259 100644 --- a/src/corelib/global/qsystemdetection.h +++ b/src/corelib/global/qsystemdetection.h @@ -235,6 +235,9 @@ # if !defined(__MAC_10_9) # define __MAC_10_9 1090 # endif +# if !defined(__MAC_10_10) +# define __MAC_10_10 101000 +# endif # if !defined(MAC_OS_X_VERSION_10_7) # define MAC_OS_X_VERSION_10_7 1070 # endif @@ -244,6 +247,9 @@ # if !defined(MAC_OS_X_VERSION_10_9) # define MAC_OS_X_VERSION_10_9 1090 # endif +# if !defined(MAC_OS_X_VERSION_10_10) +# define MAC_OS_X_VERSION_10_10 101000 +# endif # # if !defined(__IPHONE_4_3) # define __IPHONE_4_3 40300 @@ -263,6 +269,12 @@ # if !defined(__IPHONE_7_0) # define __IPHONE_7_0 70000 # endif +# if !defined(__IPHONE_7_1) +# define __IPHONE_7_1 70100 +# endif +# if !defined(__IPHONE_8_0) +# define __IPHONE_8_0 80000 +# endif #endif #ifdef __LSB_VERSION__ diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 8478e08416..70dc623e0c 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -64,7 +64,7 @@ public: isComplex = true, isStatic = true, isLarge = (sizeof(T)>sizeof(void*)), - isDummy = false, + isDummy = false, //### Qt6: remove sizeOf = sizeof(T) }; }; |