aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo@gcc.gnu.org>2013-07-24 15:42:06 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2013-07-24 15:42:06 +0000
commit821f6f1b318ce6b5e5aad7941593324b20217c32 (patch)
treee3393e23fa07c37c8b5a59a402016f4bad3f6f0b
parent37c74e2816535f654390781de97cc01206b0ff31 (diff)
downloadgcc-821f6f1b318ce6b5e5aad7941593324b20217c32.zip
gcc-821f6f1b318ce6b5e5aad7941593324b20217c32.tar.gz
gcc-821f6f1b318ce6b5e5aad7941593324b20217c32.tar.bz2
random.h (random_device): Avoid using the FILE type.
2013-07-24 Paolo Carlini <paolo.carlini@oracle.com> * include/bits/random.h (random_device): Avoid using the FILE type. * include/std/random: Do not include <cstdio>. * src/c++11/random.cc: ... include it here. (random_device::_M_init, random_device::_M_fini, random_device::_M_getval): Cast back and forth void* and FILE*. From-SVN: r201215
-rw-r--r--libstdc++-v3/ChangeLog12
-rw-r--r--libstdc++-v3/include/bits/random.h6
-rw-r--r--libstdc++-v3/include/std/random1
-rw-r--r--libstdc++-v3/src/c++11/random.cc19
4 files changed, 23 insertions, 15 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 45dc945..13d80f2 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,11 @@
+2013-07-24 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/bits/random.h (random_device): Avoid using the FILE type.
+ * include/std/random: Do not include <cstdio>.
+ * src/c++11/random.cc: ... include it here.
+ (random_device::_M_init, random_device::_M_fini,
+ random_device::_M_getval): Cast back and forth void* and FILE*.
+
2013-07-24 Tim Shen <timshen91@gmail.com>
Reimplment matcher using Depth-first search(backtracking).
@@ -24,8 +32,8 @@
New.
* testsuite/28_regex/iterators/regex_token_iterator/char/string_01.cc:
New.
- * testsuite/28_regex/iterators/regex_token_iterator/wchar_t/string_01.cc:
- New.
+ * testsuite/28_regex/iterators/regex_token_iterator/wchar_t/
+ string_01.cc: New.
2013-07-23 Paolo Carlini <paolo.carlini@oracle.com>
diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h
index 74ef144..bf7f32f 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -1638,9 +1638,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
union
{
- FILE* _M_file;
- mt19937 _M_mt;
- };
+ void* _M_file;
+ mt19937 _M_mt;
+ };
};
/* @} */ // group random_generators
diff --git a/libstdc++-v3/include/std/random b/libstdc++-v3/include/std/random
index 4aa0416..84b1761 100644
--- a/libstdc++-v3/include/std/random
+++ b/libstdc++-v3/include/std/random
@@ -36,7 +36,6 @@
#else
#include <cmath>
-#include <cstdio> // For FILE
#include <cstdlib>
#include <string>
#include <iosfwd>
diff --git a/libstdc++-v3/src/c++11/random.cc b/libstdc++-v3/src/c++11/random.cc
index b62f4f7..939bf02 100644
--- a/libstdc++-v3/src/c++11/random.cc
+++ b/libstdc++-v3/src/c++11/random.cc
@@ -30,13 +30,14 @@
# include <cpuid.h>
#endif
+#include <cstdio>
+
#ifdef _GLIBCXX_HAVE_UNISTD_H
# include <unistd.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
-
namespace
{
static unsigned long
@@ -72,7 +73,6 @@ namespace std _GLIBCXX_VISIBILITY(default)
#endif
}
-
void
random_device::_M_init(const std::string& token)
{
@@ -102,8 +102,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
std::__throw_runtime_error(__N("random_device::"
"random_device(const std::string&)"));
- _M_file = std::fopen(fname, "rb");
- if (! _M_file)
+ _M_file = static_cast<void*>(std::fopen(fname, "rb"));
+ if (!_M_file)
goto fail;
}
@@ -117,23 +117,24 @@ namespace std _GLIBCXX_VISIBILITY(default)
random_device::_M_fini()
{
if (_M_file)
- std::fclose(_M_file);
+ std::fclose(static_cast<FILE*>(_M_file));
}
random_device::result_type
random_device::_M_getval()
{
#if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND
- if (! _M_file)
+ if (!_M_file)
return __x86_rdrand();
#endif
result_type __ret;
#ifdef _GLIBCXX_HAVE_UNISTD_H
- read(fileno(_M_file), reinterpret_cast<void*>(&__ret), sizeof(result_type));
+ read(fileno(static_cast<FILE*>(_M_file)),
+ static_cast<void*>(&__ret), sizeof(result_type));
#else
- std::fread(reinterpret_cast<void*>(&__ret), sizeof(result_type),
- 1, _M_file);
+ std::fread(static_cast<void*>(&__ret), sizeof(result_type),
+ 1, static_cast<FILE*>(_M_file));
#endif
return __ret;
}