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

678 Коммитов

Автор SHA1 Сообщение Дата
akr 69263bb755 * bignum.c (rb_cstr_to_inum): Use power_cache_get_power.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 14:34:59 +00:00
akr d620b0b9cd * bignum.c (rb_big2str1): Raise an error for too big number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 12:05:04 +00:00
akr 780a125faf * bignum.c (power_cache_get_power): Hide cached Bignum objects.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 11:48:42 +00:00
akr 0ade4f39fd * bignum.c (rb_big2str1): Remove non-trim mode.
(rb_big2str0): Non-trim mode implemented here.
  (big2str_find_n1): Change the result type to long again.
  (big2str_base_powerof2): Don't take arguments: len and trim.
  (rb_big2str): Follow above change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 10:19:23 +00:00
akr 93055423bd * bignum.c (big2str_alloc): New function to allocate the result string.
It is called after actual length is calculated.
  (big2str_struct): Add fields: negative, result and ptr.
  (big2str_orig): Write out the result via b2s->ptr.
  (big2str_orig): Ditto.
  (rb_big2str1): Don't allocate the result string at beginning.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 03:43:14 +00:00
akr 478bd3128c * bignum.c (big2str_orig): Use temporary buffer when trim mode.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 22:38:53 +00:00
akr 39a00c6710 * bignum.c (big2str_orig): Simplified because RBIGNUM_LEN(x) <= 2 now.
(big2str_struct): Two fields added: hbase2, hbase2_numdigits.
  (rb_big2str1): Initialize above fields.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 21:33:14 +00:00
akr eed6c15a21 * bignum.c (big2str_karatsuba): Fix a condition of power_level.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 16:48:08 +00:00
nobu 278b494ba7 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 16:21:11 +00:00
akr 4f1b07e9eb * bignum.c (LOG2_KARATSUBA_BIG2STR_DIGITS): Removed.
(KARATSUBA_BIG2STR_DIGITS): Removed.
  (big2str_numdigits_cache): New variable.
  (power_cache_get_power): Merged with power_cache_get_power0.
  This function returns maxpow_in_bdigit_dbl(base)**(2**power_level).
  (rb_big2str1): use power_cache_get_power.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 16:20:26 +00:00
akr d28913b4b9 * bignum.c (big2str_find_n1): Change the return type to size_t.
(big2str_orig): Ditto.
  (big2str_karatsuba): Ditto.
  (rb_big2str1): Follow the above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 15:01:55 +00:00
akr 9e84b33564 * bignum.c (power_cache_get_power): Change numdigits_ret to size_t *.
(big2str_orig): Change len argument to size_t.
  (big2str_karatsuba): Ditto.
  (rb_big2str1): Follow the above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 14:21:54 +00:00
akr 621d2b3d6c * bignum.c (bary_cmp): Extracted from rb_big_cmp.
(power_cache_get_power): Change n1 argument (number of digits) to
  power_level which is just passed to power_cache_get_power0.
  (big2str_karatsuba): Ditto.
  (rb_big2str1): Calculate the initial power_level.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 13:42:22 +00:00
akr aba8c29a8b * bignum.c (MAX_BIG2STR_TABLE_ENTRIES): Use SIZEOF_SIZE_T.
(power_cache_get_power0): Add rb_bug call for too bit i argument.
  (power_cache_get_power): Simplified.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 10:58:58 +00:00
akr 6189859101 * bignum.c (big2str_struct): New structure.
(big2str_orig): Use big2str_struct.
  (big2str_karatsuba): Ditto.
  (rb_big2str1): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 03:20:35 +00:00
akr 16bf45bf38 * bignum.c (LOG2_KARATSUBA_BIG2STR_DIGITS): Renamed from
LOG2_KARATSUBA_DIGITS.
  (KARATSUBA_BIG2STR_DIGITS): Renamed from KARATSUBA_DIGITS.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29 13:18:46 +00:00
