diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-10-11 13:25:44 +0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-10-16 16:25:34 +0000 |
commit | 65eed6d5978738b06e047c9bd5d162b2596759f7 (patch) | |
tree | 283d7edafd13bacb209f486b6021facffbd57f3b /src/corelib/global/qrandom.cpp | |
parent | a090076e93487f8e461d9b866b9da1c0c21cb59b (diff) |
configure: make C++11 <random> a required functionality
Error out if it's missing or broken (Mersenne Twister not present).
This ensures that we never have a low-quality random generator in Qt.
Change-Id: I0a103569c81b4711a649fffd14ec80649df7087e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/global/qrandom.cpp')
-rw-r--r-- | src/corelib/global/qrandom.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index bafc312b3e..a7696719d1 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -46,16 +46,15 @@ #include <qthreadstorage.h> #include <private/qsimd_p.h> +#include <random> + #include <errno.h> #if QT_CONFIG(getentropy) # include <sys/random.h> -#else -# if QT_CONFIG(cxx11_random) -# include <random> -# include "qdeadlinetimer.h" -# include "qhashfunctions.h" -# endif +#elif !defined(Q_OS_BSD4) && !defined(Q_OS_WIN) +# include "qdeadlinetimer.h" +# include "qhashfunctions.h" # if QT_CONFIG(getauxval) # include <sys/auxv.h> @@ -258,7 +257,7 @@ static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW // BSDs have arc4random(4) and these work even in chroot(2) arc4random_buf(ptr, left * sizeof(*ptr)); } -#elif QT_CONFIG(cxx11_random) +#else static QBasicAtomicInteger<unsigned> seed = Q_BASIC_ATOMIC_INITIALIZER(0U); static void fallback_update_seed(unsigned value) { @@ -343,12 +342,6 @@ static void fallback_fill(quint32 *ptr, qssize_t left) Q_DECL_NOTHROW fallback_update_seed(*ptr); } -#else -static void fallback_update_seed(unsigned) {} -static Q_NORETURN void fallback_fill(quint32 *, qssize_t) -{ - qFatal("Random number generator failed and no high-quality backup available"); -} #endif static qssize_t fill_cpu(quint32 *buffer, qssize_t count) Q_DECL_NOTHROW |