aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
Commit message (Collapse)AuthorAgeFilesLines
* * bignum.c (BIGUP): Use LSHIFTX and avoid cast to consider the typeakr2013-06-231-7/+7
| | | | | | | | | | | | | 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
* * bignum.c (integer_unpack_single_bdigit): Use a cast.akr2013-06-231-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (integer_unpack_single_bdigit): Extracted fromakr2013-06-221-44/+21
| | | | | | | | bary_unpack_internal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_unpack_internal): Suppress warnings (C4146) on Visual Studio.akr2013-06-221-4/+4
| | | | | | | | Reported by ko1 via IRC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bytes_zero_p): Removed.akr2013-06-221-25/+15
| | | | | | | | (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
* * bignum.c (bytes_zero_p): Extracted from bary_pack.akr2013-06-221-7/+14
| | | | | | | | (bary_pack): Use bytes_zero_p. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (MSB): New macro.akr2013-06-221-6/+7
| | | | | | | | | | (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
* Update comments.akr2013-06-221-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Unused code removed.akr2013-06-221-114/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_swap): New function.akr2013-06-221-30/+19
| | | | | | | | | (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
* * bignum.c (bytes_2comp): Renamed from quad_buf_complement.akr2013-06-221-129/+25
| | | | | | | | | | (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
* * bignum.c (rb_integer_unpack): Don't allocate a Bignum if possible.akr2013-06-221-4/+35
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_unpack_internal): Specialized unpacker implemented.akr2013-06-221-9/+162
| | | | | | | | | (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
* * bignum.c (bary_pack): Supportakr2013-06-221-139/+157
| | | | | | | | | | | | 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
* * bignum.c (bary_pack): MEMZERO can be used even if nails is not zero.akr2013-06-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (CLEAR_LOWBITS): Rewritten without RSHIFTX.akr2013-06-221-2/+1
| | | | | | | | (RSHIFTX): Removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (LSHIFTX): Defined to suppress a warning.akr2013-06-221-2/+4
| | | | | | | | | | | (RSHIFTX): Ditto. (CLEAR_LOWBITS): Use LSHIFTX and RSHIFTX. (FILL_LOWBITS): Use LSHIFTX. Reported by ko1 via IRC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_pack): Specialized packers implemented.akr2013-06-211-3/+184
| | | | | | | | | | | | | | | | | (HOST_BIGENDIAN_P): New macro. (ALIGNOF): New macro. (CLEAR_LOWBITS): New macro. (FILL_LOWBITS): New macro. (swap_bdigit): New macro. (bary_2comp): Returns an int. * internal.h (swap16): Moved from pack.c (swap32): Ditto. (swap64): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (BDIGMAX): Use BIGRAD.akr2013-06-211-5/+5
| | | | | | | | | | | (BIGLO): Use BDIGMAX. (bigdivrem1): Ditto. (bigor_int): Ditto. (rb_big_or): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigsub_int): Use bdigit_roomof.akr2013-06-211-5/+5
| | | | | | | | | | | (bigadd_int): Ditto. (bigand_int): Ditto. (bigor_int): Ditto. (bigxor_int): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_ull2big): Refactored.akr2013-06-201-11/+11
| | | | | | | | (rb_uint2big): Useless code removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigmul1_toom3): Don't call bignorm twice.akr2013-06-201-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bignorm): Don't call bigtrunc if the result is a fixnum.akr2013-06-201-1/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_uint2big): Refactored.akr2013-06-201-11/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (dump_bignum): Use SIZEOF_BDIGITS.akr2013-06-201-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* An extra semicolon removed.akr2013-06-201-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (big2ulong): Change the return type to unsigned long.akr2013-06-201-15/+21
| | | | | | | | | | | | (rb_big2ulong_pack): Follow the above change. (rb_big2long): Ditto. (rb_big_lshift): Ditto. (rb_big_rshift): Ditto. (rb_big_aref): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_unpack_internal): Return -2 when negative overflow.akr2013-06-201-30/+55
| | | | | | | | | (bary_unpack): Set the overflowed bit if an extra BDIGIT exists. (rb_integer_unpack): Set the overflowed bit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (BIGSIZE): New macro.akr2013-06-191-4/+8
| | | | | | | | | | | (bigfixize): Use BIGSIZE. (big2ulong): Ditto. (check_shiftdown): Ditto. (rb_big_aref): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bdigit_roomof): Use SIZEOF_BDIGITS.akr2013-06-191-11/+11
| | | | | | | | | | | | | (bigfixize): Refine an ifdef condition. (rb_absint_size): Use bdigit_roomof. (rb_absint_singlebit_p): Ditto. (rb_integer_pack): Ditto. (integer_pack_fill_dd): Use BITSPERDIG. (integer_unpack_push_bits): Use BITSPERDIG, BIGLO and BIGDN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigfixize): Use rb_absint_size.akr2013-06-191-3/+3
| | | | | | | | | (check_shiftdown): Ditto. (big2ulong): Use bdigit_roomof. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_uint2big): Consider environments BDIGIT is bigger thanakr2013-06-191-8/+33
| | | | | | | | | | | long. (big2ulong): Ditto. (rb_big_aref): Ditto. (rb_big_pack): Just call rb_integer_pack. (rb_big_unpack): Just call rb_integer_unpack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (DIGSPERLONG): Don't define if BDIGIT is bigger than long.akr2013-06-191-22/+24
| | | | | | | | | | | | | | | | | | (DIGSPERLL): Don't define if BDIGIT is bigger than LONG_LONG (rb_absint_size): Consider environments BDIGIT is bigger than long. Use BIGLO and BIGDN. (rb_absint_singlebit_p): Ditto. (rb_integer_pack): Ditto. (bigsub_int): Consider environments BDIGIT is bigger than long. Use SIZEOF_BDIGITS instead of sizeof(BDIGIT). (bigadd_int): Ditto. (bigand_int): Ditto. (bigor_int): Ditto. (bigxor_int): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_aref): Apply BIGLO to ~xds[i] for environment whichakr2013-06-181-1/+1
| | | | | | | | BDIGIT is 16bit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in: Check __int128.akr2013-06-181-1/+1
| | | | | | | | | | | | | | | | | | * include/ruby/defines.h (BDIGIT_DBL): Use uint128_t if it is available. (BDIGIT): Use uint64_t if uint128_t is available. (SIZEOF_BDIGITS): Defined for above case. (BDIGIT_DBL_SIGNED): Ditto. (PRI_BDIGIT_PREFIX): Ditto. * include/ruby/ruby.h (PRI_64_PREFIX): Defined. * bignum.c (rb_big_pow): Don't use BITSPERDIG for the condition which rb_big_pow returns Float or Bignum. [ruby-dev:47413] [Feature #8509] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (nlz): Cast the result explicitly.akr2013-06-181-3/+4
| | | | | | | | (big2dbl): Don't assign BDIGIT values to int variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_xor): Non-effective code removed.akr2013-06-181-2/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_small_lshift): Renamed from bdigs_small_lshift.akr2013-06-161-9/+9
| | | | | | | | (bary_small_rshift): Renamed from bdigs_small_rshift. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (absint_numwords_bytes): Removed.akr2013-06-161-60/+0
| | | | | | | | (rb_absint_numwords): Don't call absint_numwords_bytes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (BARY_ADD): New macro.akr2013-06-161-5/+11
| | | | | | | | | | | | (BARY_SUB): Ditto. (BARY_MUL): Ditto. (BARY_DIVMOD): Ditto. (BARY_ZERO_P): Ditto. (absint_numwords_generic): Use these macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_2comp): Extracted from get2comp.akr2013-06-161-124/+148
| | | | | | | | | | | | | | | | | | | | (integer_unpack_num_bdigits): Extracted from rb_integer_unpack_internal. (bary_unpack_internal): Renamed from bary_unpack and support INTEGER_PACK_2COMP. (bary_unpack): New function to validate arguments and invoke bary_unpack_internal. (rb_integer_unpack_internal): Removed. (rb_integer_unpack): Invoke bary_unpack_internal. (rb_integer_unpack_2comp): Removed. * internal.h (rb_integer_unpack_2comp): Removed. * pack.c: Follow the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (INTEGER_PACK_2COMP): Defined.akr2013-06-161-114/+107
| | | | | | | | | | | | | | | | | | (rb_integer_pack_2comp): Removed. * bignum.c (bary_pack): Support INTEGER_PACK_2COMP. (rb_integer_pack): Invoke bary_pack directly. (rb_integer_pack_2comp): Removed. (rb_integer_pack_internal): Ditto. (absint_numwords_generic): Follow the above change. * pack.c (pack_pack): Ditto. * sprintf.c (rb_str_format): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (absint_numwords_generic): rb_funcall invocations removed.akr2013-06-161-40/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_pack) Extracted from rb_integer_pack_internal.akr2013-06-161-40/+60
| | | | | | | | (absint_numwords_generic): Use bary_pack. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_add): New function.akr2013-06-161-14/+38
| | | | | | | | | | | (bary_zero_p): Extracted from bigzero_p. (absint_numwords_generic): Use bary_zero_p and bary_add. (bary_mul): Fix an argument for bary_mul_single. (bary_divmod): Use size_t for arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bigdivrem): Use a BDIGIT variable to store the returnakr2013-06-151-5/+4
| | | | | | | | value of bigdivrem_single. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_divmod): New function.akr2013-06-151-56/+163
| | | | | | | | | | | | (absint_numwords_generic): Use bary_divmod. (bigdivrem_num_extra_words): Extracted from bigdivrem. (bigdivrem_single): Ditto. (bigdivrem_normal): Ditto. (BIGDIVREM_EXTRA_WORDS): Defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_sub): New function.akr2013-06-151-1/+16
| | | | | | | | | (absint_numwords_generic): Use bary_sub. (bigsub_core): Skip unnecessary copy. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_mul): New function.akr2013-06-151-17/+59
| | | | | | | | | | (absint_numwords_generic): Use bary_mul. (bary_mul_single): Extracted from bigmul1_single. (bary_mul_normal): Extracted from bigmul1_normal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bary_unpack): Extracted from rb_integer_unpack_internal.akr2013-06-151-30/+52
| | | | | | | | | | | | (absint_numwords_generic): Use bary_unpack. (roomof): Defined. (bdigit_roomof): Defined. (BARY_ARGS): Defined. (bary_unpack): Declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e