akr 7a9aeb33db * bignum.c (bigdivrem): Specialized implementation added for
nx == 2 && ny == 2



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28 15:14:20 +00:00
akr 37377b24d1 * bignum.c (absint_numwords_generic): The char_bit variable changed
to a static constant.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28 03:51:13 +00:00
akr aecf007782 * bignum.c: Constify bary_* functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28 03:12:36 +00:00
akr e5ff9d58ef * include/ruby/intern.h (rb_absint_size): Declaration moved from
internal.h to calculate required buffer size to pack integers.
  (rb_absint_numwords): Ditto.
  (rb_absint_singlebit_p): Ditto.
  [ruby-core:42813] [Feature #6065]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28 02:14:58 +00:00
akr 5b89a56b4f * bignum.c (rb_big_size): Return the bignum "bytewise" size.
[ruby-core:55578] [Feature #8553]
  This is accepted by matz on DevelopersMeeting20130727Japan.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-27 15:39:01 +00:00
akr a84ea11986 * bignum.c: Move functions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 11:49:25 +00:00
akr ca3f5b533d * bignum.c (bary_divmod): Add special cases for x < y easily detected
and nx == 2 && ny == 2.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 11:16:39 +00:00
akr 66cc0fa4ab * bignum.c (bary_mulsub_1xN): New function.
(bary_mul_toom3): Use bary_mulsub_1xN.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22 22:16:45 +00:00
akr fdb991b9a0 * bignum.c (KARATSUBA_BALANCED): New macro.
(TOOM3_BALANCED): Ditto.
  (bary_mul_balance_with_mulfunc): Use KARATSUBA_BALANCED and
  TOOM3_BALANCED.
  (rb_big_mul_balance): Relax a condition.
  (rb_big_mul_karatsuba): Use KARATSUBA_BALANCED.
  (rb_big_mul_toom3): Use TOOM3_BALANCED.
  (bary_mul_karatsuba_branch): Use KARATSUBA_BALANCED.
  (bary_mul_toom3_branch): Use TOOM3_BALANCED.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22 18:35:27 +00:00
akr 685e4c67bf * bignum.c (bigdivrem_mulsub): Extracted from bigdivrem1.
(bigdivrem1): Use bary_add.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22 16:36:36 +00:00
akr d3845ef8db * bignum.c (bary_sq_fast): Refine expressions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-21 15:17:09 +00:00
akr 5cf931d65e * bignum.c (bary_mul): Use simple multiplication if yl is small.
(rb_cstr_to_inum): Invoke bigsq instead of bigmul0.
  (bigsq): Re-implemented.
  (bigmul0): Invoke bigsq if two arguments are identical.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-21 12:13:47 +00:00
akr a2116ef2cd * bignum.c (bary_mul_toom3): New function based on bigmul1_toom3.
(bary_mul_toom3_branch): Call bary_mul_toom3.
  (rb_big_mul_toom3): Ditto.
  (bigmul1_toom3): Removed.
  (big_real_len): Ditto.
  (big_split): Ditto.
  (big_split3): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-21 01:01:26 +00:00
akr abfb7b35a2 Update a comment for Toom3.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-20 13:32:11 +00:00
akr 2314c1bf47 * bignum.c (bary_sq_fast): Specialize the last iteration of the
outer loop.
  (bigfixize): A condition simplified.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 12:58:46 +00:00
akr 80afc9b2f3 * bignum.c (BDIGITS_ZERO): Defined.
(bary_pack): Use BDIGITS_ZERO.
  (bary_unpack): Ditto.
  (bary_mul_single): Ditto.
  (bary_mul_normal): Ditto.
  (bary_sq_fast): Ditto.
  (bary_mul_balance_with_mulfunc): Ditto.
  (bary_mul_precheck): Ditto.
  (bary_mul_toom3_branch): Ditto.
  (rb_cstr_to_inum): Ditto.
  (big_shift3): Ditto.
  (bigmul1_toom3): Ditto.
  (bary_divmod): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-18 04:00:49 +00:00
akr 15f7c7f9d4 * bignum.c: An static assertion for relation of SIZEOF_LONG and
SIZEOF_BDIGITS is added.
  (bary_mul_precheck): Reduce comparisons.
  (bary_mul): Invoke bary_sq_fast or bary_mul1 if the bignum size is
  small.
  (bigfixize): Resize the argument bignum here.
  (bignorm): Don't call bigtrunc after bigfixize.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 13:53:24 +00:00
akr deaec24790 * bignum.c (bigmul1_toom3): Use bigdivrem_single instead of bigdivrem.
(big_three): Removed.
  (Init_Bignum): Don't initialize big_three.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 15:17:21 +00:00
akr 6be7c95734 * bignum.c (bigsq): Renamed from bigsqr.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 11:23:03 +00:00
akr a08c5527ea * bignum.c (USHORT): Unused macro removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 10:44:27 +00:00
akr 4106413465 * bignum.c (big_shift3): Big shift width is not a problem for right
shift.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 10:08:25 +00:00
akr c0cce2938c * bignum.c (bary_mul_karatsuba): Avoid duplicate calculation when
squaring.
  ((bary_mul_toom3_branch): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 09:37:42 +00:00
akr a38f209a39 Fix spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 12:56:29 +00:00
akr 46360975a4 * include/ruby/intern.h (rb_big2str0): Deprecated.
* bignum.c (rb_big2str1): Renamed from rb_big2str0.
  (rb_big2str0): Deprecated wrapper for rb_big2str1.
  (rb_big2str): Invoke rb_big2str1 instead of rb_big2str0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 05:42:22 +00:00
akr 1a42f3683f * bignum.c: Add static assertions.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 04:50:49 +00:00
akr a5da8319b6 * bignum.c (maxpow_in_bdigit_dbl): Useless #if removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 02:26:24 +00:00
zzak b39b66f4aa * bignum.c (rb_big_coerce): [DOC] Add docs for Bignum#coerce
Based on patch by Juanito Fatas [Fixes GH-360]
  https://github.com/ruby/ruby/pull/360


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 02:13:13 +00:00
nobu e068834b5c bignum.c: suppress warnings
* bignum.c (big_shift2, rb_big_lshift, rb_big_rshift): cast explicitly
  to suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 02:11:15 +00:00
akr 150b265502 * bignum.c (nlz16): Use __builtin_clz if possible.
(nlz32): Use __builtin_clz or __builtin_clzl if possible.
  (nlz64): Use __builtin_clzl or __builtin_clzll if possible.
  (nlz128): Use __builtin_clzll if possible.

* configure.in: Check __builtin_clz, __builtin_clzl and
  __builtin_clzll.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 01:49:32 +00:00
akr 508669b6da * bignum.c (power_cache_get_power): Use bitsize insteadof ceil_log2.
(ones): Removed.
  (next_pow2): Removed.
  (floor_log2): Removed.
  (ceil_log2): Removed.

* configure.in (__builtin_popcountl): Don't check.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 00:46:00 +00:00
akr 240f3056aa * configure.in: Check __builtin_popcountl, __builtin_bswap32 and
__builtin_bswap64.

* internal.h (swap32): Use the configure result for the condition to
  use __builtin_bswap32.
  (swap64): Use the configure result for the condition to use
  __builtin_bswap64.

* bignum.c (ones): Use the configure result for the condition to use
  __builtin_popcountl.
  (bary_unpack_internal): Use appropriate types for swap argument.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-14 14:28:33 +00:00
akr b0eacd027a * bignum.c (bary_subb): Support xn < yn.
(bigsub_core): Removed.
  (bigsub): Don't compare before subtraction.  Just subtract and
  get the two's complement if the subtraction causes a borrow.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-14 13:24:44 +00:00
akr 651f762c17 * bignum.c (DIGSPERLONG): Unused macro removed.
(DIGSPERLL): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:38:52 +00:00
akr 75a86e4733 * bignum.c (rb_big_aref): Less scan when the number is negative.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:36:18 +00:00
akr b9eeeac5c8 * bignum.c (big_shift): Avoid signed integer overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:19:48 +00:00
akr f9029004ee * bignum.c (bary_mul_precheck): Use bary_small_lshift or
bary_mul_normal if xl is 1.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 15:16:23 +00:00
akr de79b66f46 * bignum.c (big_shift3): New function.
big_lshift and big_rshift are merged.
  (big_shift2): New function.
  (big_lshift): Use big_shift3.
  (big_rshift): Ditto.
  (check_shiftdown): Removed.
  (rb_big_lshift): Use big_shift2 and big_shift3.
  (rb_big_rshift): Ditto.
  (big_lshift): Removed.
  (big_rshift): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 14:03:13 +00:00
akr 0001cf6bdc * bignum.c (bary_small_lshift): Use size_t instead of long.
(bary_small_rshift): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 06:53:12 +00:00
akr e31c9896d6 * 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
2013-07-13 06:36:40 +00:00
akr 725bc0c870 * bignum.c (biglsh_bang): Removed.
(bigrsh_bang): Ditto.
  (bigmul1_toom3): Use bary_small_lshift and bary_small_rshift.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-13 00:28:10 +00:00
akr 973d855391 * bignum.c: Don't use toom3 after once karatsuba is choosen.
(mulfunc_t): New type.
  (bary_mul_toom3_start): Renamed from bary_mul.
  (bary_mul_karatsuba_start): Renamed from bary_mul.
  (bary_mul_balance_with_mulfunc): Renamed from bary_mul_balance and
  new argument, mulfunc, is added.
  (rb_big_mul_balance): Invoke bary_mul_balance_with_mulfunc with
  bary_mul_toom3_start.
  (bary_mul_karatsuba): Invoke bary_mul_karatsuba_start instead of
  bary_mul.
  (bary_mul_precheck): Extracted from bary_mul.
  (bary_mul_karatsuba_branch): Extracted from bary_mul.
  (bary_mul_karatsuba_start): New function to call bary_mul_precheck
  and bary_mul_karatsuba_branch.
  (bary_mul_toom3_branch): Extracted from bary_mul.
  (bary_mul_toom3_start): New function to call bary_mul_precheck and
  bary_mul_toom3_branch.
  (bary_mul): Just call bary_mul_toom3_start.
  Arguments for work memory are removed.
  (rb_cstr_to_inum): Follow the bary_mul change.
  (bigmul0): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-11 03:06:02 +00:00
akr c0796c36b5 * bignum.c: Add a static assertion for RBIGNUM_EMBED_LEN_MAX.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 13:46:38 +00:00
akr 55e60d05dc * bignum.c (bary_2comp): Don't use bary_plus_one.
(bary_add_one): Replaced by the implementation of bary_plus_one.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 13:06:33 +00:00
nobu c37e6ab28d bignum.c: sizeof_bdigit_dbl
* bignum.c (sizeof_bdigit_dbl): check sizeof(BDIGIT_DBL).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 11:48:24 +00:00
akr 716c93bed1 * bignum.c (SIZEOF_BDIGIT_DBL): Add a ifdef guard for test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 11:10:05 +00:00
nobu cc47b02969 bignum.c: select by preprocessor conditions
* bignum.c (maxpow_in_bdigit_dbl, maxpow_in_bdigit): select by
  preprocessor conditions to reduce dead code and suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 05:58:45 +00:00
akr 5ec8b6e78e * bignum.c (bary_mul): x*1 is x.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09 15:43:48 +00:00
akr 55cbeefb2d * bignum.c (bary_mul_single): Invoke MEMZERO here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09 13:44:49 +00:00
akr 0c620c2ec3 * bignum.c (bary_mul1): No need to invoke MEMZERO at last.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09 13:19:59 +00:00
akr fa343a796f * bignum.c (biglsh_bang): Don't shift a BDIGIT with BITSPERDIG bits.
(bigrsh_bang): Ditto.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 16:50:04 +00:00
akr fa1e85c933 * bignum.c (bigrsh_bang): Fix bignum digits overrun.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 16:19:18 +00:00
akr be2a1ad45b * bignum.c (biglsh_bang): Fix bignum digits under-run.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 15:48:09 +00:00
akr 1ffdd828b3 * bignum.c (bary_mul): Arguments for work memory added.
(bary_mul_balance): Ditto.
  (bary_mul_karatsuba): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 13:44:34 +00:00
akr 6fdad008a2 * bignum.c (rb_big_sq_fast): New function for testing.
(rb_big_mul_toom3): Ditto.

* internal.h (rb_big_sq_fast): Declared.
  (rb_big_mul_toom3): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 13:05:57 +00:00
akr 85855a2242 * bignum.c (bary_mul_balance): Initialize a local variable to suppress
a warning.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 13:00:11 +00:00
akr ffe55cdc1e * bignum.c (bary_mul_balance): Reduce work memory.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-08 11:56:55 +00:00
akr a25f95f8b7 * bignum.c (bary_mul): Add a RB_GC_GUARD.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 23:04:25 +00:00
akr 1210743cad * bignum.c (bary_mul_karatsuba): Unreachable code removed. Remove
several branches.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 15:21:26 +00:00
akr 29634bca31 * internal.h (rb_big_mul_normal): Declared.
(rb_big_mul_balance): Ditto.
  (rb_big_mul_karatsuba): Ditto.

* bignum.c (rb_big_mul_normal): New function for tests.
  (rb_big_mul_balance): Ditto.
  (rb_big_mul_karatsuba): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 14:01:40 +00:00
akr d7c2f3f8a4 Useless comment removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 11:04:07 +00:00
akr 42d6020059 * bignum.c: Reorder functions to decrease forward reference.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 11:02:47 +00:00
akr 8dbf566094 * bignum.c: (bigsub_core): Use bary_sub.
(bary_sub): Returns a borrow flag.  Use bary_subb.
  (bary_subb): New function for actually calculating subtraction with
  borrow.
  (bary_sub_one): New function.
  (bigadd_core): Use bary_add.
  (bary_add): Returns a carry flag.  Use bary_addc.
  (bary_addc): New function for actually calculating addition with
  carry.
  (bary_add_one): New function.
  (bary_muladd_1xN): Extracted from bary_mul_normal.
  (bigmul1_normal): Removed.
  (bary_mul_karatsuba): New function.
  (bary_mul1): Invoke rb_thread_check_ints after bary_mul_normal.
  (bary_mul): Remove most and least significant zeros before actual
  multiplication.  Use bary_sq_fast, bary_mul_balance,
  bary_mul_karatsuba and bigmul1_toom3 as bigmul0.
  (bigmul1_balance): Removed.
  (bigmul1_karatsuba): Removed.
  (bigsqr_fast): Removed.
  (bary_sparse_p): Extracted from big_sparse_p.
  (big_sparse_p): Removed.
  (bigmul0): Use bary_mul.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 06:03:52 +00:00
akr b2cf5f36b9 * bignum.c (bary_sq_fast): Extracted from bigsqr_fast and
ensure not to access zds[2*xn].
  (bigsqr_fast): Allocate the result bignum with 2*xn words.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-07 01:22:55 +00:00
akr c97c78501f * bignum.c (BARY_MUL1): Renamed from BARY_MUL.
(bary_mul1): Renamed from bary_mul.
  (bary_mul): Renamed from bary_mul2.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04 21:04:21 +00:00
akr c311134319 * bignum.c (bary_mul_balance): Extracted from bigmul1_balance and
use bary_mul2 and bary_add to decrease allocations.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04 20:31:01 +00:00
nobu 4e681d978a bignum.c: constify
* bignum.c: constify maxpow tables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04 14:41:26 +00:00
akr 313cdec1bc * bignum.c (maxpow_in_bdigit_dbl): Use tables if available.
(maxpow_in_bdigit): Ditto.
  (U16): New macro.
  (U32): Ditto.
  (U64): Ditto.
  (U128): Ditto.
  (maxpow16_exp): New table.
  (maxpow16_num): New table.
  (maxpow32_exp): New table.
  (maxpow32_num): New table.
  (maxpow64_exp): New table.
  (maxpow64_num): New table.
  (maxpow128_exp): New table.
  (maxpow128_num): New table.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04 11:23:46 +00:00
akr fd8f2338e9 * bignum.c (rb_cstr_to_inum): Avoid temporary buffer allocation except
very big base non-power-of-2 numbers.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-04 09:38:11 +00:00
akr b2be623240 * internal.h (ruby_digit36_to_number_table): Declared.
* util.c (ruby_digit36_to_number_table): Moved from scan_digits.

* bignum.c (conv_digit): Use ruby_digit36_to_number_table.

* pack.c (hex2num): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-03 13:32:14 +00:00
akr c4107e71c5 * bignum.c (maxpow_in_bdigit): Renamed from calc_hbase and return
maxpow.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-03 03:08:52 +00:00
akr c78826190f * bignum.c (roomof): Cast to long.
(rb_ull2big): Fix bignew arguments.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02 14:49:06 +00:00
charliesome d74bb62dcc * bignum.c (rb_cstr_to_inum): fix 64 bit to 32 bit shorten warning
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02 13:16:35 +00:00
akr 4658478ae1 * bignum.c (rb_cstr_to_inum): Merge two temporary buffers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02 12:20:00 +00:00
akr 2ade221827 * bignum.c (rb_cstr_to_inum): Use BDIGIT_DBL to collect adjacent digits.
(BDIGIT_DBL_MAX): New macro.
  (maxpow_in_bdigit_dbl): New function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-02 11:52:13 +00:00
akr df1192edf5 * bignum.c (bary_mul2): New function.
(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 13:59:50 +00:00
akr 551fe2bddc * bignum.c (rb_cstr_to_inum): Skip leading zeros.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-01 03:04:07 +00:00
akr 98a8c820c7 * bignum.c (nlz16): New function.
(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 16:01:53 +00:00
akr 305f06c7e3 * bignum.c (rb_cstr_to_inum): Use rb_integer_unpack if base is a power
of 2.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-30 13:16:08 +00:00
akr b1e052d080 * bignum.c (big_rshift): Use abs2twocomp and twocomp2abs_bang.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29 16:58:58 +00:00
akr 7251c93cb3 * bignum.c (RBIGNUM_SET_NEGATIVE_SIGN): New macro.
(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 15:57:07 +00:00
akr 1522375b99 * bignum.c (bary_neg): Extracted from bary_2comp.
(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 14:38:26 +00:00
akr 69f1a3351f * bignum.c (bary_2comp): Simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29 13:33:40 +00:00
akr c6cb7416d2 * bignum.c (bigor_int): Return -1 if y == -1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-29 00:35:57 +00:00
akr f0454052f7 * bignum.c (bigor_int): Use RB_GC_GUARD.
(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-29 00:08:47 +00:00
akr 88430941c8 * bignum.c (bigand_int): Don't apply bitwise and for BDIGIT and long.
(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 23:21:57 +00:00
akr b83b33eef0 * bignum.c (rb_big_and): Allocate new bignum with same size to shorter
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-28 03:35:39 +00:00
akr 43e4de376b * bignum.c (bigand_int): Add arguments, xn and hibitsx.
Use twocomp2abs_bang.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-27 23:07:59 +00:00
akr ef18728433 * bignum.c (abs2twocomp_bang): Removed.
(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 14:59:50 +00:00
akr cd6912a595 * bignum.c (get2comp): Use bary_2comp.
(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-27 13:54:02 +00:00
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