summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--array.c4
-rw-r--r--bignum.c2
-rw-r--r--complex.c2
-rw-r--r--enum.c6
-rw-r--r--gc.c4
-rw-r--r--hash.c2
-rw-r--r--internal.h1
-rw-r--r--io.c2
-rw-r--r--math.c2
-rw-r--r--numeric.c158
-rw-r--r--object.c2
-rw-r--r--rational.c6
-rw-r--r--strftime.c2
-rw-r--r--thread.c2
-rw-r--r--time.c16
15 files changed, 104 insertions, 107 deletions
diff --git a/array.c b/array.c
index 66dc5253a0..20ed970713 100644
--- a/array.c
+++ b/array.c
@@ -7803,7 +7803,7 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
n = 0;
}
}
- else if (RB_TYPE_P(e, T_BIGNUM))
+ else if (RB_BIGNUM_TYPE_P(e))
v = rb_big_plus(e, v);
else if (RB_TYPE_P(e, T_RATIONAL)) {
if (r == Qundef)
@@ -7840,7 +7840,7 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
x = RFLOAT_VALUE(e);
else if (FIXNUM_P(e))
x = FIX2LONG(e);
- else if (RB_TYPE_P(e, T_BIGNUM))
+ else if (RB_BIGNUM_TYPE_P(e))
x = rb_big2dbl(e);
else if (RB_TYPE_P(e, T_RATIONAL))
x = rb_num2dbl(e);
diff --git a/bignum.c b/bignum.c
index 9e1ded5909..806d589842 100644
--- a/bignum.c
+++ b/bignum.c
@@ -42,8 +42,6 @@
#include "ruby/util.h"
#include "ruby_assert.h"
-#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
-
const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
#ifndef SIZEOF_BDIGIT_DBL
diff --git a/complex.c b/complex.c
index 584619af14..ec77aeb588 100644
--- a/complex.c
+++ b/complex.c
@@ -1058,7 +1058,7 @@ rb_complex_pow(VALUE self, VALUE other)
if (k_numeric_p(other) && f_real_p(other)) {
VALUE r, theta;
- if (RB_TYPE_P(other, T_BIGNUM))
+ if (RB_BIGNUM_TYPE_P(other))
rb_warn("in a**b, b may be too big");
r = f_abs(self);
diff --git a/enum.c b/enum.c
index 4a4bb95113..b73e96b55a 100644
--- a/enum.c
+++ b/enum.c
@@ -848,7 +848,7 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
n = 0;
}
}
- else if (RB_TYPE_P(e, T_BIGNUM))
+ else if (RB_BIGNUM_TYPE_P(e))
v = rb_big_plus(e, v);
else
goto not_integer;
@@ -4173,8 +4173,8 @@ enum_sum(int argc, VALUE* argv, VALUE obj)
if (RTEST(rb_range_values(obj, &beg, &end, &excl))) {
if (!memo.block_given && !memo.float_value &&
- (FIXNUM_P(beg) || RB_TYPE_P(beg, T_BIGNUM)) &&
- (FIXNUM_P(end) || RB_TYPE_P(end, T_BIGNUM))) {
+ (FIXNUM_P(beg) || RB_BIGNUM_TYPE_P(beg)) &&
+ (FIXNUM_P(end) || RB_BIGNUM_TYPE_P(end))) {
return int_range_sum(beg, end, excl, memo.v);
}
}
diff --git a/gc.c b/gc.c
index ac280f1e2d..b5656c59f3 100644
--- a/gc.c
+++ b/gc.c
@@ -3417,7 +3417,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
static int
object_id_cmp(st_data_t x, st_data_t y)
{
- if (RB_TYPE_P(x, T_BIGNUM)) {
+ if (RB_BIGNUM_TYPE_P(x)) {
return !rb_big_eql(x, y);
}
else {
@@ -3428,7 +3428,7 @@ object_id_cmp(st_data_t x, st_data_t y)
static st_index_t
object_id_hash(st_data_t n)
{
- if (RB_TYPE_P(n, T_BIGNUM)) {
+ if (RB_BIGNUM_TYPE_P(n)) {
return FIX2LONG(rb_big_hash(n));
}
else {
diff --git a/hash.c b/hash.c
index 314ac18c5c..09298421e1 100644
--- a/hash.c
+++ b/hash.c
@@ -132,7 +132,7 @@ rb_hash(VALUE obj)
}
while (!FIXNUM_P(hval)) {
- if (RB_TYPE_P(hval, T_BIGNUM)) {
+ if (RB_BIGNUM_TYPE_P(hval)) {
int sign;
unsigned long ul;
sign = rb_integer_pack(hval, &ul, 1, sizeof(ul), 0,
diff --git a/internal.h b/internal.h
index 8c116f85d7..00a8295295 100644
--- a/internal.h
+++ b/internal.h
@@ -104,5 +104,6 @@ RUBY_SYMBOL_EXPORT_END
#define bp() ruby_debug_breakpoint()
#define RBOOL(v) ((v) ? Qtrue : Qfalse)
+#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
#endif /* RUBY_INTERNAL_H */
diff --git a/io.c b/io.c
index 2e4c335aae..e2f6875c3e 100644
--- a/io.c
+++ b/io.c
@@ -4543,7 +4543,7 @@ rb_io_ungetc(VALUE io, VALUE c)
if (FIXNUM_P(c)) {
c = rb_enc_uint_chr(FIX2UINT(c), io_read_encoding(fptr));
}
- else if (RB_TYPE_P(c, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(c)) {
c = rb_enc_uint_chr(NUM2UINT(c), io_read_encoding(fptr));
}
else {
diff --git a/math.c b/math.c
index 429826763d..dd45caf6b7 100644
--- a/math.c
+++ b/math.c
@@ -26,8 +26,6 @@
#include "internal/object.h"
#include "internal/vm.h"
-#define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
-
VALUE rb_mMath;
VALUE rb_eMathDomainError;
diff --git a/numeric.c b/numeric.c
index bdf6b26a6f..9252c7ca0e 100644
--- a/numeric.c
+++ b/numeric.c
@@ -262,7 +262,7 @@ rb_num_to_uint(VALUE val, unsigned int *ret)
return 0;
}
- if (RB_TYPE_P(val, T_BIGNUM)) {
+ if (RB_BIGNUM_TYPE_P(val)) {
if (BIGNUM_NEGATIVE_P(val)) return NUMERR_NEGATIVE;
#if SIZEOF_INT < SIZEOF_LONG
/* long is 64bit */
@@ -285,7 +285,7 @@ int_pos_p(VALUE num)
if (FIXNUM_P(num)) {
return FIXNUM_POSITIVE_P(num);
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
return BIGNUM_POSITIVE_P(num);
}
rb_raise(rb_eTypeError, "not an Integer");
@@ -297,7 +297,7 @@ int_neg_p(VALUE num)
if (FIXNUM_P(num)) {
return FIXNUM_NEGATIVE_P(num);
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
return BIGNUM_NEGATIVE_P(num);
}
rb_raise(rb_eTypeError, "not an Integer");
@@ -760,7 +760,7 @@ int_zero_p(VALUE num)
}
}
else {
- assert(RB_TYPE_P(num, T_BIGNUM));
+ assert(RB_BIGNUM_TYPE_P(num));
if (rb_bigzero_p(num)) {
/* this should not happen usually */
return Qtrue;
@@ -830,7 +830,7 @@ num_positive_p(VALUE num)
if (method_basic_p(rb_cInteger))
return RBOOL((SIGNED_VALUE)num > (SIGNED_VALUE)INT2FIX(0));
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
if (method_basic_p(rb_cInteger))
return RBOOL(BIGNUM_POSITIVE_P(num) && !rb_bigzero_p(num));
}
@@ -997,7 +997,7 @@ rb_float_plus(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) {
return DBL2NUM(RFLOAT_VALUE(x) + (double)FIX2LONG(y));
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
return DBL2NUM(RFLOAT_VALUE(x) + rb_big2dbl(y));
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1021,7 +1021,7 @@ rb_float_minus(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) {
return DBL2NUM(RFLOAT_VALUE(x) - (double)FIX2LONG(y));
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
return DBL2NUM(RFLOAT_VALUE(x) - rb_big2dbl(y));
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1045,7 +1045,7 @@ rb_float_mul(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) {
return DBL2NUM(RFLOAT_VALUE(x) * (double)FIX2LONG(y));
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
return DBL2NUM(RFLOAT_VALUE(x) * rb_big2dbl(y));
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1097,7 +1097,7 @@ rb_float_div(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) {
den = FIX2LONG(y);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
den = rb_big2dbl(y);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1195,7 +1195,7 @@ flo_mod(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) {
fy = (double)FIX2LONG(y);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
fy = rb_big2dbl(y);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1235,7 +1235,7 @@ flo_divmod(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM)) {
fy = (double)FIX2LONG(y);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
fy = rb_big2dbl(y);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1271,7 +1271,7 @@ rb_float_pow(VALUE x, VALUE y)
dx = RFLOAT_VALUE(x);
dy = (double)FIX2LONG(y);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
dx = RFLOAT_VALUE(x);
dy = rb_big2dbl(y);
}
@@ -1304,7 +1304,7 @@ num_eql(VALUE x, VALUE y)
{
if (TYPE(x) != TYPE(y)) return Qfalse;
- if (RB_TYPE_P(x, T_BIGNUM)) {
+ if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_eql(x, y);
}
@@ -1352,7 +1352,7 @@ rb_float_equal(VALUE x, VALUE y)
{
volatile double a, b;
- if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
+ if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
return rb_integer_float_eq(y, x);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1427,7 +1427,7 @@ flo_cmp(VALUE x, VALUE y)
a = RFLOAT_VALUE(x);
if (isnan(a)) return Qnil;
- if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
+ if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
return LONG2FIX(-FIX2LONG(rel));
@@ -1473,7 +1473,7 @@ rb_float_gt(VALUE x, VALUE y)
double a, b;
a = RFLOAT_VALUE(x);
- if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
+ if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
return RBOOL(-FIX2LONG(rel) > 0);
@@ -1510,7 +1510,7 @@ flo_ge(VALUE x, VALUE y)
double a, b;
a = RFLOAT_VALUE(x);
- if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
+ if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
return RBOOL(-FIX2LONG(rel) >= 0);
@@ -1547,7 +1547,7 @@ flo_lt(VALUE x, VALUE y)
double a, b;
a = RFLOAT_VALUE(x);
- if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
+ if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
return RBOOL(-FIX2LONG(rel) < 0);
@@ -1584,7 +1584,7 @@ flo_le(VALUE x, VALUE y)
double a, b;
a = RFLOAT_VALUE(x);
- if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
+ if (RB_TYPE_P(y, T_FIXNUM) || RB_BIGNUM_TYPE_P(y)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
return RBOOL(-FIX2LONG(rel) <= 0);
@@ -1980,7 +1980,7 @@ int_round_zero_p(VALUE num, int ndigits)
if (FIXNUM_P(num)) {
bytes = sizeof(long);
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
bytes = rb_big_size(num);
}
else {
@@ -2532,7 +2532,7 @@ num_step_negative_p(VALUE num)
if (method_basic_p(rb_cInteger))
return (SIGNED_VALUE)num < 0;
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
if (method_basic_p(rb_cInteger))
return BIGNUM_NEGATIVE_P(num);
}
@@ -2791,7 +2791,7 @@ rb_num2long(VALUE val)
FLOAT_OUT_OF_RANGE(val, "integer");
}
}
- else if (RB_TYPE_P(val, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(val)) {
return rb_big2long(val);
}
else {
@@ -2827,7 +2827,7 @@ rb_num2ulong_internal(VALUE val, int *wrap_p)
FLOAT_OUT_OF_RANGE(val, "integer");
}
}
- else if (RB_TYPE_P(val, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(val)) {
{
unsigned long ul = rb_big2ulong(val);
if (wrap_p)
@@ -3062,7 +3062,7 @@ rb_num2ll(VALUE val)
FLOAT_OUT_OF_RANGE(val, "long long");
}
}
- else if (RB_TYPE_P(val, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(val)) {
return rb_big2ll(val);
}
else if (RB_TYPE_P(val, T_STRING)) {
@@ -3096,7 +3096,7 @@ rb_num2ull(VALUE val)
FLOAT_OUT_OF_RANGE(val, "unsigned long long");
}
}
- else if (RB_TYPE_P(val, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(val)) {
return rb_big2ull(val);
}
else if (RB_TYPE_P(val, T_STRING)) {
@@ -3128,7 +3128,7 @@ rb_int_odd_p(VALUE num)
return RBOOL(num & 2);
}
else {
- assert(RB_TYPE_P(num, T_BIGNUM));
+ assert(RB_BIGNUM_TYPE_P(num));
return rb_big_odd_p(num);
}
}
@@ -3140,7 +3140,7 @@ int_even_p(VALUE num)
return RBOOL((num & 2) == 0);
}
else {
- assert(RB_TYPE_P(num, T_BIGNUM));
+ assert(RB_BIGNUM_TYPE_P(num));
return rb_big_even_p(num);
}
}
@@ -3216,7 +3216,7 @@ rb_int_succ(VALUE num)
long i = FIX2LONG(num) + 1;
return LONG2NUM(i);
}
- if (RB_TYPE_P(num, T_BIGNUM)) {
+ if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_plus(num, INT2FIX(1));
}
return num_funcall1(num, '+', INT2FIX(1));
@@ -3242,7 +3242,7 @@ rb_int_pred(VALUE num)
long i = FIX2LONG(num) - 1;
return LONG2NUM(i);
}
- if (RB_TYPE_P(num, T_BIGNUM)) {
+ if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_minus(num, INT2FIX(1));
}
return num_funcall1(num, '-', INT2FIX(1));
@@ -3345,7 +3345,7 @@ rb_int_uminus(VALUE num)
return fix_uminus(num);
}
else {
- assert(RB_TYPE_P(num, T_BIGNUM));
+ assert(RB_BIGNUM_TYPE_P(num));
return rb_big_uminus(num);
}
}
@@ -3427,7 +3427,7 @@ rb_int2str(VALUE x, int base)
if (FIXNUM_P(x)) {
return rb_fix2str(x, base);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big2str(x, base);
}
@@ -3449,7 +3449,7 @@ fix_plus(VALUE x, VALUE y)
if (FIXNUM_P(y)) {
return rb_fix_plus_fix(x, y);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_plus(y, x);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -3475,7 +3475,7 @@ rb_int_plus(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_plus(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_plus(x, y);
}
return rb_num_coerce_bin(x, y, '+');
@@ -3496,7 +3496,7 @@ fix_minus(VALUE x, VALUE y)
if (FIXNUM_P(y)) {
return rb_fix_minus_fix(x, y);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
x = rb_int2big(FIX2LONG(x));
return rb_big_minus(x, y);
}
@@ -3514,7 +3514,7 @@ rb_int_minus(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_minus(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_minus(x, y);
}
return rb_num_coerce_bin(x, y, '-');
@@ -3540,7 +3540,7 @@ fix_mul(VALUE x, VALUE y)
if (FIXNUM_P(y)) {
return rb_fix_mul_fix(x, y);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
switch (x) {
case INT2FIX(0): return x;
case INT2FIX(1): return y;
@@ -3564,7 +3564,7 @@ rb_int_mul(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_mul(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_mul(x, y);
}
return rb_num_coerce_bin(x, y, '*');
@@ -3576,7 +3576,7 @@ fix_fdiv_double(VALUE x, VALUE y)
if (FIXNUM_P(y)) {
return double_div_double(FIX2LONG(x), FIX2LONG(y));
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_fdiv_double(rb_int2big(FIX2LONG(x)), y);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -3600,7 +3600,7 @@ rb_int_fdiv_double(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_fdiv_double(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_fdiv_double(x, y);
}
else {
@@ -3645,7 +3645,7 @@ fix_divide(VALUE x, VALUE y, ID op)
if (FIXNUM_ZERO_P(y)) rb_num_zerodiv();
return rb_fix_div_fix(x, y);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
x = rb_int2big(FIX2LONG(x));
return rb_big_div(x, y);
}
@@ -3681,7 +3681,7 @@ rb_int_div(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_div(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_div(x, y);
}
return Qnil;
@@ -3708,7 +3708,7 @@ rb_int_idiv(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_idiv(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_idiv(x, y);
}
return num_div(x, y);
@@ -3733,7 +3733,7 @@ fix_mod(VALUE x, VALUE y)
if (FIXNUM_ZERO_P(y)) rb_num_zerodiv();
return rb_fix_mod_fix(x, y);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
x = rb_int2big(FIX2LONG(x));
return rb_big_modulo(x, y);
}
@@ -3751,7 +3751,7 @@ rb_int_modulo(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_mod(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_modulo(x, y);
}
return num_modulo(x, y);
@@ -3780,7 +3780,7 @@ int_remainder(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return num_remainder(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_remainder(x, y);
}
return Qnil;
@@ -3802,7 +3802,7 @@ fix_divmod(VALUE x, VALUE y)
rb_fix_divmod_fix(x, y, &div, &mod);
return rb_assoc_new(div, mod);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
x = rb_int2big(FIX2LONG(x));
return rb_big_divmod(x, y);
}
@@ -3828,7 +3828,7 @@ rb_int_divmod(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_divmod(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_divmod(x, y);
}
return Qnil;
@@ -3936,7 +3936,7 @@ fix_pow(VALUE x, VALUE y)
if (a == 0) return INT2FIX(0);
return int_pow(a, b);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
if (a == 1) return INT2FIX(1);
if (a == -1) return INT2FIX(int_even_p(y) ? 1 : -1);
if (BIGNUM_NEGATIVE_P(y)) return fix_pow_inverted(x, rb_big_uminus(y));
@@ -3966,7 +3966,7 @@ rb_int_pow(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_pow(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_pow(x, y);
}
return Qnil;
@@ -4008,7 +4008,7 @@ fix_equal(VALUE x, VALUE y)
{
if (x == y) return Qtrue;
if (FIXNUM_P(y)) return Qfalse;
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_eq(y, x);
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -4025,7 +4025,7 @@ rb_int_equal(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_equal(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_eq(x, y);
}
return Qnil;
@@ -4052,7 +4052,7 @@ fix_cmp(VALUE x, VALUE y)
if (FIX2LONG(x) > FIX2LONG(y)) return INT2FIX(1);
return INT2FIX(-1);
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
VALUE cmp = rb_big_cmp(y, x);
switch (cmp) {
case INT2FIX(+1): return INT2FIX(-1);
@@ -4074,7 +4074,7 @@ rb_int_cmp(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_cmp(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_cmp(x, y);
}
else {
@@ -4097,7 +4097,7 @@ fix_gt(VALUE x, VALUE y)
if (FIX2LONG(x) > FIX2LONG(y)) return Qtrue;
return Qfalse;
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
return RBOOL(rb_big_cmp(y, x) == INT2FIX(-1));
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -4114,7 +4114,7 @@ rb_int_gt(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_gt(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_gt(x, y);
}
return Qnil;
@@ -4136,7 +4136,7 @@ fix_ge(VALUE x, VALUE y)
if (FIX2LONG(x) >= FIX2LONG(y)) return Qtrue;
return Qfalse;
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
return RBOOL(rb_big_cmp(y, x) != INT2FIX(+1));
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -4154,7 +4154,7 @@ rb_int_ge(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_ge(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_ge(x, y);
}
return Qnil;
@@ -4175,7 +4175,7 @@ fix_lt(VALUE x, VALUE y)
if (FIX2LONG(x) < FIX2LONG(y)) return Qtrue;
return Qfalse;
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
return RBOOL(rb_big_cmp(y, x) == INT2FIX(+1));
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -4192,7 +4192,7 @@ int_lt(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_lt(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_lt(x, y);
}
return Qnil;
@@ -4214,7 +4214,7 @@ fix_le(VALUE x, VALUE y)
if (FIX2LONG(x) <= FIX2LONG(y)) return Qtrue;
return Qfalse;
}
- else if (RB_TYPE_P(y, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(y)) {
return RBOOL(rb_big_cmp(y, x) != INT2FIX(-1));
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -4232,7 +4232,7 @@ int_le(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_le(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_le(x, y);
}
return Qnil;
@@ -4250,7 +4250,7 @@ rb_int_comp(VALUE num)
if (FIXNUM_P(num)) {
return fix_comp(num);
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_comp(num);
}
return Qnil;
@@ -4301,7 +4301,7 @@ fix_and(VALUE x, VALUE y)
return LONG2NUM(val);
}
- if (RB_TYPE_P(y, T_BIGNUM)) {
+ if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_and(y, x);
}
@@ -4314,7 +4314,7 @@ rb_int_and(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_and(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_and(x, y);
}
return Qnil;
@@ -4336,7 +4336,7 @@ fix_or(VALUE x, VALUE y)
return LONG2NUM(val);
}
- if (RB_TYPE_P(y, T_BIGNUM)) {
+ if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_or(y, x);
}
@@ -4349,7 +4349,7 @@ int_or(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_or(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_or(x, y);
}
return Qnil;
@@ -4371,7 +4371,7 @@ fix_xor(VALUE x, VALUE y)
return LONG2NUM(val);
}
- if (RB_TYPE_P(y, T_BIGNUM)) {
+ if (RB_BIGNUM_TYPE_P(y)) {
return rb_big_xor(y, x);
}
@@ -4384,7 +4384,7 @@ int_xor(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return fix_xor(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_xor(x, y);
}
return Qnil;
@@ -4430,7 +4430,7 @@ rb_int_lshift(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return rb_fix_lshift(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_lshift(x, y);
}
return Qnil;
@@ -4477,7 +4477,7 @@ rb_int_rshift(VALUE x, VALUE y)
if (FIXNUM_P(x)) {
return rb_fix_rshift(x, y);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return rb_big_rshift(x, y);
}
return Qnil;
@@ -4578,7 +4578,7 @@ one_bit:
if (FIXNUM_P(num)) {
return rb_fix_aref(num, arg);
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_aref(num, arg);
}
return Qnil;
@@ -4660,7 +4660,7 @@ int_to_f(VALUE num)
if (FIXNUM_P(num)) {
val = (double)FIX2LONG(num);
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
val = rb_big2dbl(num);
}
else {
@@ -4686,7 +4686,7 @@ rb_int_abs(VALUE num)
if (FIXNUM_P(num)) {
return fix_abs(num);
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_abs(num);
}
return Qnil;
@@ -4704,7 +4704,7 @@ rb_int_size(VALUE num)
if (FIXNUM_P(num)) {
return fix_size(num);
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_size_m(num);
}
return Qnil;
@@ -4725,7 +4725,7 @@ rb_int_bit_length(VALUE num)
if (FIXNUM_P(num)) {
return rb_fix_bit_length(num);
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
return rb_big_bit_length(num);
}
return Qnil;
@@ -4782,12 +4782,12 @@ rb_int_digits_bigbase(VALUE num, VALUE base)
assert(!rb_num_negative_p(num));
- if (RB_TYPE_P(base, T_BIGNUM))
+ if (RB_BIGNUM_TYPE_P(base))
base = rb_big_norm(base);
if (FIXNUM_P(base) && FIX2LONG(base) < 2)
rb_raise(rb_eArgError, "invalid radix %ld", FIX2LONG(base));
- else if (RB_TYPE_P(base, T_BIGNUM) && BIGNUM_NEGATIVE_P(base))
+ else if (RB_BIGNUM_TYPE_P(base) && BIGNUM_NEGATIVE_P(base))
rb_raise(rb_eArgError, "negative radix");
if (FIXNUM_P(base) && FIXNUM_P(num))
@@ -4841,7 +4841,7 @@ rb_int_digits(int argc, VALUE *argv, VALUE num)
if (!RB_INTEGER_TYPE_P(base_value))
rb_raise(rb_eTypeError, "wrong argument type %s (expected Integer)",
rb_obj_classname(argv[0]));
- if (RB_TYPE_P(base_value, T_BIGNUM))
+ if (RB_BIGNUM_TYPE_P(base_value))
return rb_int_digits_bigbase(num, base_value);
base = FIX2LONG(base_value);
@@ -4855,7 +4855,7 @@ rb_int_digits(int argc, VALUE *argv, VALUE num)
if (FIXNUM_P(num))
return rb_fix_digits(num, base);
- else if (RB_TYPE_P(num, T_BIGNUM))
+ else if (RB_BIGNUM_TYPE_P(num))
return rb_int_digits_bigbase(num, LONG2FIX(base));
return Qnil;
diff --git a/object.c b/object.c
index 81b9b12a7a..172eacbdae 100644
--- a/object.c
+++ b/object.c
@@ -3425,7 +3425,7 @@ rb_str_to_dbl(VALUE str, int badcheck)
(FIXNUM_P(x) ? fix2dbl_without_to_f(x) : big2dbl_without_to_f(x))
#define num2dbl_without_to_f(x) \
(FIXNUM_P(x) ? fix2dbl_without_to_f(x) : \
- RB_TYPE_P(x, T_BIGNUM) ? big2dbl_without_to_f(x) : \
+ RB_BIGNUM_TYPE_P(x) ? big2dbl_without_to_f(x) : \
(Check_Type(x, T_FLOAT), RFLOAT_VALUE(x)))
static inline double
rat2dbl_without_to_f(VALUE x)
diff --git a/rational.c b/rational.c
index 313dd0892e..b903decaf6 100644
--- a/rational.c
+++ b/rational.c
@@ -199,7 +199,7 @@ f_minus_one_p(VALUE x)
if (RB_INTEGER_TYPE_P(x)) {
return x == LONG2FIX(-1);
}
- else if (RB_TYPE_P(x, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(x)) {
return Qfalse;
}
else if (RB_TYPE_P(x, T_RATIONAL)) {
@@ -365,7 +365,7 @@ inline static VALUE
f_gcd(VALUE x, VALUE y)
{
#ifdef USE_GMP
- if (RB_TYPE_P(x, T_BIGNUM) && RB_TYPE_P(y, T_BIGNUM)) {
+ if (RB_BIGNUM_TYPE_P(x) && RB_BIGNUM_TYPE_P(y)) {
size_t xn = BIGNUM_LEN(x);
size_t yn = BIGNUM_LEN(y);
if (GMP_GCD_DIGITS <= xn || GMP_GCD_DIGITS <= yn)
@@ -1034,7 +1034,7 @@ rb_rational_pow(VALUE self, VALUE other)
return f_rational_new2(CLASS_OF(self), num, den);
}
}
- else if (RB_TYPE_P(other, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(other)) {
rb_warn("in a**b, b may be too big");
return rb_float_pow(nurat_to_f(self), other);
}
diff --git a/strftime.c b/strftime.c
index 4451fe3c6b..a8a688608e 100644
--- a/strftime.c
+++ b/strftime.c
@@ -219,7 +219,7 @@ case_conv(char *s, ptrdiff_t i, int flags)
static VALUE
format_value(VALUE val, int base)
{
- if (!RB_TYPE_P(val, T_BIGNUM))
+ if (!RB_BIGNUM_TYPE_P(val))
val = rb_Integer(val);
return rb_big2str(val, base);
}
diff --git a/thread.c b/thread.c
index 7d10545b0b..7e1c1a65bb 100644
--- a/thread.c
+++ b/thread.c
@@ -5170,7 +5170,7 @@ recursive_check(VALUE list, VALUE obj, VALUE paired_obj_id)
#if SIZEOF_LONG == SIZEOF_VOIDP
#define OBJ_ID_EQL(obj_id, other) ((obj_id) == (other))
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
- #define OBJ_ID_EQL(obj_id, other) (RB_TYPE_P((obj_id), T_BIGNUM) ? \
+ #define OBJ_ID_EQL(obj_id, other) (RB_BIGNUM_TYPE_P((obj_id)) ? \
rb_big_eql((obj_id), (other)) : ((obj_id) == (other)))
#endif
diff --git a/time.c b/time.c
index a459f56dc2..8869f3269d 100644
--- a/time.c
+++ b/time.c
@@ -87,7 +87,7 @@ cmp(VALUE x, VALUE y)
return 1;
return 0;
}
- if (RB_TYPE_P(x, T_BIGNUM)) return FIX2INT(rb_big_cmp(x, y));
+ if (RB_BIGNUM_TYPE_P(x)) return FIX2INT(rb_big_cmp(x, y));
return rb_cmpint(rb_funcall(x, idCmp, 1, y), x, y);
}
@@ -103,7 +103,7 @@ addv(VALUE x, VALUE y)
if (FIXNUM_P(x) && FIXNUM_P(y)) {
return LONG2NUM(FIX2LONG(x) + FIX2LONG(y));
}
- if (RB_TYPE_P(x, T_BIGNUM)) return rb_big_plus(x, y);
+ if (RB_BIGNUM_TYPE_P(x)) return rb_big_plus(x, y);
return rb_funcall(x, '+', 1, y);
}
@@ -113,7 +113,7 @@ subv(VALUE x, VALUE y)
if (FIXNUM_P(x) && FIXNUM_P(y)) {
return LONG2NUM(FIX2LONG(x) - FIX2LONG(y));
}
- if (RB_TYPE_P(x, T_BIGNUM)) return rb_big_minus(x, y);
+ if (RB_BIGNUM_TYPE_P(x)) return rb_big_minus(x, y);
return rb_funcall(x, '-', 1, y);
}
@@ -123,7 +123,7 @@ mulv(VALUE x, VALUE y)
if (FIXNUM_P(x) && FIXNUM_P(y)) {
return rb_fix_mul_fix(x, y);
}
- if (RB_TYPE_P(x, T_BIGNUM))
+ if (RB_BIGNUM_TYPE_P(x))
return rb_big_mul(x, y);
return rb_funcall(x, '*', 1, y);
}
@@ -134,7 +134,7 @@ divv(VALUE x, VALUE y)
if (FIXNUM_P(x) && FIXNUM_P(y)) {
return rb_fix_div_fix(x, y);
}
- if (RB_TYPE_P(x, T_BIGNUM))
+ if (RB_BIGNUM_TYPE_P(x))
return rb_big_div(x, y);
return rb_funcall(x, id_div, 1, y);
}
@@ -146,7 +146,7 @@ modv(VALUE x, VALUE y)
if (FIX2LONG(y) == 0) rb_num_zerodiv();
if (FIXNUM_P(x)) return rb_fix_mod_fix(x, y);
}
- if (RB_TYPE_P(x, T_BIGNUM)) return rb_big_modulo(x, y);
+ if (RB_BIGNUM_TYPE_P(x)) return rb_big_modulo(x, y);
return rb_funcall(x, '%', 1, y);
}
@@ -322,7 +322,7 @@ v2w(VALUE v)
if (FIXNUM_P(v)) {
return WIDEVAL_WRAP((WIDEVALUE)(SIGNED_WIDEVALUE)(long)v);
}
- else if (RB_TYPE_P(v, T_BIGNUM) &&
+ else if (RB_BIGNUM_TYPE_P(v) &&
rb_absint_size(v, NULL) <= sizeof(WIDEVALUE)) {
return v2w_bignum(v);
}
@@ -2575,7 +2575,7 @@ time_timespec(VALUE num, int interval)
}
}
}
- else if (RB_TYPE_P(num, T_BIGNUM)) {
+ else if (RB_BIGNUM_TYPE_P(num)) {
t.tv_sec = NUM2TIMET(num);
arg_range_check(t.tv_sec);
t.tv_nsec = 0;