Use QtPrivate::FunctionPointer to get the type of srand's first arg
Avoids #ifdefs and guesswork. Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5210efaea7d00 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
030782e1a8
commit
7697227781
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include "qrandom.h"
|
#include "qrandom.h"
|
||||||
#include "qrandom_p.h"
|
#include "qrandom_p.h"
|
||||||
|
#include <qobjectdefs.h>
|
||||||
#include <qthreadstorage.h>
|
#include <qthreadstorage.h>
|
||||||
|
|
||||||
#if QT_HAS_INCLUDE(<random>)
|
#if QT_HAS_INCLUDE(<random>)
|
||||||
@ -730,13 +731,7 @@ void QRandomGenerator::fillRange_helper(void *buffer, void *bufferEnd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
|
#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0)
|
||||||
|
using SeedStorageType = QtPrivate::FunctionPointer<decltype(&srand)>::Arguments::Car;
|
||||||
# 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.
|
|
||||||
typedef long SeedStorageType;
|
|
||||||
# else
|
|
||||||
typedef uint SeedStorageType;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
typedef QThreadStorage<SeedStorageType *> SeedStorage;
|
typedef QThreadStorage<SeedStorageType *> SeedStorage;
|
||||||
Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value
|
Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user