diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-11-04 15:51:37 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-11-09 14:40:33 +0000 |
commit | 3439657b02869299685d259c3a77aa38714565b7 (patch) | |
tree | 1dab70303e55e7101cdb6bde499de3239cda0cfc /libstdc++-v3/configure | |
parent | 8d2d0a6c4391e462555db6d33b2cc00f3da0932f (diff) | |
download | gcc-3439657b02869299685d259c3a77aa38714565b7.zip gcc-3439657b02869299685d259c3a77aa38714565b7.tar.gz gcc-3439657b02869299685d259c3a77aa38714565b7.tar.bz2 |
libstdc++: Support getentropy and arc4random in std::random_device
This adds additional "getentropy" and "arc4random" tokens to
std::random_device. The former is supported on Glibc and OpenBSD (and
apparently wasm), and the latter is supported on various BSDs.
libstdc++-v3/ChangeLog:
* acinclude.m4 (GLIBCXX_CHECK_GETENTROPY, GLIBCXX_CHECK_ARC4RANDOM):
Define.
* configure.ac (GLIBCXX_CHECK_GETENTROPY, GLIBCXX_CHECK_ARC4RANDOM):
Use them.
* config.h.in: Regenerate.
* configure: Regenerate.
* src/c++11/random.cc (random_device): Add getentropy and
arc4random as sources.
* testsuite/26_numerics/random/random_device/cons/token.cc:
Check new tokens.
* testsuite/26_numerics/random/random_device/entropy.cc:
Likewise.
Diffstat (limited to 'libstdc++-v3/configure')
-rwxr-xr-x | libstdc++-v3/configure | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index c1aea82..2137103 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -75429,6 +75429,109 @@ $as_echo "#define _GLIBCXX_X86_RDSEED 1" >>confdefs.h $as_echo "$ac_cv_x86_rdseed" >&6; } +# Check for other random number APIs + + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getentropy" >&5 +$as_echo_n "checking for getentropy... " >&6; } + if ${glibcxx_cv_getentropy+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <unistd.h> +int +main () +{ +unsigned i; + ::getentropy(&i, sizeof(i)); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + glibcxx_cv_getentropy=yes +else + glibcxx_cv_getentropy=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi + + + if test $glibcxx_cv_getentropy = yes; then + +$as_echo "#define HAVE_GETENTROPY 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_getentropy" >&5 +$as_echo "$glibcxx_cv_getentropy" >&6; } + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for arc4random" >&5 +$as_echo_n "checking for arc4random... " >&6; } + if ${glibcxx_cv_arc4random+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> +int +main () +{ +unsigned i = ::arc4random(); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + glibcxx_cv_arc4random=yes +else + glibcxx_cv_arc4random=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi + + + if test $glibcxx_cv_arc4random = yes; then + +$as_echo "#define HAVE_ARC4RANDOM 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_arc4random" >&5 +$as_echo "$glibcxx_cv_arc4random" >&6; } + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + # This depends on GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE. # Do checks for resource limit functions. |