From 6839d47eb88a839155db263b6d262b1e5a6a2406 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 19 Nov 2016 04:32:52 +0000 Subject: 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 --- bignum.c | 6 ++++++ include/ruby/ruby.h | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bignum.c b/bignum.c index c0847e620d..bf234dba6a 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 eeae2f6879..72e91c2f7b 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)) -- cgit v1.2.3