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>
This commit is contained in:
parent
1ff8ed1bf5
commit
608a9c12ae
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user