Граф коммитов

473 Коммитов

Автор SHA1 Сообщение Дата
akr c72186f4c2 * bignum.c (rb_big_pow): Retry if y is a Bignum and it is
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 15:27:20 +00:00
nobu 86b65861cd * bignum.c (LSHIFTABLE): extract from LSHIFTX().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 06:27:29 +00:00
akr 1457ee2ce4 * bignum.c (bigxor_int): Fix a buffer over read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 03:49:45 +00:00
akr 9be51267b5 * bignum.c (bigand_int): Consider negative values.
(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-26 03:16:12 +00:00
akr 3ade5353e1 * bignum.c (bigand_int): Fix a buffer over read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 22:28:43 +00:00
akr 5026d0ae75 * bignum.c (bigadd_int): Fix a buffer over read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 21:53:58 +00:00
akr 4d906fbc14 * bignum.c (bigsub_int): Fix a buffer over read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 16:18:32 +00:00
akr 56435700df * bignum.c (rb_absint_singlebit_p): Use POW2_P.
(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 13:47:39 +00:00
akr 7565d728b6 * bignum.c (big2dbl): Use (BDIGIT)1 instead of 1UL.
(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 12:51:17 +00:00
akr b58230bcbd * bignum.c (big2ulong): "check" argument removed.
(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 12:19:58 +00:00
akr d4f1cc3204 * bignum.c (rb_big2ulong_pack): Use rb_integer_pack.
(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 11:10:40 +00:00
akr e4e5bc118e * bignum.c (LSHIFTX): Revert r41611.
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 10:36:14 +00:00
akr a8c226922d * bignum.c (big2ulong): Add a cast.
(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 10:04:37 +00:00
akr 8dcdfe36b7 * bignum.c (integer_unpack_single_bdigit): Use "1 + ~u" instead of
"-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 03:46:52 +00:00
akr 26dd237449 * bignum.c (big2ulong): Add code specialized for SIZEOF_LONG <=
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 03:31:20 +00:00
akr 2b93ed5e76 * bignum.c (MSB): Removed.
(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-25 03:08:23 +00:00
nobu 0a89315b83 bignum.c: suppress warning
* 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-25 02:40:11 +00:00
nobu cb2cfdd937 bignum.c: redundant expression
* 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-25 02:39:37 +00:00
akr 13f1fbc09a * bignum.c (integer_unpack_single_bdigit): Refine code to filling
higher bits and use BIGLO.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-24 14:31:49 +00:00
akr 6225d547d5 * bignum.c (BIGUP): Use LSHIFTX and avoid cast to consider the type
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 16:05:15 +00:00
akr 9310247f50 * bignum.c (integer_unpack_single_bdigit): Use a cast.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-23 08:30:49 +00:00
akr 6983595935 * bignum.c (integer_unpack_single_bdigit): Extracted from
bary_unpack_internal.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 23:20:22 +00:00
akr a53a6281cf * bignum.c (bary_unpack_internal): Suppress warnings (C4146) on Visual Studio.
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 22:43:47 +00:00
akr 93ec82ca77 * bignum.c (bytes_zero_p): Removed.
(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 16:29:43 +00:00
akr f175d5259c * bignum.c (bytes_zero_p): Extracted from bary_pack.
(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 15:52:36 +00:00
akr 31415e5809 * bignum.c (MSB): New macro.
(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-22 15:21:27 +00:00
akr b3ad6f0648 Update comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 15:02:08 +00:00
akr 6cbeb417e9 Unused code removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 14:55:31 +00:00
akr 9ab8ab38d8 * bignum.c (bary_swap): New function.
(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 14:51:48 +00:00
akr 963d678953 * bignum.c (bytes_2comp): Renamed from quad_buf_complement.
(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 14:28:50 +00:00
akr edc338875e * bignum.c (rb_integer_unpack): Don't allocate a Bignum if possible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 12:48:45 +00:00
akr 972ae3e538 * bignum.c (bary_unpack_internal): Specialized unpacker implemented.
(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 11:38:19 +00:00
akr 8f0c3ff6e4 * bignum.c (bary_pack): Support
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 09:55:27 +00:00
akr 042fe1ea91 * bignum.c (bary_pack): MEMZERO can be used even if nails is not zero.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 04:56:37 +00:00
akr d0690f97de * bignum.c (CLEAR_LOWBITS): Rewritten without RSHIFTX.
(RSHIFTX): Removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 04:12:48 +00:00
akr afb03d1646 * bignum.c (LSHIFTX): Defined to suppress a warning.
(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
2013-06-22 00:56:53 +00:00
akr 8e9c9ec8e4 * bignum.c (bary_pack): Specialized packers implemented.
(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
2013-06-21 17:22:14 +00:00
akr c54a1abde3 * bignum.c (BDIGMAX): Use BIGRAD.
(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
2013-06-21 10:40:19 +00:00
akr 6e19e1b876 * bignum.c (bigsub_int): Use bdigit_roomof.
(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
2013-06-21 10:09:34 +00:00
akr de8ca8a138 * bignum.c (rb_ull2big): Refactored.
(rb_uint2big): Useless code removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 21:45:11 +00:00
akr a0d42f0354 * bignum.c (bigmul1_toom3): Don't call bignorm twice.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 14:09:32 +00:00
akr 7e36326c06 * bignum.c (bignorm): Don't call bigtrunc if the result is a fixnum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 13:52:19 +00:00
akr 94e5fdf336 * bignum.c (rb_uint2big): Refactored.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 13:40:09 +00:00
akr ca10999c39 * bignum.c (dump_bignum): Use SIZEOF_BDIGITS.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 13:27:15 +00:00
akr 91894ab995 An extra semicolon removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 13:24:20 +00:00
akr a9c71d1139 * bignum.c (big2ulong): Change the return type to unsigned long.
(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
2013-06-20 13:23:33 +00:00
akr 6ea1aee76e * bignum.c (bary_unpack_internal): Return -2 when negative overflow.
(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
2013-06-20 13:05:27 +00:00
akr e98b7c6c52 * bignum.c (BIGSIZE): New macro.
(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
2013-06-19 23:09:05 +00:00
akr a5b0cace63 * bignum.c (bdigit_roomof): Use SIZEOF_BDIGITS.
(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
2013-06-19 16:37:14 +00:00
akr 24c9860d55 * bignum.c (bigfixize): Use rb_absint_size.
(check_shiftdown): Ditto.
  (big2ulong): Use bdigit_roomof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 14:53:01 +00:00