aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2020-05-19 16:49:21 +0100
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:03:50 -0300
commitdfc5e65ca1e9610a2572683002cf2828500dac4f (patch)
treebcbe78e08bf216ad20d249202e1f7ec7bc5b5539 /gcc
parent7b88f294880848dd4813324e68948a688c9fd971 (diff)
downloadgcc-dfc5e65ca1e9610a2572683002cf2828500dac4f.zip
gcc-dfc5e65ca1e9610a2572683002cf2828500dac4f.tar.gz
gcc-dfc5e65ca1e9610a2572683002cf2828500dac4f.tar.bz2
libstdc++: Use RDRAND as fallback if RDSEED keeps failing (PR 94087)
It's not difficult for multiple threads to drain the entropy available to the RDSEED instruction, at which point we throw an exception. This change will try to use RDRAND after RDSEED fails repeatedly, and only throw if RDRAND also fails repeatedly. This doesn't guarantee a random value can always be read, but reduces the likelihood of failure when using the RDSEED instruction. PR libstdc++/94087 * src/c++11/random.cc (__x86_rdseed): Allow fallback function to be passed in. (__x86_rdseed_rdrand): New function that uses rdseed with rdrand fallback. (random_device::_M_init): Use __x86_rdseed_rdrand when both instructions are available. * testsuite/26_numerics/random/random_device/94087.cc: New test.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions