diff options
author | Liang Qi <liang.qi@qt.io> | 2017-04-07 08:31:13 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2017-04-07 09:38:34 +0000 |
commit | 191a21047863cd327d3e8102b08dbf20a4c6e0a5 (patch) | |
tree | 9be92e3111992951d87571ebbcf1e2859901050f /src/corelib | |
parent | dea78262e52da38de47301e206459967aa6719bb (diff) | |
parent | 5d6073be27cb951b692bbcc4dc0dd54cc09c9fd4 (diff) |
Merge "Merge remote-tracking branch 'origin/5.9' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 9 | ||||
-rw-r--r-- | src/corelib/global/qfloat16.h | 15 | ||||
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 2 | ||||
-rw-r--r-- | src/corelib/global/qlogging.cpp | 2 | ||||
-rw-r--r-- | src/corelib/global/qmalloc.cpp | 11 | ||||
-rw-r--r-- | src/corelib/global/qsysinfo.h | 23 | ||||
-rw-r--r-- | src/corelib/io/qlockfile_unix.cpp | 1 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.h | 2 | ||||
-rw-r--r-- | src/corelib/statemachine/qstatemachine.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qcryptographichash.cpp | 55 | ||||
-rw-r--r-- | src/corelib/tools/qvector.h | 1 | ||||
-rw-r--r-- | src/corelib/xml/qxmlstream_p.h | 1 |
13 files changed, 84 insertions, 42 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 8a8d781cf8..fcfe020509 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1329,15 +1329,14 @@ Q_ASSUME_IMPL(valueOfExpression);\ } while (0) +#if defined(__cplusplus) #if QT_HAS_CPP_ATTRIBUTE(fallthrough) # define Q_FALLTHROUGH() [[fallthrough]] -#elif defined(__cplusplus) -/* Clang can not parse namespaced attributes in C mode, but defines __has_cpp_attribute */ -# if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) +#elif QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) # define Q_FALLTHROUGH() [[clang::fallthrough]] -# elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) +#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) # define Q_FALLTHROUGH() [[gnu::fallthrough]] -# endif +#endif #endif #ifndef Q_FALLTHROUGH # if defined(Q_CC_GNU) && Q_CC_GNU >= 700 diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 651057f8e2..05b88e0e92 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -113,10 +113,14 @@ inline Q_REQUIRED_RESULT bool qIsNull(qfloat16 f) Q_DECL_NOTHROW inline int qIntCast(qfloat16 f) Q_DECL_NOTHROW { return int(static_cast<float>(f)); } +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wc99-extensions") inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW { -#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) - b16 = _cvtss_sh(f, 0); +#if defined(QT_COMPILER_SUPPORTS_F16C) && (defined(__F16C__) || defined(__AVX2__)) + __m128 packsingle = _mm_set_ss(f); + __m128i packhalf = _mm_cvtps_ph(packsingle, 0); + b16 = _mm_extract_epi16(packhalf, 0); #elif defined (__ARM_FP16_FORMAT_IEEE) __fp16 f16 = f; memcpy(&b16, &f16, sizeof(quint16)); @@ -127,11 +131,14 @@ inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW + ((u & 0x007fffff) >> shifttable[(u >> 23) & 0x1ff]); #endif } +QT_WARNING_POP inline qfloat16::operator float() const Q_DECL_NOTHROW { -#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) - return _cvtsh_ss(b16); +#if defined(QT_COMPILER_SUPPORTS_F16C) && (defined(__F16C__) || defined(__AVX2__)) + __m128i packhalf = _mm_cvtsi32_si128(b16); + __m128 packsingle = _mm_cvtph_ps(packhalf); + return _mm_cvtss_f32(packsingle); #elif defined (__ARM_FP16_FORMAT_IEEE) __fp16 f16; memcpy(&f16, &b16, sizeof(quint16)); diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 03ee0730db..b4ba0b5b2e 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -663,6 +663,8 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName) + QLatin1String("Arguments"); return settings->value(key).toStringList(); } +#else + Q_UNUSED(platformName); #endif // !QT_BUILD_QMAKE && !QT_NO_SETTINGS return QStringList(); } diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 927c1bb76b..cb78732526 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -217,7 +217,7 @@ static bool willLogToConsole() # elif defined(Q_OS_UNIX) // if /dev/tty exists, we can only open it if we have a controlling TTY int devtty = qt_safe_open("/dev/tty", O_RDONLY); - if (devtty == -1 && (errno == ENOENT || errno == EPERM)) { + if (devtty == -1 && (errno == ENOENT || errno == EPERM || errno == ENXIO)) { // no /dev/tty, fall back to isatty on stderr return isatty(STDERR_FILENO); } else if (devtty != -1) { diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index f83cecd499..05676a0da2 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -40,6 +40,7 @@ #include "qplatformdefs.h" #include <stdlib.h> +#include <string.h> /* Define the container allocation functions in a separate file, so that our @@ -79,8 +80,6 @@ void *qMallocAligned(size_t size, size_t alignment) void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t alignment) { // fake an aligned allocation - Q_UNUSED(oldsize); - void *actualptr = oldptr ? static_cast<void **>(oldptr)[-1] : 0; if (alignment <= sizeof(void*)) { // special, fast case @@ -110,9 +109,15 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align quintptr faked = reinterpret_cast<quintptr>(real) + alignment; faked &= ~(alignment - 1); - void **faked_ptr = reinterpret_cast<void **>(faked); + if (oldptr) { + qptrdiff oldoffset = static_cast<char *>(oldptr) - static_cast<char *>(actualptr); + qptrdiff newoffset = reinterpret_cast<char *>(faked_ptr) - static_cast<char *>(real); + if (oldoffset != newoffset) + memmove(faked_ptr, static_cast<char *>(real) + oldoffset, qMin(oldsize, newsize)); + } + // now save the value of the real pointer at faked-sizeof(void*) // by construction, alignment > sizeof(void*) and is a power of 2, so // faked-sizeof(void*) is properly aligned for a pointer diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h index 3cbcfd3fc9..ff0a784ace 100644 --- a/src/corelib/global/qsysinfo.h +++ b/src/corelib/global/qsysinfo.h @@ -135,19 +135,6 @@ public: WV_CE_6 = 0x0400, WV_CE_based = 0x0f00 }; -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") -QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") -QT_WARNING_DISABLE_INTEL(1478) -QT_WARNING_DISABLE_MSVC(4996) -#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) - QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static const WinVersion WindowsVersion; - QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static WinVersion windowsVersion(); -#else - QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static const WinVersion WindowsVersion = WV_None; - QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static WinVersion windowsVersion() { return WV_None; } -#endif -QT_WARNING_POP #define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0)) #define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor) @@ -222,11 +209,19 @@ QT_WARNING_POP MV_WATCHOS_2_2 = Q_MV_WATCHOS(2, 2), MV_WATCHOS_3_0 = Q_MV_WATCHOS(3, 0) }; + QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations") QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations") -QT_WARNING_DISABLE_INTEL(1478) +QT_WARNING_DISABLE_INTEL(1786) QT_WARNING_DISABLE_MSVC(4996) +#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) + QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static const WinVersion WindowsVersion; + QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static WinVersion windowsVersion(); +#else + QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static const WinVersion WindowsVersion = WV_None; + QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static WinVersion windowsVersion() { return WV_None; } +#endif #if defined(Q_OS_MAC) QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static const MacVersion MacintoshVersion; QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()") static MacVersion macVersion(); diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index 5a02741727..ccc607afd5 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -115,6 +115,7 @@ int QLockFilePrivate::checkFcntlWorksAfterFlock(const QString &fn) return 0; return 1; #else + Q_UNUSED(fn); return 0; #endif } diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 5e2e746bbc..f704c5b21a 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -527,7 +527,7 @@ public: static bool load(QDataStream &stream, int type, void *data); #endif - explicit QMetaType(const int type); + explicit QMetaType(const int type); // ### Qt6: drop const inline ~QMetaType(); inline bool isValid() const; diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index c0e5f2f591..a2c5711993 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -464,7 +464,7 @@ public: void create(int type, const void *copy); bool cmp(const QVariant &other) const; int compare(const QVariant &other) const; - bool convert(const int t, void *ptr) const; + bool convert(const int t, void *ptr) const; // ### Qt6: drop const private: // force compile error, prevent QVariant(bool) to be called diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index d7cdec9aac..1d80da55c9 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -2331,6 +2331,7 @@ void QStateMachinePrivate::unregisterAllTransitions() unregisterSignalTransition(t); } } +#if QT_CONFIG(qeventtransition) { QList<QEventTransition*> transitions = rootState()->findChildren<QEventTransition*>(); for (int i = 0; i < transitions.size(); ++i) { @@ -2339,6 +2340,7 @@ void QStateMachinePrivate::unregisterAllTransitions() unregisterEventTransition(t); } } +#endif } #if QT_CONFIG(qeventtransition) diff --git a/src/corelib/tools/qcryptographichash.cpp b/src/corelib/tools/qcryptographichash.cpp index 08f89d2f02..963a91b9a9 100644 --- a/src/corelib/tools/qcryptographichash.cpp +++ b/src/corelib/tools/qcryptographichash.cpp @@ -180,9 +180,45 @@ public: SHA3Context sha3Context; #endif }; +#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 + void sha3Finish(int bitCount); +#endif QByteArray result; }; +#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1 +void QCryptographicHashPrivate::sha3Finish(int bitCount) +{ + /* + FIPS 202 ยง6.1 defines SHA-3 in terms of calculating the Keccak function + over the original message with the two-bit suffix "01" appended to it. + This variable stores that suffix (and it's fed into the calculations + when the hash is returned to users). + + Only 2 bits of this variable are actually used (see the call to sha3Update + below). The Keccak implementation we're using will actually use the + *leftmost* 2 bits, and interpret them right-to-left. In other words, the + bits must appear in order of *increasing* significance; and as the two most + significant bits of the byte -- the rightmost 6 are ignored. (Yes, this + seems self-contradictory, but it's the way it is...) + + Overall, this means: + * the leftmost two bits must be "10" (not "01"!); + * we don't care what the other six bits are set to (they can be set to + any value), but we arbitrarily set them to 0; + + and for an unsigned char this gives us 0b10'00'00'00, or 0x80. + */ + static const unsigned char sha3FinalSuffix = 0x80; + + result.resize(bitCount / 8); + + SHA3Context copy = sha3Context; + sha3Update(©, reinterpret_cast<const BitSequence *>(&sha3FinalSuffix), 2); + sha3Final(©, reinterpret_cast<BitSequence *>(result.data())); +} +#endif + /*! \class QCryptographicHash \inmodule QtCore @@ -196,7 +232,8 @@ public: QCryptographicHash can be used to generate cryptographic hashes of binary or text data. - Currently MD4, MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 are supported. + Refer to the documentation of the \l QCryptographicHash::Algorithm enum for a + list of the supported algorithms. */ /*! @@ -426,27 +463,19 @@ QByteArray QCryptographicHash::result() const break; } case Sha3_224: { - SHA3Context copy = d->sha3Context; - d->result.resize(224/8); - sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); + d->sha3Finish(224); break; } case Sha3_256: { - SHA3Context copy = d->sha3Context; - d->result.resize(256/8); - sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); + d->sha3Finish(256); break; } case Sha3_384: { - SHA3Context copy = d->sha3Context; - d->result.resize(384/8); - sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); + d->sha3Finish(384); break; } case Sha3_512: { - SHA3Context copy = d->sha3Context; - d->result.resize(512/8); - sha3Final(©, reinterpret_cast<BitSequence *>(d->result.data())); + d->sha3Finish(512); break; } #endif diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index ab5a2944bf..57e80ae125 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -291,6 +291,7 @@ public: private: friend class QRegion; // Optimization for QRegion::rects() + // ### Qt6: remove const from int parameters void reallocData(const int size, const int alloc, QArrayData::AllocationOptions options = QArrayData::Default); void reallocData(const int sz) { reallocData(sz, d->alloc); } void freeData(Data *d); diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h index 1edd716094..72cc7c9bb4 100644 --- a/src/corelib/xml/qxmlstream_p.h +++ b/src/corelib/xml/qxmlstream_p.h @@ -1139,6 +1139,7 @@ bool QXmlStreamReaderPrivate::parse() case '\n': ++lineNumber; lastLineStart = characterOffset + readBufferPos; + Q_FALLTHROUGH(); case ' ': case '\t': token = SPACE; |