]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
random.h (random_device): Avoid using the FILE type.
authorPaolo Carlini <paolo@gcc.gnu.org>
Wed, 24 Jul 2013 15:42:06 +0000 (15:42 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 24 Jul 2013 15:42:06 +0000 (15:42 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/random.h
libstdc++-v3/include/std/random
libstdc++-v3/src/c++11/random.cc

index 45dc9452afbbdac5aa208cf649e90d8f4db1f687..13d80f2d4dddf8d572f716823e7f3daa0df31d46 100644 (file)
@@ -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>
 
index 74ef144300042eb1212c0c6d056779a68f002ffd..bf7f32ff0f2618f7d8388656ee87645d788994a9 100644 (file)
@@ -1638,9 +1638,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     union
     {
-    FILE*        _M_file;
-    mt19937      _M_mt;
-  };
+      void*      _M_file;
+      mt19937    _M_mt;
+    };
   };
 
   /* @} */ // group random_generators
index 4aa0416c0475865d6b868f041df78934aaa3846a..84b176154b9b4e0787004525d45c81f577ae04bc 100644 (file)
@@ -36,7 +36,6 @@
 #else
 
 #include <cmath>
-#include <cstdio> // For FILE
 #include <cstdlib>
 #include <string>
 #include <iosfwd>
index b62f4f7e6b76c29b9f70525db5fc4e8a74028181..939bf02583cfb0fb5b7bcbc387f773d53a658fbc 100644 (file)
 # 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;
   }