mirror of git://gcc.gnu.org/git/gcc.git
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
This commit is contained in:
parent
ae382ebd8c
commit
94e7477f0c
|
|
@ -1,3 +1,10 @@
|
||||||
|
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>
|
2013-07-21 Tim Shen <timshen91@gmail.com>
|
||||||
|
|
||||||
Partially implement regex_search.
|
Partially implement regex_search.
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,11 @@
|
||||||
# include <cpuid.h>
|
# include <cpuid.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
#ifdef _GLIBCXX_HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace std _GLIBCXX_VISIBILITY(default)
|
namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
{
|
{
|
||||||
|
|
@ -126,8 +131,12 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
result_type __ret;
|
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),
|
std::fread(reinterpret_cast<void*>(&__ret), sizeof(result_type),
|
||||||
1, _M_file);
|
1, _M_file);
|
||||||
|
#endif
|
||||||
return __ret;
|
return __ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue