From: Jonathan Wakely Date: Wed, 4 Jul 2018 16:56:21 +0000 (+0100) Subject: Define "random_device" effective target X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=89bc4ab198a0be9e5b2d493f9b25f7ea3df336ef;p=gcc.git Define "random_device" effective target Currently only matches targets where _GLIBCXX_USE_RANDOM_TR1 is defined, which means /dev/random and /dev/urandom are usable. * testsuite/25_algorithms/make_heap/complexity.cc: Require effective target for std::random_device. * testsuite/26_numerics/random/random_device/cons/default.cc: Likewise. * testsuite/experimental/algorithm/sample-2.cc: Likewise. * testsuite/experimental/algorithm/shuffle.cc: Likewise. * testsuite/experimental/random/randint.cc: Likewise. * testsuite/lib/libstdc++.exp (check_effective_target_random_device): New proc. From-SVN: r262415 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b1747e82cb8..24acd68751b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2018-07-04 Jonathan Wakely + + * testsuite/25_algorithms/make_heap/complexity.cc: Require effective + target for std::random_device. + * testsuite/26_numerics/random/random_device/cons/default.cc: + Likewise. + * testsuite/experimental/algorithm/sample-2.cc: Likewise. + * testsuite/experimental/algorithm/shuffle.cc: Likewise. + * testsuite/experimental/random/randint.cc: Likewise. + * testsuite/lib/libstdc++.exp + (check_effective_target_random_device): New proc. + 2018-07-04 Jonathan Wakely Jakub Jelinek diff --git a/libstdc++-v3/testsuite/25_algorithms/make_heap/complexity.cc b/libstdc++-v3/testsuite/25_algorithms/make_heap/complexity.cc index cca48f61e0a..069d2d0433d 100644 --- a/libstdc++-v3/testsuite/25_algorithms/make_heap/complexity.cc +++ b/libstdc++-v3/testsuite/25_algorithms/make_heap/complexity.cc @@ -16,6 +16,7 @@ // . // { dg-do run { target c++11 } } +// { dg-require-effective-target random_device } #include #include diff --git a/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/default.cc index 38210963f7e..5a34526a5f7 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/default.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/default.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++11 } } +// { dg-require-effective-target random_device } // { dg-require-cstdint "" } // // 2008-11-24 Edward M. Smith-Rowland <3dw4rd@verizon.net> diff --git a/libstdc++-v3/testsuite/experimental/algorithm/sample-2.cc b/libstdc++-v3/testsuite/experimental/algorithm/sample-2.cc index 541d17e08a0..ef3f7daa14c 100644 --- a/libstdc++-v3/testsuite/experimental/algorithm/sample-2.cc +++ b/libstdc++-v3/testsuite/experimental/algorithm/sample-2.cc @@ -16,6 +16,7 @@ // . // { dg-do run { target c++14 } } +// { dg-require-effective-target random_device } // { dg-require-effective-target tls_runtime } // { dg-add-options tls } diff --git a/libstdc++-v3/testsuite/experimental/algorithm/shuffle.cc b/libstdc++-v3/testsuite/experimental/algorithm/shuffle.cc index ee06fbd996a..db958f600d4 100644 --- a/libstdc++-v3/testsuite/experimental/algorithm/shuffle.cc +++ b/libstdc++-v3/testsuite/experimental/algorithm/shuffle.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++14 } } +// { dg-require-effective-target random_device } // { dg-require-effective-target tls_runtime } // { dg-add-options tls } diff --git a/libstdc++-v3/testsuite/experimental/random/randint.cc b/libstdc++-v3/testsuite/experimental/random/randint.cc index e80bd858f29..90ba72ac2fc 100644 --- a/libstdc++-v3/testsuite/experimental/random/randint.cc +++ b/libstdc++-v3/testsuite/experimental/random/randint.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++14 } } +// { dg-require-effective-target random_device } // { dg-require-effective-target tls_runtime } // { dg-add-options tls } diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 7af3266f855..d8717e402df 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -2061,6 +2061,34 @@ proc check_effective_target_cxx11-abi { } { return 0 } +# Return 1 if std::random_device should be usable using the current flags, 0 otherwise. +proc check_effective_target_random_device { } { + global cxxflags + + # Set up and preprocess a C++ test program that depends + # on std::random_device being usable. + set src random_device[pid].cc + + set f [open $src "w"] + puts $f "#include " + puts $f "#if ! _GLIBCXX_USE_RANDOM_TR1" + puts $f "# error No working std::random_device available" + puts $f "#endif" + close $f + + set lines [v3_target_compile $src /dev/null preprocess ""] + file delete $src + + if [string match "" $lines] { + # No error message, preprocessing succeeded. + verbose "check_v3_random_device: `1'" 2 + return 1 + } + + verbose "check_v3_random_device: `0'" 2 + return 0 +} + set additional_prunes "" if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \