summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
Commit message (Collapse)AuthorAgeFilesLines
...
* | QFileSystemEngine::renameFile: use calls that don't overwriteThiago Macieira2017-08-042-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The renameat2(2) Linux system call, new in 3.16, allows for the atomic renaming of a file if and only if it won't clobber an existing file. None of the Linux libcs have enabled this syscall as an API, so we use syscall(3) to place the call. If your libc has SYS_renameat2 but your kernel doesn't support it, we'll keep issuing the unknown syscall, every time. Users in that situation should upgrade (3.16 is from 2014). On Darwin, there's a similar renameatx_np (guessing "np" stands for "non-portable"). I haven't found anything similar on the other BSDs. Change-Id: I1eba2b016de74620bfc8fffd14ccb4e455a3ec9e Reviewed-by: David Faure <david.faure@kdab.com>
* | Long live qEnvironmentVariable()Thiago Macieira2017-08-042-17/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore] Added qEnvironmentVariable, which returns the value of an environment variable in a QString, while qgetenv continues to be used to return it in a QByteArray. For Unix, since most environment variables seem to contain path names, qEnvironmentVariable will do the same as QFile::decodeName, which means NFC/NFD conversion on Apple OSes. I opted not to #include <qfile.h> from qglobal.cpp to implement that QFile::decodeName functionality, so qglobal.cpp doesn't depend on corelib/io and to avoid possible recursions. Task-number: QTBUG-41006 Change-Id: I14839ba5678944c2864bffff141794b8aaa7aa28 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.9' into devOswald Buddenhagen2017-08-021-1/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/xcb/qxcbconnection.h src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp src/plugins/styles/mac/qmacstyle_mac.mm src/widgets/widgets/qdockarealayout.cpp src/widgets/widgets/qmainwindow.cpp src/widgets/widgets/qmainwindowlayout.cpp src/widgets/widgets/qmainwindowlayout_p.h tests/auto/corelib/tools/qlocale/tst_qlocale.cpp tests/auto/other/macnativeevents/BLACKLIST tests/auto/widgets/widgets/qmenu/BLACKLIST Change-Id: Ic8e724b80a65e7b1af25511b0e674d209265e567
| * Blacklist use of [[nodiscard]] with ClangThiago Macieira2017-07-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | __has_cpp_attribute(nodiscard) is 1 in all compilation modes, but if you use it outside of C++1z, you get a warning. LLVM-bug: https://bugs.llvm.org/show_bug.cgi?id=33518 Task-number: QTBUG-61840 Task-number: QTBUG-62085 Change-Id: I84e45059a888497fb55ffffd14d3683f4808978b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Docs: Fix day/year format in QDateTimeDavid Fries2017-07-281-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | QDateTime takes dd and yyyy. It is confusing when the example format strings don't work because they use DD YYYY, and it is a silent error with the characters not getting substituted and can be easy to miss. Improved Qt::ISODate, TZD isn't a format character so skip writing out a bad format example. Task-number: QTBUG-62111 Change-Id: Ia61d561074ae885fc0a99238d93cb34aaa9953bb Reviewed-by: David Fries <david@fries.net> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Fix use of getentropy on larger blocksThiago Macieira2017-07-271-2/+16
| | | | | | | | | | | | | | | | | | | | | | Found while working on suppressing the warning about the return value (which is either 0 or -1) was being ignored. Task-number: QTBUG-61968 Change-Id: I02d22222fff64d4dbda4fffd14d148b1724547ca Reviewed-by: Florian Bruhin <qt-project.org@the-compiler.org> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add API to disable text shaping on fontsEskil Abrahamsen Blomfeldt2017-07-261-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the past, we had an undocumented text flag that worked with one of the QPainter::drawText() overloads. This was never intended as public API and served a specific cause in Qt WebKit at one point. But there is a general need for such API, as disabling shaping features easily gives 25% performance improvement on text rendering even for fairly short strings. This patch adds a new style strategy flag to disable shaping and will just uses the CMAP and HDMX tables to get glyph indices and advances for the characters. In Qt 6, the TextBypassShaping flag can be removed completely and be replaced by the style strategy. [ChangeLog][QtGui][Text] Added QFont::PreferNoShaping style strategy to support improvements to performance at the expense of some cosmetic font features. Task-number: QTBUG-56728 Change-Id: I48e025dcc06afe02824bf5b5011702a7e0036f6d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devSimon Hausmann2017-07-192-92/+18
|\| | | | | | | | | | | | | | | Conflicts: src/corelib/io/qwindowspipewriter.cpp src/widgets/styles/qcommonstyle.cpp Change-Id: I0d33efdc4dc256e234abc490a18ccda72cd1d9e6
| * Merge qt_error_string and QSystemErrorThiago Macieira2017-07-181-92/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This removes a lot of duplicated code that existed in both qglobal.cpp and qsystemerror.cpp, including the hack to get the correct strerror_r signature. This removes the incorrect use of EACCES, EMFILE, ENOENT, and ENOSPC from qt_error_string on Windows. qt_error_string is supposed to be used only with Win32 error codes from GetLastError(), despite there being a lot of uses in cross-platform and even Windows-specific code that pass errno constants. It may or may not work: that depends on whether the constants happen to match. ENOENT matches ERROR_FILE_NOT_FOUND and one could argue that ENOSPC matching ERROR_OUT_OF_PAPER is acceptable, but EMFILE isn't the same as ERROR_BAD_LENGTH nor is EACCES, ERROR_INVALID_DATA. Change-Id: I1eba2b016de74620bfc8fffd14cccb7f77f4b510 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Update OS version constants in qsystemdetection.hJake Petroules2017-07-161-0/+18
| | | | | | | | | | | | Change-Id: I8c8fa8861280948bf8488c4465a359858bb625e0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.9' into devGabriel de Dietrich2017-07-133-10/+10
|\| | | | | | | | | | | | | Conflicts: src/widgets/widgets/qmainwindowlayout.cpp Change-Id: I306b4f5ad11bceb336c9091241b468d455fe6bb6
| * Fix modernize-use-bool-literals issuesKevin Funk2017-07-082-9/+9
| | | | | | | | | | | | | | | | | | | | | | Reported by clang-tidy. Skipped fixes in implementation files, only changed headers. Change-Id: I5cfd266b3d4046f90baebc0c538b1b6ab03a02d2 Reviewed-by: Volker Krause <volker.krause@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Use the namespace-mangled symbol for the qt_version_tag group nameThiago Macieira2017-07-071-1/+1
| | | | | | | | | | | | | | | | | | | | Doesn't affect our current builds since it's just a marker for the linker on what sections should be merged. Unless you're mixing namespaced and non-namespaced static builds into one executable. Change-Id: Ia53158e207a94bf49489fffd14c7bc294fccf8f9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Move endian-specific integer types to public qtendian headerAllan Sandfeld Jensen2017-07-093-81/+490
| | | | | | | | | | | | | | | | | | The classes have recently been cleaned up to be ready for being made public, and this change adds the final documentation. The classes are already used in qjson, qtdeclarative and some image format decoders. Change-Id: Ib6df89f1119162c5bad7a08e9b6f843a2db4040f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-07-062-8/+21
|\| | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: I43531e087bb810889d5c1fbfcdffb29b78804839
| * Make qt_check_pointer more OOM-safeThiago Macieira2017-07-032-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First, it can never return, so we can mark it Q_NORETURN and add an std::termianate at the end. Though if it did, we'd end up in a null- pointer dereference crash in the caller. Second, add Q_DECL_NOTHROW to it. It can't throw, but it terminates execution. This also prevents both puts and fprintf from escaping via pthread asynchronous cancellation on Linux/glibc. Third, don't use QMessageLogger, since that allocates memory and actually uses QString. If we really are in an OOM situation, then QString's failed allocation would recurse back into qt_check_pointer. We'd compound the OOM situation with a stack overflow... Change-Id: Ia53158e207a94bf49489fffd14c81c47971f4e82 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Use QMessageLogger context properly in qglobal.cpp redirectsThiago Macieira2017-07-031-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qt_assert and qt_check_pointer get the function name and line number from the caller (the functions are called from the Q_ASSERT and Q_CHECK_PTR macros, respectively), so we don't need to capture the context from those two functions. Instead, pass the context to QMessageLogger for proper logging. I've left the file name and line number in the assertions, for users who did not add them to their message log pattern, but I've removed from the almost never used qt_check_pointer function. Note: how useful is it that we allocate memory in response to failing to allocate memory? Change-Id: Ia53158e207a94bf49489fffd14c81b359c5b6537 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* | Rename the "sys_auxv" feature to "getauxval"Thiago Macieira2017-07-062-3/+3
| | | | | | | | | | Change-Id: I8d96dea9955d4c749b99fffd14cdbd1e69940d33 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-07-042-4/+11
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qprocess_unix.cpp src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/widgets/util/util.pri tests/auto/corelib/thread/qthread/qthread.pro tests/auto/corelib/thread/qthread/tst_qthread.cpp Change-Id: I5c45ab54d46d3c75a5c6c116777ebf5bc47a871b
| * QOperatingSystemVersion: (potentially) fix compilation with QNX 6Marc Mutz2017-06-282-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | According to qcompilerdetection.h, the Dinkumware C++ library does not have std::initializer_list, even though the compiler supports it. Add the missing Q_COMPILER_ guards. Change-Id: I84a7d5054c00dba38bcde15e277ceb0ee05e6cd7 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: James McDonnell <jmcdonnell@blackberry.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * QOperatingSystemVersion: mark as Q_RELOCATABLE_TYPEMarc Mutz2017-06-281-0/+1
| | | | | | | | | | | | | | | | and Q_PRIMITIVE_TYPE-come-Qt-6. Change-Id: I97bb9add8ed0870fb70c231d6fed6abce8729434 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * QOperatingSystemVersion/Android: compress global dataMarc Mutz2017-06-281-3/+6
| | | | | | | | | | | | | | | | | | | | The values do not need to be 2 x 32-bits. Eight bits suffice for a long time to come. Should save 189 bytes in text size on Android builds. Change-Id: I78e31e7caa7a698f41c66d7bbac58a766c6e8834 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * QOperatingSystemVersion: remove unneded copy ctor declarationMarc Mutz2017-06-281-1/+0
| | | | | | | | | | | | | | | | | | The copy constructor is not disabled by any user-defined move or copy special member function, and thus does not need to be = default'ed. Change-Id: I90586d25756885ac77f0946c147079efb5d1b1e0 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QRandomGenerator: use getentropy on Linux & OpenBSDThiago Macieira2017-06-303-11/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The getentropy function, first found in OpenBSD, is present in glibc since version 2.25 and Bionic since Android 6.0 and NDK r11. It uses the Linux 3.17 getrandom system call. Unlike glibc's getrandom() wrapper, the glibc implementation of getentropy() function is not a POSIX thread cancellation point, so we prefer to use that even though we have to break the reading into 256-byte blocks. The big advantage is that these functions work even in the absence of a /dev/urandom device node, in addition to a few cycles shaved off by not having to open a file descriptor and close it at exit. What's more, the glibc implementation blocks until entropy is available on early boot, so we don't have to worry about a failure mode. The Bionic implementation will fall back by itself to /dev/urandom and, failing that, gathering entropy from elsewhere in the system in a way it cannot fail either. uClibc has a wrapper to getrandom(2) but no getentropy(3). MUSL has neither. Change-Id: Ia53158e207a94bf49489fffd14c8cee1b968a619 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Linux: add a note to the ELF binary what minimum Linux is neededThiago Macieira2017-06-302-0/+108
| | | | | | | | | | | | | | Change-Id: Ia53158e207a94bf49489fffd14c8d2a1f173ff97 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | qglobal.h: fix build in assembler modeThiago Macieira2017-06-301-2/+5
| | | | | | | | | | | | | | QT_CONFIG and some other macros are unavailable there. Change-Id: Ia53158e207a94bf49489fffd14c8d306e2dbd9d2 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | Move qle_bitfield to qendian_p.hAllan Sandfeld Jensen2017-06-271-1/+83
| | | | | | | | | | | | | | | | | | Makes the qle_bitfield template more generic and moves it to qendian_p.h It is also hardened to be more reliable. Change-Id: I53214ec99cceee4f5e8934ae688c99e555a5fb42 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QRandomGenerator: Rework the fallback seedingThiago Macieira2017-06-251-38/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qdeadlinetimer.cpp and qelapsedtimer_*.cpp are not part of the bootstrap library. Instead of adding them there, just remove this entropy source from bootstrapped builds (instead of just qmake). To compensate, store all the bits instead of trying to combine them into just one 32-bit word. We've got a few new sources from the stack and libc, plus two more ELF auxvec values that the Linux kernel supplies (inspired by OpenBSD's getentropy_linux.c, which is used in Bionic). Task-number: QTBUG-61492 Change-Id: I1d5a585d4af842f9a66ffffd14c999ae8c44f46c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Move endian integers to qendian_p.hAllan Sandfeld Jensen2017-06-212-0/+142
| | | | | | | | | | | | | | | | | | | | The endian integers have more use than just in QJson, and is already used separately by QtDeclarative. This patch moves q_littleendian out of qjson_p.h and matches it with a corresponding q_bigendian, and puts it to use in simplifying endian handling in the ico image handler. Change-Id: I975bb701a089256db8ced3cb53b4bd62cdfb02dd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Mark bswap and related methods constexprAllan Sandfeld Jensen2017-06-201-81/+33
| | | | | | | | | | | | | | | | | | Marks the bswap methods constexpr and removes the special versions explicitly using builtins as both clang and gcc automatically recognizes bswap code and replaces it with builtins. Change-Id: I07258431ac2588f6046682ffb9c832e650faf66a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Doc: add a note about QRandomGenerator returning the sign bit setThiago Macieira2017-06-201-0/+18
| | | | | | | | | | | | | | | | Found this in a few uses of qrand() that assumed the result would be non-negative. Change-Id: Ia53158e207a94bf49489fffd14c7c029515cf42c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QRandomGenerator: don't internally rely on QT_HAS_INCLUDEThiago Macieira2017-06-202-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC didn't support it until version 5 or 6, so add configure tests for both <random> and <sys/auxv.h>. Normally I'd say "upgrade", but this is too low-level and important a feature. There's a good chance that all our supported compilers have <random> anyway. As for <sys/auxv.h>, it's present on Glibc, Bionic and MUSL, but I don't see it in uClibc (AT_RANDOM is a Linux-specific feature). Change-Id: Ia3e896da908f42939148fffd14c5b2af491f7a77 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Fix some qdoc warnings for 5.10Friedemann Kleint2017-06-201-27/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix comments for QRandomGenerator. src/corelib/io/qprocess.cpp:453: warning: Cannot find 'startDetached(...)' in '\fn' bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid) src/corelib/tools/qstringiterator.qdoc:122: warning: Cannot find 'QStringIterator(...)' in '\fn' QStringIterator::QStringIterator(QStringView string, QStringView::size_type idx) src/corelib/global/qrandom.cpp:902: warning: Can't link to 'QRandomGenerator' src/sql/kernel/qsqlerror.cpp:123: warning: Unknown command '\other' src/network/kernel/qhostinfo.cpp:296: warning: Unknown command '\other' src/gui/kernel/qplatformcursor.cpp:97: warning: Cannot find 'QPlatformCursor::OverrideCursor' specified with '\enum' in any header file src/network/access/qnetworkreply.cpp:307: warning: Can't link to 'QNetworkAccessManager::setRedirectsPolicy()' src/network/access/qnetworkreply.cpp:307: warning: Can't link to 'QNetworkRequest::RedirectsPolicyAttribute' Change-Id: Ibc2455b1b657716dfb6192615738dc7f924dbab3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-197-55/+51
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/plugins/platforms/android/qandroidplatformintegration.h src/plugins/platforms/windows/qwindowscontext.cpp src/plugins/platforms/windows/windows.pri src/tools/uic/cpp/cppwriteinitialization.cpp src/widgets/doc/src/widgets-and-layouts/gallery.qdoc Change-Id: I8d0834c77f350ea7540140c2c7f372814afc2d0f
| * rename qglobalstatic.cpp -> qglobalstatic.qdocOswald Buddenhagen2017-06-172-3/+0
| | | | | | | | | | | | | | | | it contains no code. Change-Id: Ie8a43abb2db3d040f7046206adf2bf555960dd9c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * QLogging: Fix unused static function warningOrgad Shaneh2017-06-131-1/+1
| | | | | | | | | | | | | | Detected by clang Change-Id: Ia7d1bf085d838d19319ee1060dcb3c0086a510e4 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
| * Update for the newest Darwin-family operating systemsJake Petroules2017-06-073-0/+11
| | | | | | | | | | | | Change-Id: Id6533c8a444854f6215f6e47000875ef9751905b Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Use the C++ [[nodiscard]] attributeThiago Macieira2017-06-071-31/+36
| | | | | | | | | | | | Change-Id: I7814054a102a407d876ffffd14b6a285c70b21de Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Re-fix the detection of CPU architecture on an Apple OSThiago Macieira2017-06-071-20/+3
| | | | | | | | | | | | | | | | | | | | | | Commit d56c6cf7a4fe2b7e5543d58a786efc768b7370c2 was incorrect. It was a nice try, but on a 64-bit Mac machine (x86_64 CPU), it returned hw.cputype = 7, which is CPU_TYPE_X86. CPU_TYPE_X86_64 is only used in Mach-O slices for fat binaries and does not reflect hw.cputype. Task-number: QTBUG-61205 Change-Id: Ia3e896da908f42939148fffd14c54b3050b8e64b Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | QRandomGenerator: mix the Linux AT_RANDOM random bytes in the fallbackThiago Macieira2017-06-121-3/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Linux kernel gives us 16 bytes of random data and sets a pointer to it in the ELF AuxV (the same one that allows us to get HWCAP on ARM systems). So if we end up in the fallback generator, at leat we'll get a good amount of entropy to seed the Mersenne Twister. This could happen if the application is run in a chroot(2) or container without /dev/random or /dev/urandom. That is probably an installation mistake, so we don't optimize this case for performance. With this commit, we have now good, high-quality fallbacks for Windows (rand_s), for BSDs (arc4random) and for Linux. The only missing, supported OS without a good entropy source is QNX. Change-Id: Ia3e896da908f42939148fffd14c5b1084051f1a8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QRandomGenerator: improve the fallback seeding in emergenciesThiago Macieira2017-06-121-1/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we've never read any samples from hardware RNG or from /dev/urandom, then there are no stored samples for us to seed the Mersenne Twister. In that case, attempt to obtain an emergency sample that consists of some random bits from the variable addresses (ASLR should help) and from the clock (using nanosecond quality, instead of seconds). There's still the possibility that we'll get poor entropy: very close to boot, if the kernel entropy pool is empty, ASLR could be poor and the monotonic clock value could be consistent from boot to boot. There's nothing we can do about that. Change-Id: Ia3e896da908f42939148fffd14c5b0c7b608371b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QRandomGenerator: use arc4random as fallback on BSDs (including Darwin)Thiago Macieira2017-06-121-0/+7
| | | | | | | | | | | | | | | | | | This function works even in chroots where /dev is not available. Since it's part of the OS, it may have better ways of gathering entropy even when we don't. Change-Id: Ia3e896da908f42939148fffd14c5afedc8569dbc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QRandomGenerator: add support for hardware-based random generatorsThiago Macieira2017-06-121-2/+46
| | | | | | | | | | | | | | | | | | | | | | This commit adds support for the x86 RDRAND instruction for QRandomGenerator. This is the same that libstdc++-v3 uses for std::random_device() by default. If it fails because the hardware does not have enough entropy collected, we fall back to the operating system generator, which often has more entropy collected from other sources. Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5167214e1ea3f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Use QtPrivate::FunctionPointer to get the type of srand's first argThiago Macieira2017-06-121-7/+2
| | | | | | | | | | | | | | Avoids #ifdefs and guesswork. Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5210efaea7d00 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Move qrand() & qsrand() to qrandom.cppThiago Macieira2017-06-122-136/+140
| | | | | | | | | | | | | | Now that we have the file, may as well consolidate Change-Id: Icd0e0d4b27cb4e5eb892fffd14b51d3e701c6a94 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Long live QRandomGeneratorThiago Macieira2017-06-125-4/+968
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This class provides a reasonably-secure random number generator that does not need seeding. That is quite unlike qrand(), which requires a seed and is low-quality (definitely not secure). This class is also like std::random_device, but better. It provides an operator() like std::random_device, but unlike that, it also provides a way to fill a buffer with random data, not just one 32-bit quantity. It's also stateless. Finally, it also implements std::seed_seq-like generate(). It obeys the standard requirement of the range (32-bit) but not that of the algorithm (if you wanted that, you'd use std::seed_seq itself). Instead, generate() fills with pure random data. Change-Id: Icd0e0d4b27cb4e5eb892fffd14b4e3ba9ea04da8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-074-12/+50
|\| | | | | | | | | | | | | Conflicts: src/widgets/widgets/qmenu.cpp Change-Id: I6d3baf56eb24501cddb129a3cb6b958ccc25a308
| * Work around uname(2) on Apple mobile OSes not returning the proper archThiago Macieira2017-06-051-0/+20
| | | | | | | | | | | | Task-number: QTBUG-61205 Change-Id: Ia3e896da908f42939148fffd14c46fc991650f6f Reviewed-by: Jake Petroules <jake.petroules@qt.io>
| * define QT_NO_EXCEPTIONS reliably when using ClangR.J.V. Bertin2017-06-032-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang's definition of the __EXCEPTIONS macro is inconsistent across platforms. When compiling for Darwin, Clang 3.6 and newer will set the token when exceptions are enabled in either C++ or ObjC. This change adds the reliable check described in the Clang 3.6 release notes to ensure that QT_NO_EXCEPTIONS is defined when required. The check requires the use of the Clang-specific __has_feature() syntax for which a new proxy macro QT_HAS_FEATURE(x) is added in qcompilerdetection.h Task-number: QTBUG-61034 Change-Id: Ie7b482dfa1a4a5b700a6b97562c26b626be1fc04 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * qEnvironmentVariableIntValue: fix the case of a non-numeric valueThiago Macieira2017-06-011-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation says that it's equivalent to qgetenv(varName).toInt() But the implementation wasn't. QByteArray::toInt() verifies that the entire string was consumed, so QByteArray("1a").toInt() == 0, but qstrtoll alone doesn't. That is, qstrtoll("1a", ...) == 1. The implementation also detected the base, a behavior I kept. Instead, I updated the documentation. Change-Id: I0031aa609e714ae983c3fffd14676ea6061a9268 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>