From a6ffdbe30c49fa1ede0d147531b89d121d00fa94 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 7 Oct 2019 05:30:54 +0200 Subject: QTextCodec: try to work around an ICC 19 bug ICC 19 barfs on the TextCodecsMutexLocker class because it doesn't have a user-provided default ctor: ../../corelib/codecs/qtextcodec.cpp(543): error #854: const variable locker requires an initializer -- class TextCodecsMutexLocker has no user-provided default constructor [...] But the class doesn't have members that would delete the implictly-declared default ctor, so no user-provided default ctor should be necessary: The only member is the result of qt_unique_lock(), which is std::unique_lock, which does have a default ctor. We conclude that this is a compiler bug, and work around it with the introduction of a user-provided default ctor. Fix brace placement as a drive-by. Fixes: QTBUG-78844 Change-Id: I1f5a326afd68138fbebad506ba9aa1926f1afb85 Reviewed-by: Thiago Macieira --- src/corelib/codecs/qtextcodec.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/corelib') 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::ConstIterator ByteArrayListConstIt; Q_GLOBAL_STATIC(QRecursiveMutex, textCodecsMutex); -class TextCodecsMutexLocker { +class TextCodecsMutexLocker +{ using Lock = decltype(qt_unique_lock(std::declval())); // ### 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) -- cgit v1.2.3 From 1ed9cc2a93a1b5215b5ad149d9698aa970d1756a Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 1 Oct 2019 07:05:15 +0200 Subject: Drop unused code These defines are never used; maybe a remnant from Qt 4? Change-Id: Ieb12e629493e5483ca5ab84577569610eceb9417 Reviewed-by: Edward Welbourne Reviewed-by: Ulf Hermann --- src/corelib/text/qlocale_tools_p.h | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'src/corelib') 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 { -- cgit v1.2.3 From 780137d585344bf9de906a285a50498104c0c66e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 13 Aug 2019 21:59:26 -0700 Subject: QRandom: add support for RDSEED The Intel whitepaer[1] recommends using the RDSEED over RDRAND whenever present. libstdc++ from GCC 10 will also use it in std::random_device. [ChangeLog][QtCore][QRandomGenerator] The system() random generator will now use the RDSEED instruction on x86 processors whenever available as the first source of random data. It will fall back to RDRAND and then to the system functions, in that order. [1] https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide Change-Id: I907a43cd9a714da288a2fffd15bab176e54e1975 Reviewed-by: Edward Welbourne --- src/corelib/tools/qsimd.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'src/corelib') 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(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(ptr))) ptr += sizeof(qregisteruint)/sizeof(*ptr); @@ -657,5 +692,4 @@ out: } #endif - QT_END_NAMESPACE -- cgit v1.2.3