summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-10-21 11:24:54 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-11-20 15:49:36 +0000
commit3c7a6a7a581f9ea6f05a22a912d660c5402a1fa8 (patch)
tree2dfc0d1c7ecc59fab766a972c8aa694b2ba3a3d5 /src/corelib/global
parentbb3872d60975724a50ff910b6dd108d1944db597 (diff)
QRandomGenerator: Enforce the use of 32-bit integers in the engine
std::mt19937 is defined as operating on uint_fast32_t, which is usually just a 32-bit integer. That's not the case on 64-bit Linux, where it is actually 64-bit wide, meaning sizeof(std::mt19937) jumps from 2504 to 5000 bytes, with exactly 50% of it filled with zeroes. The seed() function also needs a large zero-extending loop. Change-Id: Icaa86fc7b54d4b368c0efffd14efa911e2a40b44 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qrandom.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h
index bde64646a4..005de0941f 100644
--- a/src/corelib/global/qrandom.h
+++ b/src/corelib/global/qrandom.h
@@ -177,7 +177,8 @@ private:
friend class QRandomGenerator64;
struct SystemGenerator;
struct SystemAndGlobalGenerators;
- typedef std::mt19937 RandomEngine;
+ using RandomEngine = std::mersenne_twister_engine<quint32,
+ 32,624,397,31,0x9908b0df,11,0xffffffff,7,0x9d2c5680,15,0xefc60000,18,1812433253>;
union Storage {
uint dummy;