aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-10-16 15:49:29 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2018-10-16 15:49:29 +0100
commit5ae2c32a8abcc154af73692f55f6b60fc77b08ae (patch)
tree1b49c6938582e78efc39822706e0c5af7bd1e484
parent630f2da9676a699dbd734799822d146861e76f71 (diff)
downloadgcc-5ae2c32a8abcc154af73692f55f6b60fc77b08ae.zip
gcc-5ae2c32a8abcc154af73692f55f6b60fc77b08ae.tar.gz
gcc-5ae2c32a8abcc154af73692f55f6b60fc77b08ae.tar.bz2
Define _GLIBCXX_USE_DEV_RANDOM as replacement for _GLIBCXX_USE_RANDOM_TR1
Define and use a new macro with a more descriptive name. Only use the old macro in <tr1/random.h>. * acinclude.m4 (GLIBCXX_CHECK_RANDOM_TR1): Replace with ... (GLIBCXX_CHECK_DEV_RANDOM): New macro with more descriptive name. Define _GLIBCXX_USE_DEV_RANDOM as well as _GLIBCXX_USE_RANDOM_TR1. * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Use GLIBCXX_CHECK_DEV_RANDOM instead of GLIBCXX_CHECK_RANDOM_TR1. crossconfig.m4: Likewise. * include/bits/random.h (random_device): Use _GLIBCXX_USE_DEV_RANDOM instead of _GLIBCXX_USE_RANDOM_TR1. * testsuite/26_numerics/random/random_device/cons/token.cc: Likewise. From-SVN: r265197
-rw-r--r--libstdc++-v3/ChangeLog14
-rw-r--r--libstdc++-v3/acinclude.m426
-rw-r--r--libstdc++-v3/config.h.in4
-rwxr-xr-xlibstdc++-v3/configure31
-rw-r--r--libstdc++-v3/configure.ac4
-rw-r--r--libstdc++-v3/crossconfig.m42
-rw-r--r--libstdc++-v3/include/bits/random.h6
-rw-r--r--libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc2
8 files changed, 60 insertions, 29 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 08bb1e8..bfb372d 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,17 @@
+2018-10-16 Jonathan Wakely <jwakely@redhat.com>
+
+ * acinclude.m4 (GLIBCXX_CHECK_RANDOM_TR1): Replace with ...
+ (GLIBCXX_CHECK_DEV_RANDOM): New macro with more descriptive name.
+ Define _GLIBCXX_USE_DEV_RANDOM as well as _GLIBCXX_USE_RANDOM_TR1.
+ * config.h.in: Regenerate.
+ * configure: Regenerate.
+ * configure.ac: Use GLIBCXX_CHECK_DEV_RANDOM instead of
+ GLIBCXX_CHECK_RANDOM_TR1.
+ crossconfig.m4: Likewise.
+ * include/bits/random.h (random_device): Use _GLIBCXX_USE_DEV_RANDOM
+ instead of _GLIBCXX_USE_RANDOM_TR1.
+ * testsuite/26_numerics/random/random_device/cons/token.cc: Likewise.
+
2018-10-16 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* testsuite/lib/dg-options.exp (add_options_for_net_ts): New proc.
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 6d68e90..82a25e5 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -2073,27 +2073,31 @@ AC_DEFUN([GLIBCXX_CHECK_UCHAR_H], [
dnl
-dnl Check whether "/dev/random" and "/dev/urandom" are available for the
+dnl Check whether "/dev/random" and "/dev/urandom" are available for
+dnl class std::random_device from C++ 2011 [rand.device], and
dnl random_device of "TR1" (Chapter 5.1, "Random number generation").
dnl
-AC_DEFUN([GLIBCXX_CHECK_RANDOM_TR1], [
+AC_DEFUN([GLIBCXX_CHECK_DEV_RANDOM], [
- AC_MSG_CHECKING([for "/dev/random" and "/dev/urandom" for TR1 random_device])
- AC_CACHE_VAL(glibcxx_cv_random_tr1, [
+ AC_MSG_CHECKING([for "/dev/random" and "/dev/urandom" for std::random_device])
+ AC_CACHE_VAL(glibcxx_cv_dev_random, [
if test -r /dev/random && test -r /dev/urandom; then
- ## For MSys environment the test above is detect as false-positive
- ## on mingw-targets. So disable it explicit for them.
+ ## For MSys environment the test above is detected as false-positive
+ ## on mingw-targets. So disable it explicitly for them.
case ${target_os} in
- *mingw*) glibcxx_cv_random_tr1=no ;;
- *) glibcxx_cv_random_tr1=yes ;;
+ *mingw*) glibcxx_cv_dev_random=no ;;
+ *) glibcxx_cv_dev_random=yes ;;
esac
else
- glibcxx_cv_random_tr1=no;
+ glibcxx_cv_dev_random=no;
fi
])
- AC_MSG_RESULT($glibcxx_cv_random_tr1)
+ AC_MSG_RESULT($glibcxx_cv_dev_random)
- if test x"$glibcxx_cv_random_tr1" = x"yes"; then
+ if test x"$glibcxx_cv_dev_random" = x"yes"; then
+ AC_DEFINE(_GLIBCXX_USE_DEV_RANDOM, 1,
+ [Define if /dev/random and /dev/urandom are available for
+ std::random_device.])
AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1, 1,
[Define if /dev/random and /dev/urandom are available for
the random_device of TR1 (Chapter 5.1).])
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 919a1f0..65e7b46 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -924,6 +924,10 @@
this host. */
#undef _GLIBCXX_USE_DECIMAL_FLOAT
+/* Define if /dev/random and /dev/urandom are available for
+ std::random_device. */
+#undef _GLIBCXX_USE_DEV_RANDOM
+
/* Define if fchmod is available in <sys/stat.h>. */
#undef _GLIBCXX_USE_FCHMOD
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index d33081d..93a727e 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -27852,32 +27852,35 @@ done
CXXFLAGS="$ac_save_CXXFLAGS"
- # For /dev/random and /dev/urandom for TR1.
+ # For /dev/random and /dev/urandom for std::random_device.
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for \"/dev/random\" and \"/dev/urandom\" for TR1 random_device" >&5
-$as_echo_n "checking for \"/dev/random\" and \"/dev/urandom\" for TR1 random_device... " >&6; }
- if test "${glibcxx_cv_random_tr1+set}" = set; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for \"/dev/random\" and \"/dev/urandom\" for std::random_device" >&5
+$as_echo_n "checking for \"/dev/random\" and \"/dev/urandom\" for std::random_device... " >&6; }
+ if test "${glibcxx_cv_dev_random+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -r /dev/random && test -r /dev/urandom; then
- ## For MSys environment the test above is detect as false-positive
- ## on mingw-targets. So disable it explicit for them.
+ ## For MSys environment the test above is detected as false-positive
+ ## on mingw-targets. So disable it explicitly for them.
case ${target_os} in
- *mingw*) glibcxx_cv_random_tr1=no ;;
- *) glibcxx_cv_random_tr1=yes ;;
+ *mingw*) glibcxx_cv_dev_random=no ;;
+ *) glibcxx_cv_dev_random=yes ;;
esac
else
- glibcxx_cv_random_tr1=no;
+ glibcxx_cv_dev_random=no;
fi
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_random_tr1" >&5
-$as_echo "$glibcxx_cv_random_tr1" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_dev_random" >&5
+$as_echo "$glibcxx_cv_dev_random" >&6; }
+
+ if test x"$glibcxx_cv_dev_random" = x"yes"; then
+
+$as_echo "#define _GLIBCXX_USE_DEV_RANDOM 1" >>confdefs.h
- if test x"$glibcxx_cv_random_tr1" = x"yes"; then
$as_echo "#define _GLIBCXX_USE_RANDOM_TR1 1" >>confdefs.h
@@ -47105,6 +47108,8 @@ done
CXXFLAGS="$ac_save_CXXFLAGS"
+ $as_echo "#define _GLIBCXX_USE_DEV_RANDOM 1" >>confdefs.h
+
$as_echo "#define _GLIBCXX_USE_RANDOM_TR1 1" >>confdefs.h
# We don't yet support AIX's TLS ABI.
@@ -59737,6 +59742,8 @@ done
CXXFLAGS="$ac_save_CXXFLAGS"
+ $as_echo "#define _GLIBCXX_USE_DEV_RANDOM 1" >>confdefs.h
+
$as_echo "#define _GLIBCXX_USE_RANDOM_TR1 1" >>confdefs.h
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 332af37..e3612b0 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -255,8 +255,8 @@ if $GLIBCXX_IS_NATIVE; then
GLIBCXX_CHECK_MATH_SUPPORT
GLIBCXX_CHECK_STDLIB_SUPPORT
- # For /dev/random and /dev/urandom for TR1.
- GLIBCXX_CHECK_RANDOM_TR1
+ # For /dev/random and /dev/urandom for std::random_device.
+ GLIBCXX_CHECK_DEV_RANDOM
# For TLS support.
GCC_CHECK_TLS
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index 0dbfe40..3de40dc 100644
--- a/libstdc++-v3/crossconfig.m4
+++ b/libstdc++-v3/crossconfig.m4
@@ -66,6 +66,7 @@ case "${host}" in
GLIBCXX_CHECK_LINKER_FEATURES
GLIBCXX_CHECK_MATH_SUPPORT
GLIBCXX_CHECK_STDLIB_SUPPORT
+ AC_DEFINE(_GLIBCXX_USE_DEV_RANDOM)
AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1)
# We don't yet support AIX's TLS ABI.
#GCC_CHECK_TLS
@@ -188,6 +189,7 @@ case "${host}" in
GLIBCXX_CHECK_LINKER_FEATURES
GLIBCXX_CHECK_MATH_SUPPORT
GLIBCXX_CHECK_STDLIB_SUPPORT
+ AC_DEFINE(_GLIBCXX_USE_DEV_RANDOM)
AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1)
GCC_CHECK_TLS
AC_CHECK_FUNCS(__cxa_thread_atexit_impl)
diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h
index e59c8b0..5e994aa 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -1602,7 +1602,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// constructors, destructors and member functions
-#ifdef _GLIBCXX_USE_RANDOM_TR1
+#ifdef _GLIBCXX_USE_DEV_RANDOM
random_device() { _M_init("default"); }
explicit
@@ -1629,7 +1629,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
double
entropy() const noexcept
{
-#ifdef _GLIBCXX_USE_RANDOM_TR1
+#ifdef _GLIBCXX_USE_DEV_RANDOM
return this->_M_getentropy();
#else
return 0.0;
@@ -1639,7 +1639,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
result_type
operator()()
{
-#ifdef _GLIBCXX_USE_RANDOM_TR1
+#ifdef _GLIBCXX_USE_DEV_RANDOM
return this->_M_getval();
#else
return this->_M_getval_pretr1();
diff --git a/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc
index e2fc507..3d945ae 100644
--- a/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc
+++ b/libstdc++-v3/testsuite/26_numerics/random/random_device/cons/token.cc
@@ -29,7 +29,7 @@
void
test01()
{
-#ifdef _GLIBCXX_USE_RANDOM_TR1
+#ifdef _GLIBCXX_USE_DEV_RANDOM
std::random_device x("/dev/random");
#else
std::random_device x("0");