diff options
author | axis <qt-info@nokia.com> | 2009-12-18 10:32:06 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-12-18 10:32:06 (GMT) |
commit | 2fb8ea9aa787d59ac16250eade0adfea08f1ca9d (patch) | |
tree | c274575bb148c9755a901094fc94d4553a84653c /src/corelib/global/qglobal.cpp | |
parent | ab8508380d6e5875ed871196eb09642380ac1aef (diff) | |
parent | bf819a04b0c60c64912f72b613c1546d8be7dc50 (diff) | |
download | Qt-2fb8ea9aa787d59ac16250eade0adfea08f1ca9d.zip Qt-2fb8ea9aa787d59ac16250eade0adfea08f1ca9d.tar.gz Qt-2fb8ea9aa787d59ac16250eade0adfea08f1ca9d.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Conflicts:
configure
src/gui/text/qfontdatabase_s60.cpp
Diffstat (limited to 'src/corelib/global/qglobal.cpp')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index f630f96..d39e3b7 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -82,6 +82,7 @@ #include <e32def.h> #include <e32debug.h> #include <f32file.h> +#include <e32math.h> # include "private/qcore_symbian_p.h" _LIT(qt_S60Filter, "Series60v?.*.sis"); @@ -2498,7 +2499,7 @@ bool qputenv(const char *varName, const QByteArray& value) #endif } -#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) +#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) # if defined(Q_OS_INTEGRITY) && defined(__GHS_VERSION_NUMBER) && (__GHS_VERSION_NUMBER < 500) // older versions of INTEGRITY used a long instead of a uint for the seed. @@ -2521,8 +2522,6 @@ Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value Sets the argument \a seed to be used to generate a new random number sequence of pseudo random integers to be returned by qrand(). - If no seed value is provided, qrand() is automatically seeded with a value of 1. - The sequence of random numbers generated is deterministic per thread. For example, if two threads call qsrand(1) and subsequently calls qrand(), the threads will get the same random number sequence. @@ -2546,8 +2545,9 @@ void qsrand(uint seed) srand(seed); } #else - // On Windows srand() and rand() already use Thread-Local-Storage + // On Windows and Symbian srand() and rand() already use Thread-Local-Storage // to store the seed between calls + // this is also valid for QT_NO_THREAD srand(seed); #endif } @@ -2563,7 +2563,7 @@ void qsrand(uint seed) */ void qsrand() { -#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) +#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) SeedStorage *seedStorage = randTLS(); if (seedStorage) { SeedStorageType *pseed = seedStorage->localData(); @@ -2577,24 +2577,28 @@ void qsrand() *pseed = QDateTime::currentDateTime().toTime_t() + quintptr(&pseed) + serial.fetchAndAddRelaxed(1); -#if defined(Q_OS_WIN) - // for Windows the srand function must still be called. +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + // for Windows and Symbian the srand function must still be called. srand(*pseed); #endif } -#elif defined(Q_OS_WIN) +//QT_NO_THREAD implementations +#else static unsigned int seed = 0; if (seed) return; +#if defined(Q_OS_SYMBIAN) + seed = Math::Random(); +#elif defined(Q_OS_WIN) seed = GetTickCount(); - srand(seed); #else - // Symbian? - -#endif // defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) + seed = quintptr(&seed) + QDateTime::currentDateTime().toTime_t(); +#endif + srand(seed); +#endif // defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) } /*! @@ -2631,8 +2635,9 @@ int qrand() return rand(); } #else - // On Windows srand() and rand() already use Thread-Local-Storage + // On Windows and Symbian srand() and rand() already use Thread-Local-Storage // to store the seed between calls + // this is also valid for QT_NO_THREAD return rand(); #endif } |