From 821f6f1b318ce6b5e5aad7941593324b20217c32 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 24 Jul 2013 15:42:06 +0000 Subject: [PATCH] random.h (random_device): Avoid using the FILE type. 2013-07-24 Paolo Carlini * include/bits/random.h (random_device): Avoid using the FILE type. * include/std/random: Do not include . * 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 --- libstdc++-v3/ChangeLog | 12 ++++++++++-- libstdc++-v3/include/bits/random.h | 6 +++--- libstdc++-v3/include/std/random | 1 - libstdc++-v3/src/c++11/random.cc | 19 ++++++++++--------- 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 + + * include/bits/random.h (random_device): Avoid using the FILE type. + * include/std/random: Do not include . + * 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 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 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 -#include // For FILE #include #include #include 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 #endif +#include + #ifdef _GLIBCXX_HAVE_UNISTD_H # include #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(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(_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(&__ret), sizeof(result_type)); + read(fileno(static_cast(_M_file)), + static_cast(&__ret), sizeof(result_type)); #else - std::fread(reinterpret_cast(&__ret), sizeof(result_type), - 1, _M_file); + std::fread(static_cast(&__ret), sizeof(result_type), + 1, static_cast(_M_file)); #endif return __ret; } -- 2.7.4