Add support for additional sources of randomness to std::random_device, to allow using RDSEED for Intel CPUs and rand_s for Windows. When supported these can be selected using the tokens "rdseed" and "rand_s". For *-w64-mingw32 targets the "default" token will now use rand_s, and for other i?86-*-* and x86_64-*-* targets it will try to use "rdseed" first, then "rdrand", and finally "/dev/urandom". To simplify the declaration of std::random_device in <bits/random.h> the constructors now unconditionally call _M_init instead of _M_init_pretr1, and the function call operator now unconditionally calls _M_getval. The library code now decides whether _M_init and _M_getval should use a real source of randomness or the mt19937 engine. Existing code compiled against old libstdc++ headers will still call _M_init_pretr1 and _M_getval_pretr1, but those functions now forward to _M_init and _M_getval if a real source of randomness is available. This means existing code compiled for mingw-w64 will start to use rand_s just by linking to a new libstdc++.dll. * acinclude.m4 (GLIBCXX_CHECK_X86_RDSEED): Define macro to check if the assembler supports rdseed. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Use GLIBCXX_CHECK_X86_RDSEED. * config/os/mingw32-w64/os_defines.h (_GLIBCXX_USE_CRT_RAND_S): Define. * doc/html/*: Regenerate. * doc/xml/manual/status_cxx2011.xml: Document new tokens. * include/bits/random.h (random_device::random_device()): Always call _M_init rather than _M_init_pretr1. (random_device::random_device(const string&)): Likewise. (random_device::operator()()): Always call _M_getval(). (random_device::_M_file): Replace first member of union with an anonymous struct, with _M_file as its first member. * src/c++11/random.cc [_GLIBCXX_X86_RDRAND] (USE_RDRAND): Define. [_GLIBCXX_X86_RDSEED] (USE_RDSEED): Define. (USE_MT19937): Define if none of the above are defined. (USE_POSIX_FILE_IO): Define. (_M_strtoul): Remove. [USE_RDSEED] (__x86_rdseed): Define new function. [_GLIBCXX_USE_CRT_RAND_S] (__winxp_rand_s): Define new function. (random_device::_M_init(const string&)): Initialize new union members. Add support for "rdseed" and "rand_s" tokens. Decide what the "default" token does according to which USE_* macros are defined. [USE_POSIX_FILE_IO]: Store a file descriptor. [USE_MT19937]: Forward to _M_init_pretr1 instead. (random_device::_M_init_pretr1(const string&)) [USE_MT19937]: Inline code from _M_strtoul. [!USE_MT19937]: Call _M_init, transforming the old default token or numeric tokens to "default". (random_device::_M_fini()) [USE_POSIX_FILE_IO]: Use close not fclose. (random_device::_M_getval()): Use new union members to obtain a random number from the stored function pointer or file descriptor. [USE_MT19937]: Obtain a value from the mt19937 engine. (random_device::_M_getval_pretr1()): Call _M_getval(). (random_device::_M_getentropy()) [USE_POSIX_FILE_IO]: Use _M_fd instead of fileno. [!USE_MT19937] (mersenne_twister): Do not instantiate when not needed. * testsuite/26_numerics/random/random_device/85494.cc: New test. From-SVN: r271740
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
abi.html | Loading commit data... | |
algorithms.html | Loading commit data... | |
api.html | Loading commit data... | |
appendix.html | Loading commit data... | |
appendix_contributing.html | Loading commit data... | |
appendix_free.html | Loading commit data... | |
appendix_gfdl.html | Loading commit data... | |
appendix_gpl.html | Loading commit data... | |
appendix_porting.html | Loading commit data... | |
associative.html | Loading commit data... | |
atomics.html | Loading commit data... | |
backwards.html | Loading commit data... | |
bitmap_allocator.html | Loading commit data... | |
bitmap_allocator_impl.html | Loading commit data... | |
bugs.html | Loading commit data... | |
concept_checking.html | Loading commit data... | |
concurrency.html | Loading commit data... | |
configure.html | Loading commit data... | |
containers.html | Loading commit data... | |
containers_and_c.html | Loading commit data... | |
debug.html | Loading commit data... | |
debug_mode.html | Loading commit data... | |
debug_mode_design.html | Loading commit data... | |
debug_mode_semantics.html | Loading commit data... | |
debug_mode_using.html | Loading commit data... | |
diagnostics.html | Loading commit data... | |
documentation_hacking.html | Loading commit data... | |
dynamic_memory.html | Loading commit data... | |
errno.html | Loading commit data... | |
ext_algorithms.html | Loading commit data... | |
ext_compile_checks.html | Loading commit data... | |
ext_concurrency.html | Loading commit data... | |
ext_concurrency_impl.html | Loading commit data... | |
ext_concurrency_use.html | Loading commit data... | |
ext_containers.html | Loading commit data... | |
ext_demangling.html | Loading commit data... | |
ext_io.html | Loading commit data... | |
ext_iterators.html | Loading commit data... | |
ext_numerics.html | Loading commit data... | |
ext_preface.html | Loading commit data... | |
ext_sgi.html | Loading commit data... | |
ext_utilities.html | Loading commit data... | |
extensions.html | Loading commit data... | |
facets.html | Loading commit data... | |
fstreams.html | Loading commit data... | |
generalized_numeric_operations.html | Loading commit data... | |
index.html | Loading commit data... | |
internals.html | Loading commit data... | |
intro.html | Loading commit data... | |
io.html | Loading commit data... | |
io_and_c.html | Loading commit data... | |
iterators.html | Loading commit data... | |
license.html | Loading commit data... | |
localization.html | Loading commit data... | |
make.html | Loading commit data... | |
memory.html | Loading commit data... | |
mt_allocator.html | Loading commit data... | |
mt_allocator_design.html | Loading commit data... | |
mt_allocator_ex_multi.html | Loading commit data... | |
mt_allocator_ex_single.html | Loading commit data... | |
mt_allocator_impl.html | Loading commit data... | |
numerics.html | Loading commit data... | |
numerics_and_c.html | Loading commit data... | |
pairs.html | Loading commit data... | |
parallel_mode.html | Loading commit data... | |
parallel_mode_design.html | Loading commit data... | |
parallel_mode_semantics.html | Loading commit data... | |
parallel_mode_test.html | Loading commit data... | |
parallel_mode_using.html | Loading commit data... | |
policy_based_data_structures_test.html | Loading commit data... | |
policy_data_structures.html | Loading commit data... | |
policy_data_structures_ack.html | Loading commit data... | |
policy_data_structures_design.html | Loading commit data... | |
policy_data_structures_using.html | Loading commit data... | |
profile_mode.html | Loading commit data... | |
profile_mode_api.html | Loading commit data... | |
profile_mode_cost_model.html | Loading commit data... | |
profile_mode_design.html | Loading commit data... | |
profile_mode_devel.html | Loading commit data... | |
profile_mode_diagnostics.html | Loading commit data... | |
profile_mode_impl.html | Loading commit data... | |
setup.html | Loading commit data... | |
source_code_style.html | Loading commit data... | |
source_design_notes.html | Loading commit data... | |
source_organization.html | Loading commit data... | |
status.html | Loading commit data... | |
std_contents.html | Loading commit data... | |
streambufs.html | Loading commit data... | |
strings.html | Loading commit data... | |
stringstreams.html | Loading commit data... | |
support.html | Loading commit data... | |
termination.html | Loading commit data... | |
test.html | Loading commit data... | |
traits.html | Loading commit data... | |
unordered_associative.html | Loading commit data... | |
using.html | Loading commit data... | |
using_concurrency.html | Loading commit data... | |
using_dual_abi.html | Loading commit data... | |
using_dynamic_or_shared.html | Loading commit data... | |
using_exceptions.html | Loading commit data... | |
using_headers.html | Loading commit data... | |
using_macros.html | Loading commit data... | |
using_namespaces.html | Loading commit data... | |
utilities.html | Loading commit data... |