diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2017-09-09 16:31:33 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2017-09-09 16:31:33 +0900 |
commit | 7d91217a0a65ff24ab629bd63870a5b0a36775de (patch) | |
tree | 411c64fa616a40290e1a93d749976f17d16aace5 /include/ruby/ruby.h | |
parent | 1dab9557432e12f489109966b8ab5c6cb85afba6 (diff) | |
download | ruby-wip/cleanup-num-macros.tar.gz |
ruby.h: simplify RB_NUM2INT() and RB_FIX2INT() declarationwip/cleanup-num-macros
Diffstat (limited to 'include/ruby/ruby.h')
-rw-r--r-- | include/ruby/ruby.h | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 60dbf79ec1..ca4897da1a 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -649,29 +649,15 @@ rb_num2ulong_inline(VALUE x) } #define RB_NUM2ULONG(x) rb_num2ulong_inline(x) #define NUM2ULONG(x) RB_NUM2ULONG(x) +#define RB_NUM2INT(x) rb_long2int(RB_NUM2LONG(x)) +#define RB_FIX2INT(x) rb_long2int(RB_FIX2LONG(x)) #if SIZEOF_INT < SIZEOF_LONG -long rb_num2int(VALUE); -long rb_fix2int(VALUE); -#define RB_FIX2INT(x) ((int)rb_fix2int((VALUE)(x))) - -static inline int -rb_num2int_inline(VALUE x) -{ - if (RB_FIXNUM_P(x)) - return (int)rb_fix2int(x); - else - return (int)rb_num2int(x); -} -#define RB_NUM2INT(x) rb_num2int_inline(x) - unsigned long rb_num2uint(VALUE); #define RB_NUM2UINT(x) ((unsigned int)rb_num2uint(x)) unsigned long rb_fix2uint(VALUE); #define RB_FIX2UINT(x) ((unsigned int)rb_fix2uint(x)) #else /* SIZEOF_INT < SIZEOF_LONG */ -#define RB_NUM2INT(x) ((int)RB_NUM2LONG(x)) #define RB_NUM2UINT(x) ((unsigned int)RB_NUM2ULONG(x)) -#define RB_FIX2INT(x) ((int)RB_FIX2LONG(x)) #define RB_FIX2UINT(x) ((unsigned int)RB_FIX2ULONG(x)) #endif /* SIZEOF_INT < SIZEOF_LONG */ #define NUM2INT(x) RB_NUM2INT(x) |