Commit 94e7477f by Paolo Carlini Committed by Paolo Carlini

re PR libstdc++/57920 ([c++11] Linux: std::random_device reads too much from /dev/urandom)

2013-07-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/57920
	* src/c++11/random.cc (random_device::_M_getval): If possible, use
	read instead of std::fread.
	* include/std/random: Do not include <cstdio> unnecessarily.

From-SVN: r201133
parent ae382ebd
2013-07-22 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57920
* src/c++11/random.cc (random_device::_M_getval): If possible, use
read instead of std::fread.
* include/std/random: Do not include <cstdio> unnecessarily.
2013-07-21 Tim Shen <timshen91@gmail.com>
Partially implement regex_search.
......
......@@ -36,7 +36,6 @@
#else
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iosfwd>
......
......@@ -30,6 +30,11 @@
# include <cpuid.h>
#endif
#include <cstdio>
#ifdef _GLIBCXX_HAVE_UNISTD_H
# include <unistd.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
......@@ -126,8 +131,12 @@ namespace std _GLIBCXX_VISIBILITY(default)
#endif
result_type __ret;
#ifdef _GLIBCXX_HAVE_UNISTD_H
read(fileno(_M_file), reinterpret_cast<void*>(&__ret), sizeof(result_type));
#else
std::fread(reinterpret_cast<void*>(&__ret), sizeof(result_type),
1, _M_file);
#endif
return __ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment