aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-19 04:32:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-19 04:32:52 +0000
commit58f3e5c51bd48a44ac6faab9451edce862fefab3 (patch)
tree02969d192245bbaa2c5650ee0a0b31312d728e49
parenta257ea8d83c2ab277604b83b68d2c339e7315f3a (diff)
downloadruby-58f3e5c51bd48a44ac6faab9451edce862fefab3.tar.gz
ruby.h: rb_big_sign
* include/ruby/ruby.h (RBIGNUM_SIGN): use a wrapper function to return the sign bit, instead of comparing with 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--bignum.c6
-rw-r--r--include/ruby/ruby.h7
2 files changed, 10 insertions, 3 deletions
diff --git a/bignum.c b/bignum.c
index c0847e6..bf234db 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6691,6 +6691,12 @@ rb_big_abs(VALUE x)
return x;
}
+int
+rb_big_sign(VALUE x)
+{
+ return BIGNUM_SIGN(x);
+}
+
size_t
rb_big_size(VALUE big)
{
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index eeae2f6..72e91c2 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1185,9 +1185,10 @@ void *rb_check_typeddata(VALUE, const rb_data_type_t *);
#define RSTRUCT_SET(st, idx, v) rb_struct_aset(st, INT2NUM(idx), (v))
#define RSTRUCT_GET(st, idx) rb_struct_aref(st, INT2NUM(idx))
-#define RBIGNUM_SIGN(b) (RB_FIX2LONG(rb_big_cmp((b), RB_INT2FIX(0))) >= 0)
-#define RBIGNUM_POSITIVE_P(b) (RB_FIX2LONG(rb_big_cmp((b), RB_INT2FIX(0))) >= 0)
-#define RBIGNUM_NEGATIVE_P(b) (RB_FIX2LONG(rb_big_cmp((b), RB_INT2FIX(0))) < 0)
+int rb_big_sign(VALUE);
+#define RBIGNUM_SIGN(b) (rb_big_sign(b))
+#define RBIGNUM_POSITIVE_P(b) (RBIGNUM_SIGN(b)!=0)
+#define RBIGNUM_NEGATIVE_P(b) (RBIGNUM_SIGN(b)==0)
#define R_CAST(st) (struct st*)
#define RBASIC(obj) (R_CAST(RBasic)(obj))