a2d196e75c
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. |
||
---|---|---|
.. | ||
accumulate | ||
adjacent_difference | ||
bit | ||
complex | ||
endian | ||
exclusive_scan | ||
gcd | ||
headers | ||
inclusive_scan | ||
inner_product | ||
iota | ||
lcm | ||
midpoint | ||
numbers | ||
partial_sum | ||
pstl/numeric_ops | ||
random | ||
reduce | ||
slice | ||
slice_array | ||
transform_exclusive_scan | ||
transform_inclusive_scan | ||
transform_reduce | ||
valarray | ||
lerp.cc |