diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> | 2013-08-02 16:12:40 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-06 11:40:38 +0200 |
commit | 608a9c12ae342d7093e949f0153c407f5817e2d8 (patch) | |
tree | 915715ac3c7e3650332a21cc57387ad8d031c48f | |
parent | 1ff8ed1bf5c8f0fe0f0c2e7a5ab62ae539f8c97e (diff) |
Enable qsrand() on builds without thread-safe posix
The #ifdef clause in qsrand() needs to be the same as in
qrand(). Otherwise, we will store the seed in thread-local
storage in qsrand(), never passing it into srand(), and then
we'll use regular rand() because the rand_r() function
is missing, thus always using a random seed of 1 in all
applications.
Task-number: QTBUG-32781
Change-Id: I00240a1954ae746b87b031f3a0470a6cbe747571
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/global/qglobal.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index bcd0d06777..85cb698afc 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2322,7 +2322,7 @@ Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value */ void qsrand(uint seed) { -#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) +#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0) SeedStorage *seedStorage = randTLS(); if (seedStorage) { SeedStorageType *pseed = seedStorage->localData(); |