1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Moved RHASH_LEV_MASK and turned into a macro

Get rid of "ISO C restricts enumerator values to range of 'int'"
error.
This commit is contained in:
Nobuyoshi Nakada 2019-07-31 11:08:05 +09:00
parent e315f3a134
commit 13e84d5c0a
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 2 additions and 3 deletions

3
hash.c
View file

@ -1317,10 +1317,11 @@ iter_lev_in_ivar_set(VALUE hash, int lev)
rb_ivar_set_internal(hash, rb_intern("hash_iter_lev"), INT2FIX(lev));
}
#define RHASH_LEV_MASK ((VALUE)RHASH_LEV_MAX << RHASH_LEV_SHIFT)
static int
iter_lev_in_flags(VALUE hash)
{
unsigned int u = (unsigned int)(RBASIC(hash)->flags & (unsigned int)RHASH_LEV_MASK) >> RHASH_LEV_SHIFT;
unsigned int u = (unsigned int)((RBASIC(hash)->flags >> RHASH_LEV_SHIFT) & RHASH_LEV_MAX);
return (int)u;
}

View file

@ -827,8 +827,6 @@ enum ruby_rhash_flags {
RHASH_TRANSIENT_FLAG = FL_USER12, /* FL 12 */
#endif
RHASH_LEV_MASK = (FL_USER13 | FL_USER14 | FL_USER15 | /* FL 13..19 */
FL_USER16 | FL_USER17 | FL_USER18 | FL_USER19),
RHASH_LEV_SHIFT = (FL_USHIFT + 13),
RHASH_LEV_MAX = 127, /* 7 bits */