From 608a9c12ae342d7093e949f0153c407f5817e2d8 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 2 Aug 2013 16:12:40 +0200 Subject: [PATCH] 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 --- src/corelib/global/qglobal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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();