Skip to content

Commit

Permalink
Moved RHASH_LEV_MASK and turned into a macro
Browse files Browse the repository at this point in the history
Get rid of "ISO C restricts enumerator values to range of 'int'"
error.
  • Loading branch information
nobu committed Jul 31, 2019
1 parent e315f3a commit 13e84d5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 2 additions & 1 deletion hash.c
Expand Up @@ -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;
}

Expand Down
2 changes: 0 additions & 2 deletions internal.h
Expand Up @@ -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 */

Expand Down

0 comments on commit 13e84d5

Please sign in to comment.