Use CHAR_BIT instead of assuming 8 bits
* src/c++11/random.cc (random_device::_M_getentropy): Use __CHAR_BIT__ instead of fixed number of bits. From-SVN: r248428
This commit is contained in:
parent
216bfadc5d
commit
b678436176
|
@ -1,3 +1,8 @@
|
|||
2017-05-24 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
* src/c++11/random.cc (random_device::_M_getentropy): Use __CHAR_BIT__
|
||||
instead of fixed number of bits.
|
||||
|
||||
2017-05-24 Andreas Schwab <schwab@suse.de>
|
||||
|
||||
* config/abi/post/ia64-linux-gnu/baseline_symbols.txt: Update.
|
||||
|
|
|
@ -187,8 +187,9 @@ namespace std _GLIBCXX_VISIBILITY(default)
|
|||
if (ent < 0)
|
||||
return 0.0;
|
||||
|
||||
if (static_cast<unsigned>(ent) > sizeof(result_type) * 8)
|
||||
return static_cast<double>(sizeof(result_type) * 8);
|
||||
const int max = sizeof(result_type) * __CHAR_BIT__;
|
||||
if (ent > max)
|
||||
ent = max;
|
||||
|
||||
return static_cast<double>(ent);
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue