diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-13 06:36:40 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-13 06:36:40 +0000 |
commit | e31c9896d68106a9bdc872c75c3c28f79a5bb4d6 (patch) | |
tree | 8d7d7052fa6c858a08340eaeea6f81b21bab2a60 | |
parent | 245d964e8a72c1aba46ead0c7f290585b3b42b02 (diff) | |
download | ruby-e31c9896d68106a9bdc872c75c3c28f79a5bb4d6.tar.gz |
* bignum.c (bary_small_lshift): Functions moved to remove
declaration.
(bary_small_rshift): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | bignum.c | 61 |
2 files changed, 35 insertions, 32 deletions
@@ -1,3 +1,9 @@ +Sat Jul 13 15:33:33 2013 Tanaka Akira <akr@fsij.org> + + * bignum.c (bary_small_lshift): Functions moved to remove + declaration. + (bary_small_rshift): Ditto. + Sat Jul 13 12:27:34 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> * encoding.c (rb_enc_associate_index): fill new terminator length, not @@ -114,8 +114,6 @@ STATIC_ASSERT(rbignum_embed_len_max, RBIGNUM_EMBED_LEN_MAX <= (RBIGNUM_EMBED_LEN typedef void (mulfunc_t)(BDIGIT *zds, size_t zl, BDIGIT *xds, size_t xl, BDIGIT *yds, size_t yl, BDIGIT *wds, size_t wl); -static BDIGIT bary_small_lshift(BDIGIT *zds, BDIGIT *xds, long n, int shift); -static void bary_small_rshift(BDIGIT *zds, BDIGIT *xds, long n, int shift, int sign_bit); static mulfunc_t bary_mul_toom3_start; static mulfunc_t bary_mul_karatsuba_start; static void bary_divmod(BDIGIT *qds, size_t nq, BDIGIT *rds, size_t nr, BDIGIT *xds, size_t nx, BDIGIT *yds, size_t ny); @@ -442,6 +440,35 @@ maxpow_in_bdigit(int base, int *exp_ret) return maxpow; } +static BDIGIT +bary_small_lshift(BDIGIT *zds, BDIGIT *xds, long n, int shift) +{ + long i; + BDIGIT_DBL num = 0; + + for (i=0; i<n; i++) { + num = num | (BDIGIT_DBL)*xds++ << shift; + *zds++ = BIGLO(num); + num = BIGDN(num); + } + return BIGLO(num); +} + +static void +bary_small_rshift(BDIGIT *zds, BDIGIT *xds, long n, int shift, int sign_bit) +{ + BDIGIT_DBL num = 0; + BDIGIT x; + if (sign_bit) { + num = (~(BDIGIT_DBL)0) << BITSPERDIG; + } + while (n--) { + num = (num | xds[n]) >> shift; + x = xds[n]; + zds[n] = BIGLO(num); + num = BIGUP(x); + } +} static int bary_zero_p(BDIGIT *xds, size_t nx) @@ -5706,20 +5733,6 @@ rb_big_lshift(VALUE x, VALUE y) return bignorm(x); } -static BDIGIT -bary_small_lshift(BDIGIT *zds, BDIGIT *xds, long n, int shift) -{ - long i; - BDIGIT_DBL num = 0; - - for (i=0; i<n; i++) { - num = num | (BDIGIT_DBL)*xds++ << shift; - *zds++ = BIGLO(num); - num = BIGDN(num); - } - return BIGLO(num); -} - static VALUE big_lshift(VALUE x, unsigned long shift) { @@ -5783,22 +5796,6 @@ rb_big_rshift(VALUE x, VALUE y) return bignorm(x); } -static void -bary_small_rshift(BDIGIT *zds, BDIGIT *xds, long n, int shift, int sign_bit) -{ - BDIGIT_DBL num = 0; - BDIGIT x; - if (sign_bit) { - num = (~(BDIGIT_DBL)0) << BITSPERDIG; - } - while (n--) { - num = (num | xds[n]) >> shift; - x = xds[n]; - zds[n] = BIGLO(num); - num = BIGUP(x); - } -} - static VALUE big_rshift(VALUE x, unsigned long shift) { |