summaryrefslogtreecommitdiff
path: root/bignum.c
AgeCommit message (Collapse)Author
2013-07-01* bignum.c (bary_mul2): New function.akr
(rb_cstr_to_inum): Use a better algorithm to compose the result if input length is very long. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-01* bignum.c (rb_cstr_to_inum): Skip leading zeros.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-30* bignum.c (nlz16): New function.akr
(nlz32): Ditto. (nlz64): Ditto. (nlz128): Ditto. (nlz): Redefined using an above function. (bitsize): New macro. (rb_cstr_to_inum): Use bitsize instead of nlz. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-30* bignum.c (rb_cstr_to_inum): Use rb_integer_unpack if base is a powerakr
of 2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29* bignum.c (big_rshift): Use abs2twocomp and twocomp2abs_bang.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29* bignum.c (RBIGNUM_SET_NEGATIVE_SIGN): New macro.akr
(RBIGNUM_SET_POSITIVE_SIGN): Ditto. (rb_big_neg): Inline get2comp to avoid double negation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29* bignum.c (bary_neg): Extracted from bary_2comp.akr
(bary_plus_one): Extracted from bary_2comp. (bary_2comp): Use bary_neg and bary_plus_one. (big_extend_carry): Extracted from get2comp. (get2comp): Use big_extend_carry. (rb_integer_unpack): Use big_extend_carry. (rb_big_neg): Use bary_neg. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29* bignum.c (bary_2comp): Simplified.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29* bignum.c (bigor_int): Return -1 if y == -1.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29* bignum.c (bigor_int): Use RB_GC_GUARD.akr
(bigxor_int): Take xn and hibitsx arguments. Use twocomp2abs_bang. (rb_big_xor): Use abs2twocomp and twocomp2abs_bang. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-28* bignum.c (bigand_int): Don't apply bitwise and for BDIGIT and long.akr
(bigor_int): Take xn and hibitsx arguments. Use twocomp2abs_bang. (rb_big_or): Use abs2twocomp and twocomp2abs_bang. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-28* bignum.c (rb_big_and): Allocate new bignum with same size to shorterakr
argument if it's high bits are zero. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-27* bignum.c (bigand_int): Add arguments, xn and hibitsx.akr
Use twocomp2abs_bang. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-27* bignum.c (abs2twocomp_bang): Removed.akr
(abs2twocomp): Take n_ret argument to return actual length. (rb_big_and): Follow above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-27* bignum.c (get2comp): Use bary_2comp.akr
(abs2twocomp_bang): New function. (abs2twocomp): New function. (twocomp2abs_bang): New function. (rb_big_and): Use abs2twocomp and twocomp2abs_bang. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26* bignum.c (rb_big_pow): Retry if y is a Bignum and it isakr
representable as a Fixnum. Use rb_absint_numwords. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26* bignum.c (LSHIFTABLE): extract from LSHIFTX().nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26* bignum.c (bigxor_int): Fix a buffer over read.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26* bignum.c (bigand_int): Consider negative values.akr
(bigor_int): The allocated bignum should have enough size to store long. This fixes (bignum fits in a BDIGIT) | (fixnum bigger than BDIGIT) on platforms which SIZEOF_BDIGITS < SIZEOF_LONG, such as LP64 with 32bit BDIGIT (no int128). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (bigand_int): Fix a buffer over read.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (bigadd_int): Fix a buffer over read.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (bigsub_int): Fix a buffer over read.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (rb_absint_singlebit_p): Use POW2_P.akr
(bary_pack): Ditto. (rb_big2str0): Ditto. (POW2_P): Moved to top. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (big2dbl): Use (BDIGIT)1 instead of 1UL.akr
(bary_mul_normal): Remove a useless cast. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (big2ulong): "check" argument removed.akr
(rb_big2ulong): Follow above change. (rb_big2long): Ditto. (rb_big_rshift): Ditto. (rb_big_aref): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (rb_big2ulong_pack): Use rb_integer_pack.akr
(rb_big_aref): Call big2ulong with TRUE for "check" argument. It should be non-effective. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (LSHIFTX): Revert r41611.akr
The redundant expression suppresses a warning, C4293, by Visual Studio. http://ruby-mswin.cloudapp.net/vc10-x64/ruby-trunk/log/20130625T072854Z.log.html.gz#miniruby git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (big2ulong): Add a cast.akr
(big2ull): Add a specialized code for SIZEOF_LONG_LONG <= SIZEOF_BDIGITS. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (integer_unpack_single_bdigit): Use "1 + ~u" instead ofakr
"-u" to suppress warning (C4146) by Visual Studio. Reported by ko1 via IRC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (big2ulong): Add code specialized for SIZEOF_LONG <=akr
SIZEOF_BDIGITS. This prevents shift witdth warning from "num <<= BITSPERDIG". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25* bignum.c (MSB): Removed.akr
(BDIGIT_MSB): Defined using BIGRAD_HALF. (bary_2comp): Apply BIGLO after possible over flow of BDIGIT. (get2comp): Ditto. (bary_unpack_internal): Use BDIGIT_MSB. Apply BIGLO after possible over flow of BDIGIT. (rb_integer_unpack): Use BDIGIT_MSB. (calc_hbase): Use BDIGMAX. (big2dbl): Use BDIGMAX. Apply BIGLO after possible over flow of BDIGIT. (rb_big_neg): Apply BIGLO after possible over flow of BDIGIT. (biglsh_bang): Ditto. (bigrsh_bang): Ditto. (bary_divmod): Use BDIGIT_MSB. (bigdivrem): Ditto. (bigxor_int): Apply BIGLO after possible over flow of BDIGIT. * marshal.c (shortlen): Use SIZEOF_BDIGITS instead of sizeof(BDIGIT). * ext/openssl/ossl_bn.c (ossl_bn_initialize): Use SIZEOF_BDIGITS instead of sizeof(BDIGIT). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25bignum.c: suppress warningnobu
* bignum.c (big2ulong): suppress shorten-64-to-32 warning. BDIGIT can be bigger than long now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25bignum.c: redundant expressionnobu
* bignum.c (LSHIFTX): remove redundant never-true expression. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-24* bignum.c (integer_unpack_single_bdigit): Refine code to fillingakr
higher bits and use BIGLO. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-23* bignum.c (BIGUP): Use LSHIFTX and avoid cast to consider the typeakr
of x is bigger than BDIGIT_DBL. (big2ulong): Use unsigned long to store the result. (big2ull): Use unsigned LONG_LONG to store the result. (bigand_int): Use long for num to avoid data loss. (bigor_int): Ditto. (bigxor_int): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-23* bignum.c (integer_unpack_single_bdigit): Use a cast.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (integer_unpack_single_bdigit): Extracted fromakr
bary_unpack_internal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (bary_unpack_internal): Suppress warnings (C4146) on Visual Studio.akr
Reported by ko1 via IRC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (bytes_zero_p): Removed.akr
(bary_pack): Don't call bytes_zero_p. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (bytes_zero_p): Extracted from bary_pack.akr
(bary_pack): Use bytes_zero_p. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (MSB): New macro.akr
(bary_unpack_internal): Use MSB. (bary_divmod): Ditto. (bigdivrem): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22Update comments.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22Unused code removed.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (bary_swap): New function.akr
(bary_pack): Use bary_swap. (bary_unpack_internal): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (bytes_2comp): Renamed from quad_buf_complement.akr
(bary_pack): Use bytes_2comp. (rb_quad_pack): Use rb_integer_pack. (rb_quad_unpack): Use rb_integer_unpack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (rb_integer_unpack): Don't allocate a Bignum if possible.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (bary_unpack_internal): Specialized unpacker implemented.akr
(bary_unpack): Support INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION. (rb_integer_unpack): Support INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (bary_pack): Supportakr
INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION flag. Fix byte order and word order handling in code specialized for wordsize % SIZEOF_BDIGITS == 0. * internal.h (INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION): Defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (bary_pack): MEMZERO can be used even if nails is not zero.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22* bignum.c (CLEAR_LOWBITS): Rewritten without RSHIFTX.akr
(RSHIFTX): Removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e