diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-04-08 13:28:13 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-08 13:28:13 +0900 |
commit | 9e6e39c3512f7a962c44dc3729c98a0f8be90341 (patch) | |
tree | 901a22676d54d78240e450b64a8cd06eb1703910 /bignum.c | |
parent | 5ac4bf2cd87e1eb5779ca5ae7f96a1a22e8436d9 (diff) |
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
Notes
Notes:
Merged-By: shyouhei <shyouhei@ruby-lang.org>
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -9,7 +9,7 @@ **********************************************************************/ -#include "ruby/config.h" +#include "ruby/3/config.h" #include <ctype.h> #include <float.h> @@ -3018,18 +3018,19 @@ static VALUE bignew_1(VALUE klass, size_t len, int sign) { NEWOBJ_OF(big, struct RBignum, klass, T_BIGNUM | (RGENGC_WB_PROTECTED_BIGNUM ? FL_WB_PROTECTED : 0)); - BIGNUM_SET_SIGN((VALUE)big, sign); + VALUE bigv = (VALUE)big; + BIGNUM_SET_SIGN(bigv, sign); if (len <= BIGNUM_EMBED_LEN_MAX) { - FL_SET_RAW(big, BIGNUM_EMBED_FLAG); - BIGNUM_SET_LEN((VALUE)big, len); - (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)RBIGNUM(big)->as.ary, sizeof(RBIGNUM(big)->as.ary)); + FL_SET_RAW(bigv, BIGNUM_EMBED_FLAG); + BIGNUM_SET_LEN(bigv, len); + (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)big->as.ary, sizeof(big->as.ary)); } else { - RBIGNUM(big)->as.heap.digits = ALLOC_N(BDIGIT, len); - RBIGNUM(big)->as.heap.len = len; + big->as.heap.digits = ALLOC_N(BDIGIT, len); + big->as.heap.len = len; } - OBJ_FREEZE(big); - return (VALUE)big; + OBJ_FREEZE(bigv); + return bigv; } VALUE @@ -6278,7 +6279,7 @@ rb_big_pow(VALUE x, VALUE y) yy = FIX2LONG(y); if (yy < 0) { - x = rb_big_pow(x, INT2NUM(-yy)); + x = rb_big_pow(x, LONG2NUM(-yy)); if (RB_INTEGER_TYPE_P(x)) return rb_rational_raw(INT2FIX(1), x); else |