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>
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>
Backtrace logging tests were not passing for arm when -O2 option was used.
Set "-fno-inline" on for the app whose backtrace is to be inspected.
Task-number: QTBUG-59966
Change-Id: Id1bbf78c31dc524357a30c7d39c239689621b155
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
The operator double() and operator long double() members of qfloat16
are causing cast ambiguities. This removes them, leaving only
operator float() which seems to be adequate.
Also, additional arithmetic operator tests were added which without
this removal fail to compile.
Change-Id: Id52a101b318fd754969b3de13c1e528d0aac2387
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
I don't know why.
tst_qflags.cpp(114): error: no instance of function template "verifyConstExpr" matches the argument list argument types are: (Qt::MouseButton)
tst_qflags.cpp(91): note: this candidate was rejected because there is a type mismatch after argument substitution
Change-Id: I84e363d735b443cb9beefffd14b9581d77933cb8
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
Backtrace logging tests were not passing for arm. Added compile option
-funwind-tables to support backtrace on arm.
Task-number: QTBUG-59966
Change-Id: I5e2443b1e3a644a239dab68db990e75ae8fade24
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Replace all QT_NO_PROCESS with QT_CONFIG(process), define it in
qconfig-bootstrapped.h, add QT_REQUIRE_CONFIG(process) to the qprocess
headers, exclude the sources from compilation when switched off, guard
header inclusions in places where compilation without QProcess seems
supported, drop some unused includes, and fix some tests that were
apparently designed to work with QT_NO_PROCESS but failed to.
Change-Id: Ieceea2504dea6fdf43b81c7c6b65c547b01b9714
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
This constitutes a fairly complete submission of an entirely new
floating point type which conforms to IEEE 754 as a 16-bit storage
class. Conversion between qfloat16 and float is currently performed
through a sequence of lookup tables. Global-level functions
qRound(), qRound64(), qFuzzyCompare(), qFuzzyIsNull(), and
qIsNull() each with a qfloat16 parameter have been included
for completeness.
[ChangeLog][QtCore] Added new qfloat16 class.
Change-Id: Ia52eb27846965c14f8140c00faf5ba33c9443976
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
So that QFlags can use an (un)signed int matching the
underlying type as identified by the compiler and not by us.
Requires fixing a few warnings about sign conversion due to
QFlags misusages in qtbase that were either plain wrong, or
were relying on the enum being backed by an (un)signed int
when it wasn't.
Keep qtypetraits.h in the source tree in order to prevent
source breaks if some downstream #includes it (note however
that it did not contain any public API).
Change-Id: Ib3a92b98db7031e793a088fb2a3b306eff4d7a3c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This new function does the same as newRow(), except that it has a less confusing
name (in line with _add_Column()), and accepts printf-style arguments to avoid
the need to newRow(qPrintable(QString::asprintf())), a common pattern in client
code. It uses qvsnprintf() under the hoods, avoiding the need for the QString
const char* round-trip.
Port all in-tree users of newRow(qPrintable(QString::asnprintf())) to the new
function.
Change-Id: Icd5de9b7ea4f6759d98080ec30f5aecadb8bec39
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Namely: decltype(). Ideally we'd want C++17's template constructor
argument deduction, but instead use the C++11 solution: a factory
function. This enables using things such as lambdas in the container
argument.
Change-Id: Idba64d8069d15bbafe54cfdebe24b1fba1eb8d0a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Chaining hooks together was mentioned by Ossi in the comments of
d953d9a4. This patch justs add a test that verifies that it works, and
also serves as an informal example for developers looking how to do it.
Change-Id: I53a014d5663c289ea0559e0926ed301f4e5110e6
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Any other use than for enums should use std::is_[un]signed. Make this
explicit by renaming the type traits.
Change-Id: I494158563c95c710e710d0d337f4e547006df171
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Since the macro is now just a wrapper for std::is_enum,
its use is also deprecated.
[ChangeLog][QtCore][Global] Q_IS_ENUM is deprecated.
Use std::is_enum<>::value instead.
Change-Id: I09b9f4559c02c81f338cace927873318f2acafde
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Remove most type traits from qtypetraits.h, but keep the custom
implementation of is_signed/is_unsigned. This gets rid of
BSD-3 licensed code from Google in a public header (hugh!).
The custom implementations for is_signed/is_unsigned are kept
because the implementations in gcc's standard headers do not
work as we expect for enums - both is_signed and is_unsigned
always returns false there - see also
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59027
[ChangeLog][QtCore][General] Qt now relies on type traits from
the C++ standard library.
Change-Id: I3f2188b46949f04ca4482a6ac9afd3482103f0e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Consistent with other Unix platforms, and internally consistent between tests,
as a lot of tests were already applying CONFIG -= app_bundle manually.
Change-Id: Icd2b7e1c08015b26137af60ff82fddbc753f0ff4
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Use the new qtConfig macro in all pro/pri files.
This required adding some feature entries, and adding
{private,public}Feature to every referenced already existing entry.
Change-Id: I164214dad1154df6ad84e86d99ed14994ef97cf4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
- port Q_FOREACH to C++11 range-for
(except in the Q_FOREACH tests :)
- port uses of inefficient QLists to QVector
- include QTest, not QtTest
Fixes some errors pointed out by my tree's static checks.
Change-Id: Ibb21a280537af74dda5679ec7c75d59477b6de55
Reviewed-by: David Faure <david.faure@kdab.com>
Update files using old header.LGPL3 to header.LGPL
Update files using old FDL template to use new one
Update files using old BSD template to use new one
Change-Id: I36a78272516f9953d02956522f285b40adfc8915
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
The previous implementation overwrote multiple 'time' parts in the
qSetMessagePattern with the last setting in the pattern line.
%{time}%{time process}%{time boot} ended up to be output as if
%{time boot}%{time boot}%{time boot} was set.
This fix keeps the arguments of each individual 'time' part.
The same holds for multiple 'backtrace' parts. The previouse
implementation overwrote multiple 'backtrace' arguments with the
arguments of the last occurrence.
This fix keeps the individual arguments for the 'process' parts.
The individual arguments are applied in qFormatLogMessage.
A new test to verify the individual 'time' arguments application
is added, too.
Task-number: QTBUG-51944
Change-Id: Ib757614a482c5f31ed0a61b550daa2eea4b907b4
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This makes implementing class methods that enable or disable a feature
stored in a QFlags<> member easier.
[ChangeLog][QtCore][QFlags] Added setFlag method to set or unset a flag
Task-number: QTBUG-27100
Change-Id: Ic602abbbf3100df78f21b7918573744d1bbd18c1
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
I wrote a script to help find the files, but I reviewed the
contributions manually to be sure I wasn't claiming copyright for search
& replace, adding Q_DECL_NOTHROW or adding "We mean it" headers.
Change-Id: I7a9e11d7b64a4cc78e24ffff142b506368fc8842
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some
exceptions, see
http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/
Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one
(in those files which will be under GPL 3 with exceptions)
Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
TEST_HELPER_INSTALLS cannot be used on platforms with no
QProcess support.
Change-Id: I2a6a283d94ca4487fc628449c53fc37140dd291d
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
Only add C++14 to the project configuration when C++14 support is
available on the platform. Adding it because the platform supports
C++11 doesn't work when the platform _only_ supports C++11 (e.g.,
QNX 6.6.0).
Task-number: QTBUG-49491
Change-Id: I15de38bb06d912a314b9dd18c80b513cc06a855e
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
In C++, signed overflow math is Undefined Behavior. However, many CPUs
do implement some way to check for overflow. Some compilers expose
intrinsics to use this functionality. If the no intrinsic is exposed,
overflow checking can be done by widening the result type and "manually"
checking for overflow. Or, for X86, by using inline assembly to use the
CPU features.
Used in QtQml.
Change-Id: I2ef2523ccaa98f6757a45e24862a2fa730a26bb0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The previous implementations did not check the full mantissa. The result
was that certain NaN values were seen as +/-Infinity.
A nice benefit is that the generated code for this implementation is also
faster.
Task-number: QTBUG-47692
Change-Id: I1507ec579ccd9a2ab97da8cf83dabbc5d6e28597
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Use character literals where applicable.
Change-Id: I1a026c320079ee5ca6f70be835d5a541deee2dd1
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
The code still produces Internal Compiler Errors in release mode.
Task-number: QTBUG-46344
Change-Id: I86d3608b13a197a0b65b83829d1512203e1578f8
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
Most processors have carry flags which they set on addition overflow, so
it's a good idea to access them whenever possible. Most of them also
have widening multiply instructions that can be used to detect overflow
of the non-widening version.
Tested to compile on:
Architecture Compiler
x86 GCC 4.9, GCC 5*, Clang 3.6*, ICC 16 beta
x86-64 GCC 4.9, GCC 5*, Clang 3.6*, ICC 16 beta
x86-64 ILP32 GCC 4.9, GCC 5*, Clang 3.6*
IA-64 LP64 GCC 4.8
ARMv7-A GCC 4.9, Clang 3.6*
AArch64 Clang 3.6*
MIPS GCC 4.9, Clang 3.6*
MIPS64 GCC 4.9, Clang 3.6*
PowerPC GCC 4.9, Clang 3.6*
PowerPC 64 GCC 4.9, Clang 3.6*
SPARC Clang 3.6*
SPARCv9 Clang 3.6*
[*] supports the intrinsics
If the compiler does not offer a way to detect an overflow, we do it by
hand. For unsigned additions, that's easy, since the C++ language
specifies the behavior of the overflow. That's also the reason why this
code is implemented only for unsigned integers.
For the multiplication, if the compiler does not support widening
multiplications, we do it with a division instead. This is necessary for
GCC < 4.5 and compilers not compatible with GCC or MSVC.
Change-Id: I049a653beeb5454c9539ffff13e637de0f1338c1
Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The keyword no longer has a meaning for the new CI.
Change-Id: Ibcea4c7a82fb7f982cf4569fdff19f82066543d1
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Qt Creator needs to be able to determine structure sizes and data
member offsets for certain private types even in the absence of debug
information.
It is sufficient to keep and test the actual data sets on the Qt Creator
side, as long library provides a hint which data set is needed.
So far, HookDataVersion was meant to be used for that purpose. To
make it more explicit, this patch introduce a TypeInformationVersion
field in qtHookData.
Change-Id: Ia1c3c6f62f314d63c4df289ef456f047c5e84cf4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
- Replace Q[TRY]_VERIFY(pointer == 0) by Q[TRY]_VERIFY(!pointer).
- Replace Q[TRY]_VERIFY(smartPointer == 0) by
Q[TRY]_VERIFY(smartPointer.isNull()).
- Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b) and
add casts where necessary. The values will then be logged
should a test fail.
Tests from corelib/tools were omitted in this change.
Change-Id: I4c8786d33fcf429d11b2b624c7cd89c28cadb518
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>