зеркало из https://github.com/github/ruby.git
random.c: suppress a warning
* random.c (random_ulong_limited): suppress a shift count warning when unsigned long is 32bits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5cb5692ac8
Коммит
9529e46adf
6
random.c
6
random.c
|
@ -991,7 +991,11 @@ random_ulong_limited(VALUE obj, rb_random_t *rnd, unsigned long limit)
|
||||||
const int w = sizeof(limit) * CHAR_BIT - nlz_long(limit);
|
const int w = sizeof(limit) * CHAR_BIT - nlz_long(limit);
|
||||||
const int n = w > 32 ? sizeof(unsigned long) : sizeof(uint32_t);
|
const int n = w > 32 ? sizeof(unsigned long) : sizeof(uint32_t);
|
||||||
const unsigned long mask = ~(~0UL << w);
|
const unsigned long mask = ~(~0UL << w);
|
||||||
const unsigned long full = ~(~0UL << n * CHAR_BIT);
|
const unsigned long full =
|
||||||
|
#if SIZEOF_LONG == 4
|
||||||
|
(size_t)n >= sizeof(unsigned long) ? ~0UL :
|
||||||
|
#endif
|
||||||
|
~(~0UL << n * CHAR_BIT);
|
||||||
unsigned long val, bits = 0, rest = 0;
|
unsigned long val, bits = 0, rest = 0;
|
||||||
do {
|
do {
|
||||||
if (mask & ~rest) {
|
if (mask & ~rest) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче