diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-09-09 09:30:43 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-09-09 07:51:49 +0000 |
commit | 1d53b6d9f2d7d0427ff56cfa50d98ac97f99c1bc (patch) | |
tree | d270812c4b648f51090e1262972846b1b4de8116 /src/corelib/global/qrandom.cpp | |
parent | 89d0a03c067b42155b1a2d310f8514f595abfd61 (diff) | |
parent | 5cea83a8a2fc3384bb07a7265c8d907171cb1ea4 (diff) |
Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
Change-Id: Idd3ca5cb9a2b95a4c3513b2a4c8966e6f56193f1
Diffstat (limited to 'src/corelib/global/qrandom.cpp')
-rw-r--r-- | src/corelib/global/qrandom.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 711eb8f4d5..e5b2399566 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 Intel Corporation. +** Copyright (C) 2019 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -103,17 +103,22 @@ static QT_FUNCTION_TARGET(RDRND) qsizetype qt_random_cpu(void *buffer, qsizetype { unsigned *ptr = reinterpret_cast<unsigned *>(buffer); unsigned *end = ptr + count; + int retries = 10; while (ptr + sizeof(qregisteruint)/sizeof(*ptr) <= end) { - if (_rdrandXX_step(reinterpret_cast<qregisteruint *>(ptr)) == 0) + if (_rdrandXX_step(reinterpret_cast<qregisteruint *>(ptr))) + ptr += sizeof(qregisteruint)/sizeof(*ptr); + else if (--retries == 0) goto out; - ptr += sizeof(qregisteruint)/sizeof(*ptr); } - if (sizeof(*ptr) != sizeof(qregisteruint) && ptr != end) { - if (_rdrand32_step(ptr)) - goto out; - ++ptr; + while (sizeof(*ptr) != sizeof(qregisteruint) && ptr != end) { + bool ok = _rdrand32_step(ptr); + if (!ok && --retries) + continue; + if (ok) + ++ptr; + break; } out: |