diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2015-01-21 11:14:34 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2015-01-21 11:14:34 +0100 |
commit | 112342b32650f56e289c7dcd181d5897b0b77a78 (patch) | |
tree | 76e9a37bcaa70097d009628bb2b116ea782c72cb /src/corelib/global | |
parent | 3bbc1bf53bac7648637d92abecadc568acfffb2d (diff) | |
parent | b6191b16d41459ed73cea738dfaf8e25e81ae22b (diff) |
Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/global.pri | 2 | ||||
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 6 | ||||
-rw-r--r-- | src/corelib/global/qendian.h | 12 | ||||
-rw-r--r-- | src/corelib/global/qglobal.cpp | 78 | ||||
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 7 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 2 |
6 files changed, 90 insertions, 17 deletions
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index 86621364ec..0b1374a3bb 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -35,6 +35,8 @@ INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global # Only used on platforms with CONFIG += precompile_header PRECOMPILED_HEADER = global/qt_pch.h +# qlogging.cpp uses backtrace(3), which is in a separate library on the BSDs. + if(linux*|hurd*):!cross_compile:!static:!*-armcc* { QMAKE_LFLAGS += -Wl,-e,qt_core_boilerplate prog=$$quote(if (/program interpreter: (.*)]/) { print $1; }) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 77f6c48857..2881a0fcbd 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -142,6 +142,10 @@ # if defined(__INTEL_COMPILER) /* Intel C++ also masquerades as GCC */ # define Q_CC_INTEL (__INTEL_COMPILER) +# ifdef __clang__ +/* Intel C++ masquerades as Clang masquerading as GCC */ +# define Q_CC_CLANG 305 +# endif # define Q_ASSUME_IMPL(expr) __assume(expr) # define Q_UNREACHABLE_IMPL() __builtin_unreachable() # if __INTEL_COMPILER >= 1300 && !defined(__APPLE__) @@ -537,9 +541,11 @@ # define Q_COMPILER_RANGE_FOR # define Q_COMPILER_RAW_STRINGS # define Q_COMPILER_REF_QUALIFIERS +# define Q_COMPILER_UNICODE_STRINGS # define Q_COMPILER_UNRESTRICTED_UNIONS # endif # if __INTEL_COMPILER >= 1500 +# define Q_COMPILER_CONSTEXPR # define Q_COMPILER_ALIGNAS # define Q_COMPILER_ALIGNOF # define Q_COMPILER_INHERITING_CONSTRUCTORS diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 1d72ba0fae..957ba2ad63 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -87,9 +87,15 @@ 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) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 206) +#if (defined(Q_CC_GNU) && Q_CC_GNU >= 403) || QT_HAS_BUILTIN(__builtin_bswap32) template <> inline quint64 qbswap<quint64>(quint64 source) { return __builtin_bswap64(source); @@ -130,7 +136,7 @@ template <> inline quint32 qbswap<quint32>(quint32 source) | ((source & 0xff000000) >> 24); } #endif // GCC & Clang intrinsics -#if (defined(Q_CC_GNU) && Q_CC_GNU >= 408) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 302) +#if (defined(Q_CC_GNU) && Q_CC_GNU >= 408) || QT_HAS_BUILTIN(__builtin_bswap16) template <> inline quint16 qbswap<quint16>(quint16 source) { return __builtin_bswap16(source); @@ -148,6 +154,8 @@ 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 4895bf6dd9..0a9e2f97db 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -41,6 +41,8 @@ #include "qdatetime.h" #include <private/qlocale_tools_p.h> +#include <private/qsystemlibrary_p.h> + #ifndef QT_NO_QOBJECT #include <private/qthread_p.h> #endif @@ -1876,6 +1878,70 @@ QT_BEGIN_INCLUDE_NAMESPACE QT_END_INCLUDE_NAMESPACE #ifndef Q_OS_WINRT + +# ifndef Q_OS_WINCE + +// Determine Windows versions >= 8 by querying the version of kernel32.dll. +static inline bool determineWinOsVersionPost8(OSVERSIONINFO *result) +{ + typedef WORD (WINAPI* PtrGetFileVersionInfoSizeW)(LPCWSTR, LPDWORD); + typedef BOOL (WINAPI* PtrVerQueryValueW)(LPCVOID, LPCWSTR, LPVOID, PUINT); + typedef BOOL (WINAPI* PtrGetFileVersionInfoW)(LPCWSTR, DWORD, DWORD, LPVOID); + + QSystemLibrary versionLib(QStringLiteral("version")); + if (!versionLib.load()) + return false; + PtrGetFileVersionInfoSizeW getFileVersionInfoSizeW = (PtrGetFileVersionInfoSizeW)versionLib.resolve("GetFileVersionInfoSizeW"); + PtrVerQueryValueW verQueryValueW = (PtrVerQueryValueW)versionLib.resolve("VerQueryValueW"); + PtrGetFileVersionInfoW getFileVersionInfoW = (PtrGetFileVersionInfoW)versionLib.resolve("GetFileVersionInfoW"); + if (!getFileVersionInfoSizeW || !verQueryValueW || !getFileVersionInfoW) + return false; + + const wchar_t kernel32Dll[] = L"kernel32.dll"; + DWORD handle; + const DWORD size = getFileVersionInfoSizeW(kernel32Dll, &handle); + if (!size) + return false; + QScopedArrayPointer<BYTE> versionInfo(new BYTE[size]); + if (!getFileVersionInfoW(kernel32Dll, handle, size, versionInfo.data())) + return false; + UINT uLen; + VS_FIXEDFILEINFO *fileInfo = Q_NULLPTR; + if (!verQueryValueW(versionInfo.data(), L"\\", (LPVOID *)&fileInfo, &uLen)) + return false; + const DWORD fileVersionMS = fileInfo->dwFileVersionMS; + const DWORD fileVersionLS = fileInfo->dwFileVersionLS; + result->dwMajorVersion = HIWORD(fileVersionMS); + result->dwMinorVersion = LOWORD(fileVersionMS); + result->dwBuildNumber = HIWORD(fileVersionLS); + return true; +} + +// Fallback for determining Windows versions >= 8 by looping using the +// version check macros. Note that it will return build number=0 to avoid +// inefficient looping. +static inline void determineWinOsVersionFallbackPost8(OSVERSIONINFO *result) +{ + result->dwBuildNumber = 0; + DWORDLONG conditionMask = 0; + VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL); + OSVERSIONINFOEX checkVersion = { sizeof(OSVERSIONINFOEX), result->dwMajorVersion, 0, + result->dwBuildNumber, result->dwPlatformId, {'\0'}, 0, 0, 0, 0, 0 }; + for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMajorVersion) + result->dwMajorVersion = checkVersion.dwMajorVersion; + conditionMask = 0; + checkVersion.dwMajorVersion = result->dwMajorVersion; + checkVersion.dwMinorVersion = 0; + VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_EQUAL); + VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL); + for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMinorVersion) + result->dwMinorVersion = checkVersion.dwMinorVersion; +} + +# endif // !Q_OS_WINCE + static inline OSVERSIONINFO winOsVersion() { OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0, {'\0'}}; @@ -1891,16 +1957,8 @@ static inline OSVERSIONINFO winOsVersion() # endif # ifndef Q_OS_WINCE if (result.dwMajorVersion == 6 && result.dwMinorVersion == 2) { - // This could be Windows 8.1 or higher. Note that as of Windows 9, - // the major version needs to be checked as well. - DWORDLONG conditionMask = 0; - VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL); - VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL); - VER_SET_CONDITION(conditionMask, VER_PLATFORMID, VER_EQUAL); - OSVERSIONINFOEX checkVersion = { sizeof(OSVERSIONINFOEX), result.dwMajorVersion, result.dwMinorVersion, - result.dwBuildNumber, result.dwPlatformId, {'\0'}, 0, 0, 0, 0, 0 }; - for ( ; VerifyVersionInfo(&checkVersion, VER_MAJORVERSION | VER_MINORVERSION | VER_PLATFORMID, conditionMask); ++checkVersion.dwMinorVersion) - result.dwMinorVersion = checkVersion.dwMinorVersion; + if (!determineWinOsVersionPost8(&result)) + determineWinOsVersionFallbackPost8(&result); } # endif // !Q_OS_WINCE return result; diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index c60ca7e9b0..575da452b9 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -116,10 +116,11 @@ QLibrarySettings::QLibrarySettings() QStringList children = settings->childGroups(); #ifdef QT_BOOTSTRAPPED haveEffectiveSourcePaths = children.contains(QLatin1String("EffectiveSourcePaths")); - haveEffectivePaths = haveEffectiveSourcePaths || children.contains(QLatin1String("EffectivePaths")); #else - haveEffectivePaths = children.contains(QLatin1String("EffectivePaths")); + // EffectiveSourcePaths is for the Qt build only, so needs no backwards compat trickery. + bool haveEffectiveSourcePaths = false; #endif + haveEffectivePaths = haveEffectiveSourcePaths || children.contains(QLatin1String("EffectivePaths")); // Backwards compat: an existing but empty file is claimed to contain the Paths section. havePaths = (!haveEffectivePaths && !children.contains(QLatin1String(platformsSection))) || children.contains(QLatin1String("Paths")); @@ -128,9 +129,7 @@ QLibrarySettings::QLibrarySettings() settings.reset(0); #else } else { -#ifdef QT_BOOTSTRAPPED haveEffectiveSourcePaths = false; -#endif haveEffectivePaths = false; havePaths = false; #endif diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 4b582642f3..c8aa53aced 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -592,7 +592,7 @@ string, "ddd MMM d yyyy". See QDate::toString() for more information. \value ISODate \l{ISO 8601} extended format: either \c{YYYY-MM-DD} for dates or - \c{YYYY-MM-DDTHH:MM:SS}, \c{YYYY-MM-DDTHH:MM:SSTZD} (e.g., 1997-07-16T19:20:30+01:00) + \c{YYYY-MM-DDTHH:mm:ss}, \c{YYYY-MM-DDTHH:mm:ssTZD} (e.g., 1997-07-16T19:20:30+01:00) for combined dates and times. \value SystemLocaleShortDate The \l{QLocale::ShortFormat}{short format} used |