diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-10-10 01:01:26 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-10-10 01:01:26 +0200 |
commit | 8b91c6831546f884437122ce243b8a08c328a13c (patch) | |
tree | 7430b8cb7c61616f00ebfa221f5a478a8cb59c64 /src/corelib | |
parent | 0e12c8b020d8bb54d214ecbab284429cc702e2d0 (diff) | |
parent | 780137d585344bf9de906a285a50498104c0c66e (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: Iab9b3a7d004a2e4b4de816f4a2d7ed2fb936d3ae
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/codecs/qtextcodec.cpp | 5 | ||||
-rw-r--r-- | src/corelib/text/qlocale_tools_p.h | 16 | ||||
-rw-r--r-- | src/corelib/tools/qsimd.cpp | 36 |
3 files changed, 39 insertions, 18 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 14f9abc28a..06fd88da90 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -103,10 +103,13 @@ typedef QList<QByteArray>::ConstIterator ByteArrayListConstIt; Q_GLOBAL_STATIC(QRecursiveMutex, textCodecsMutex); -class TextCodecsMutexLocker { +class TextCodecsMutexLocker +{ using Lock = decltype(qt_unique_lock(std::declval<QRecursiveMutex&>())); // ### FIXME: this is used when textCodecsMutex already == nullptr const Lock lock = qt_unique_lock(textCodecsMutex()); +public: + TextCodecsMutexLocker() {} // required d/t an ICC 19 bug }; #if !QT_CONFIG(icu) diff --git a/src/corelib/text/qlocale_tools_p.h b/src/corelib/text/qlocale_tools_p.h index 594331ae37..e2142bf545 100644 --- a/src/corelib/text/qlocale_tools_p.h +++ b/src/corelib/text/qlocale_tools_p.h @@ -54,22 +54,6 @@ #include "qlocale_p.h" #include "qstring.h" -#if !defined(QT_QLOCALE_NEEDS_VOLATILE) -# if defined(Q_CC_GNU) -# if __GNUC__ == 4 -# define QT_QLOCALE_NEEDS_VOLATILE -# elif defined(Q_OS_WIN) -# define QT_QLOCALE_NEEDS_VOLATILE -# endif -# endif -#endif - -#if defined(QT_QLOCALE_NEEDS_VOLATILE) -# define NEEDS_VOLATILE volatile -#else -# define NEEDS_VOLATILE -#endif - QT_BEGIN_NAMESPACE enum StrayCharacterMode { diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index fb9b5996f6..6e3b0f9faf 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -626,8 +626,40 @@ void qDumpCPUFeatures() # ifdef Q_PROCESSOR_X86_64 # define _rdrandXX_step _rdrand64_step +# define _rdseedXX_step _rdseed64_step # else # define _rdrandXX_step _rdrand32_step +# define _rdseedXX_step _rdseed32_step +# endif + +# if QT_COMPILER_SUPPORTS_HERE(RDSEED) +static QT_FUNCTION_TARGET(RDSEED) unsigned *qt_random_rdseed(unsigned *ptr, unsigned *end) noexcept +{ + // Unlike for the RDRAND code below, the Intel whitepaper describing the + // use of the RDSEED instruction indicates we should not retry in a loop. + // If the independent bit generator used by RDSEED is out of entropy, it + // may take time to replenish. + // https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide + while (ptr + sizeof(qregisteruint)/sizeof(*ptr) <= end) { + if (_rdseedXX_step(reinterpret_cast<qregisteruint *>(ptr)) == 0) + goto out; + ptr += sizeof(qregisteruint)/sizeof(*ptr); + } + + if (sizeof(*ptr) != sizeof(qregisteruint) && ptr != end) { + if (_rdseed32_step(ptr) == 0) + goto out; + ++ptr; + } + +out: + return ptr; +} +# else +static unsigned *qt_random_rdseed(unsigned *ptr, unsigned *) +{ + return ptr; +} # endif QT_FUNCTION_TARGET(RDRND) qsizetype qRandomCpu(void *buffer, qsizetype count) noexcept @@ -636,6 +668,9 @@ QT_FUNCTION_TARGET(RDRND) qsizetype qRandomCpu(void *buffer, qsizetype count) no unsigned *end = ptr + count; int retries = 10; + if (qCpuHasFeature(RDSEED)) + ptr = qt_random_rdseed(ptr, end); + while (ptr + sizeof(qregisteruint)/sizeof(*ptr) <= end) { if (_rdrandXX_step(reinterpret_cast<qregisteruint *>(ptr))) ptr += sizeof(qregisteruint)/sizeof(*ptr); @@ -657,5 +692,4 @@ out: } #endif - QT_END_NAMESPACE |