diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2010-07-13 10:23:05 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2010-07-18 03:30:13 (GMT) |
commit | fad58a22089a381f97bfaaa192ad3cf651e52d94 (patch) | |
tree | bde007ae1f17677d4e1f56c5a4638f690ae84cc6 /src | |
parent | d8944b560a16db3805d6faadfaadbabe750c0cef (diff) | |
download | Qt-fad58a22089a381f97bfaaa192ad3cf651e52d94.zip Qt-fad58a22089a381f97bfaaa192ad3cf651e52d94.tar.gz Qt-fad58a22089a381f97bfaaa192ad3cf651e52d94.tar.bz2 |
Compile when bootstrapping qmake
QThreadStorage is not available when bootstrapping qmake, so fall back
to a simple static bool instead.
Reviewed-by: TrustMe
(cherry picked from commit a736d333aab9e2e97fdbb738b3f3f4646afe192e)
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/plugin/quuid.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 7858b33..0d14b9b 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -604,11 +604,13 @@ QUuid QUuid::createUuid() randbits = r; } + // Seed the PRNG once per thread with a combination of current time, a + // stack address and a serial counter (since thread stack addresses are + // re-used). +#ifndef QT_BOOTSTRAPPED static QThreadStorage<int *> uuidseed; - if (!uuidseed.hasLocalData()) { - // Seed the PRNG once per thread with a combination of current time, a - // stack address and a serial counter (since thread stack addresses are - // re-used). + if (!uuidseed.hasLocalData()) + { int *pseed = new int; static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2); qsrand(*pseed = QDateTime::currentDateTime().toTime_t() @@ -616,6 +618,12 @@ QUuid QUuid::createUuid() + serial.fetchAndAddRelaxed(1)); uuidseed.setLocalData(pseed); } +#else + static bool seeded = false; + if (!seeded) + qsrand(QDateTime::currentDateTime().toTime_t() + + quintptr(&seeded)); +#endif int chunks = 16 / sizeof(uint); while (chunks--) { |