diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-10-19 12:31:06 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-10-19 17:27:06 +0100 |
commit | 58f339fc5eaae7db9526f81ab91f282ad4a9b8cc (patch) | |
tree | 3c6974aae38d7c6d988ac5625bc143db6147405d /gcc/rtl.c | |
parent | 3cfbe5dc08b574bccc398256946cc03e2a767329 (diff) | |
download | gcc-58f339fc5eaae7db9526f81ab91f282ad4a9b8cc.zip gcc-58f339fc5eaae7db9526f81ab91f282ad4a9b8cc.tar.gz gcc-58f339fc5eaae7db9526f81ab91f282ad4a9b8cc.tar.bz2 |
libstdc++: Implement std::random_device::entropy() for other sources
Currently this function only returns a non-zero value for /dev/random
and /dev/urandom. When a hardware instruction such as RDRAND is in use
it should (in theory) be perfectly random and produce 32 bits of entropy
in each 32-bit result. Add a helper function to identify the source of
randomness from the _M_func and _M_file data members, and return a
suitable value when RDRAND or RDSEED is being used.
libstdc++-v3/ChangeLog:
* src/c++11/random.cc (which_source): New helper function.
(random_device::_M_getentropy()): Use which_source and return
suitable values for sources other than device files.
* testsuite/26_numerics/random/random_device/entropy.cc: New test.
Diffstat (limited to 'gcc/rtl.c')
0 files changed, 0 insertions, 0 deletions