Commit efc622f8 by Ulrich Drepper Committed by Ulrich Drepper

random.cc (random_device::_M_init): Check whether cpuid instruction is available…

random.cc (random_device::_M_init): Check whether cpuid instruction is available by using __get_cpuid_max.


	* src/c++11/random.cc (random_device::_M_init): Check whether cpuid
	instruction is available by using __get_cpuid_max.

From-SVN: r190982
parent 4700dd70
2012-09-05 Ulrich Drepper <drepper@gmail.com> 2012-09-05 Ulrich Drepper <drepper@gmail.com>
* src/c++11/random.cc (random_device::_M_init): Check whether cpuid
instruction is available by using __get_cpuid_max.
* include/ext/random.tcc (__gnu_cxx:normal_mv_distribution<>) * include/ext/random.tcc (__gnu_cxx:normal_mv_distribution<>)
(operator()): Use __generate() function of _M_nd. (operator()): Use __generate() function of _M_nd.
......
...@@ -77,9 +77,9 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -77,9 +77,9 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ {
#if defined __i386__ || defined __x86_64__ #if defined __i386__ || defined __x86_64__
unsigned int eax, ebx, ecx, edx; unsigned int eax, ebx, ecx, edx;
__cpuid(0, eax, ebx, ecx, edx); // Check availability of cpuid and, for now at least, also the
// Check for "GenuineIntel" // CPU signature for Intel's
if (ebx == 0x756e6547 && ecx == 0x6c65746e && edx == 0x49656e69) if (__get_cpuid_max(0, &ebx) > 0 && ebx == 0x756e6547)
{ {
__cpuid(1, eax, ebx, ecx, edx); __cpuid(1, eax, ebx, ecx, edx);
if (ecx & bit_RDRND) if (ecx & bit_RDRND)
...@@ -104,7 +104,6 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -104,7 +104,6 @@ namespace std _GLIBCXX_VISIBILITY(default)
void void
random_device::_M_init_pretr1(const std::string& token) random_device::_M_init_pretr1(const std::string& token)
{ {
_M_mt.seed(_M_strtoul(token)); _M_mt.seed(_M_strtoul(token));
} }
......
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