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

413 Коммитов

Автор SHA1 Сообщение Дата
akr ecabbf1bf6 * internal.h (INTEGER_PACK_2COMP): Defined.
(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
2013-06-16 09:53:45 +00:00
akr fc3fbc143c * bignum.c (absint_numwords_generic): rb_funcall invocations removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-16 08:49:26 +00:00
akr 552c0c5aa8 * bignum.c (bary_pack) Extracted from rb_integer_pack_internal.
(absint_numwords_generic): Use bary_pack.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-16 05:33:39 +00:00
akr 7a58763dc6 * bignum.c (bary_add): New function.
(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
2013-06-16 01:41:58 +00:00
akr d631642a2e * bignum.c (bigdivrem): Use a BDIGIT variable to store the return
value of bigdivrem_single.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-15 23:56:32 +00:00
akr 00a95f15bc * bignum.c (bary_divmod): New function.
(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
2013-06-15 23:46:07 +00:00
akr 392def5b71 * bignum.c (bary_sub): New function.
(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
2013-06-15 14:52:02 +00:00
akr 988c22ea72 * bignum.c (bary_mul): New function.
(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
2013-06-15 13:32:16 +00:00
akr d1eea69b01 * bignum.c (bary_unpack): Extracted from rb_integer_unpack_internal.
(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
2013-06-15 11:15:23 +00:00
akr 78a6a6cad6 * bignum.c (absint_numwords_bytes): Make it static.
(absint_numwords_small): Ditto.
  (absint_numwords_generic): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-15 10:35:52 +00:00
akr 919cc1e53e * bignum.c (bigmul1_normal): Shrink the result Bignum length.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-15 08:15:40 +00:00
akr 6193a3148a * bignum.c (bdigs_small_rshift): Extracted from big_rshift.
(bigdivrem): Use bdigs_small_rshift.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-15 01:03:37 +00:00
akr 2b6cab544f * bignum.c (bdigs_small_lshift): Extracted from big_lshift.
(bigdivrem): Use bdigs_small_lshift.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-14 17:41:38 +00:00
akr 2f407300fa * bignum.c (bigdivrem): Reduce number of digits before bignew() for div.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-14 12:05:38 +00:00
akr 48bfbb574e * bignum.c (bigdivrem): Use bignew when ny == 1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41301 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-14 11:13:16 +00:00
akr 65575bab02 * bignum.c (bigdivrem): Zero test condition simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-13 15:15:07 +00:00
akr b4bafcb416 Use ny instead of RBIGNUM_LEN(y).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-13 13:02:34 +00:00
akr 63dd3e7ef9 * bignum.c (bigdivrem): Refactored to use ALLOCV_N for temporally
buffers.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-13 12:26:33 +00:00
usa 138bc4c0c4 * bignum.c (integer_unpack_num_bdigits_generic): reorder terms (but not
changed the intention of the expression) because VC++ reports a
  warning for it.  reported by ko1 via IRC.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-13 09:56:52 +00:00
akr db3b317ca7 * bignum.c (bigdivrem): Use nlz.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-13 09:35:05 +00:00
nobu 392d7a797a bignum.c: suppress warnings
* bignum.c (integer_unpack_num_bdigits_generic): suppress "implicit
  conversion shortens 64-bit value into a 32-bit value" warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-13 07:33:12 +00:00
akr 90026ab53f Refine debug code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-13 03:20:28 +00:00
akr 2b1c2b7223 * bignum.c (integer_unpack_num_bdigits_small): Fix a comple error on
clang -Werror,-Wshorten-64-to-32
  Reported by Eric Hodel.  [ruby-core:55467] [Bug #8522]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 21:13:56 +00:00
akr aaa1461d7b * bignum.c (rb_integer_unpack_2comp): New function.
(rb_integer_unpack_internal): Extracted from rb_integer_unpack and
  nlp_bits_ret argument added.
  (integer_unpack_num_bdigits_small): nlp_bits_ret argument added to
  return number of leading padding bits.
  (integer_unpack_num_bdigits_generic): Ditto.

* internal.h (rb_integer_unpack_2comp): Declared.

* pack.c (pack_unpack): Use rb_integer_unpack_2comp and
  rb_integer_unpack.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 15:18:00 +00:00
akr b53a183c00 * bignum.c (integer_unpack_num_bdigits_generic): Rewritten without
rb_funcall.
  (integer_unpack_num_bdigits_bytes): Removed.
  (rb_integer_unpack): integer_unpack_num_bdigits_bytes invocation
  removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 13:25:00 +00:00
akr 4e0685faea * bignum.c (validate_integer_pack_format): supported_flags argument
added and validate given flags.
  (rb_integer_pack_internal): Specify supported_flags.
  (rb_integer_unpack): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 09:21:11 +00:00
akr 0c9a719d77 * internal.h (INTEGER_PACK_NEGATIVE): Defined.
(rb_integer_unpack): sign argument removed.

* bignum.c (rb_integer_unpack): sign argument removed.
  Non-negative integers generated by default.
  INTEGER_PACK_NEGATIVE flag is used to generate non-positive integers.

* pack.c (pack_unpack): Follow the above change.

* random.c (int_pair_to_real_inclusive): Ditto.
  (make_seed_value): Ditto.
  (mt_state): Ditto.
  (limited_big_rand): Ditto.

* marshal.c (r_object0): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-11 21:39:55 +00:00
akr b23d9a8a63 * bignum.c (validate_integer_pack_format): Don't require a word order
flag if numwords is 1 or less.
  (absint_numwords_generic): Don't specify a word order for
  rb_integer_pack.

* hash.c (rb_hash): Ditto.

* time.c (v2w_bignum): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-11 14:40:16 +00:00
akr c4b12333f7 * bignum.c (validate_integer_pack_format): Refine error messages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-11 14:02:46 +00:00
akr 06b1671107 * bignum.c (validate_integer_pack_format): numwords argument added.
Move a varidation from rb_integer_pack_internal and rb_integer_unpack.
  (rb_integer_pack_internal): Follow above change.
  (rb_integer_unpack): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-11 13:28:33 +00:00
akr d5a3818f8e * bignum.c (rb_integer_pack_internal): Renamed from rb_integer_pack
and overflow_2comp argument added.
  (rb_integer_pack): Just call rb_integer_pack_internal.
  (rb_integer_pack_2comp): New function.

* internal.h (rb_integer_pack_2comp): Declared.

* sprintf.c (rb_str_format): Use rb_integer_pack and
  rb_integer_pack_2comp to format binary/octal/hexadecimal integers.
  (ruby_digitmap): Declared.
  (remove_sign_bits): Removed.
  (BITSPERDIG): Ditto.
  (EXTENDSIGN): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-11 12:06:40 +00:00
akr 46bb1a9f92 Update comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 13:51:20 +00:00
akr 780ab06a0e Update a comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 13:10:11 +00:00
akr 6735633663 Update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 10:55:08 +00:00
akr 0e8caa7d0f * bignum.c (rb_integer_pack): Returns sign instead of words.
(absint_numwords_generic): Follow the above change.
  (big2str_base_powerof2): Follow the above change.

* internal.h: Ditto.

* hash.c (rb_hash): Ditto.

* pack.c (pack_pack): Ditto.

* random.c (int_pair_to_real_inclusive): Ditto.
  (rand_init): Ditto.
  (random_load): Ditto.
  (limited_big_rand): Ditto.

* time.c (v2w_bignum): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 10:37:39 +00:00
akr 8c239f35de * bignum.c (integer_unpack_num_bdigits_small: Extracted from
rb_integer_unpack.
  (integer_unpack_num_bdigits_generic): Ditto.
  (integer_unpack_num_bdigits_bytes): New function.
  (rb_integer_unpack): Use above functions.
  Return a Bignum for INTEGER_PACK_FORCE_BIGNUM evenwhen the result
  is zero.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 03:12:44 +00:00
akr 192085bad3 * bignum.c (absint_numwords_small): New function.
(absint_numwords_generic): Use absint_numwords_small if possible.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-09 20:39:05 +00:00
akr f30d662c24 * bignum.c (absint_numwords_bytes): New function.
(absint_numwords_generic): Extracted from rb_absint_numwords.
  (rb_absint_numwords): Use absint_numwords_bytes if possible.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-09 16:08:54 +00:00
akr d395be138c Update an error message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-09 13:03:45 +00:00
akr 9cb1452318 * bignum.c (rb_absint_numwords): Return (size_t)-1 when overflow.
Refine variable names.
  (rb_absint_size): Refine variable names.

* internal.h (rb_absint_size): Refine an argument name.
  (rb_absint_numwords): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-09 12:37:38 +00:00
akr f5ad120b97 * bignum.c (rb_absint_numwords): Renamed from rb_absint_size_in_word.
* internal.h (rb_absint_numwords): Follow the above change.

* pack.c (pack_pack): Ditto.

* random.c (rand_init): Ditto.
  (limited_big_rand): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-09 07:53:20 +00:00
akr 837392b452 * bignum.c (rb_integer_pack): numwords_allocated argument removed.
* internal.h (rb_integer_pack): Follow the above change.

* hash.c (rb_hash): Ditto.

* time.c (v2w_bignum): Ditto.

* pack.c (pack_pack): Ditto.

* random.c (int_pair_to_real_inclusive): Ditto.
  (rand_init): Ditto.
  (random_load): Ditto.
  (limited_big_rand): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-09 05:53:00 +00:00
akr f6757f080c * bignum.c (big2str_base_powerof2): New function.
(rb_big2str0): Use big2str_base_powerof2 if base is 2, 4, 8, 16 or 32.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-09 00:36:58 +00:00
akr 747894a32d * bignum.c (rb_absint_singlebit_p): New function.
* internal.h (rb_absint_singlebit_p): Declared.

* time.c (v2w_bignum): Use rb_absint_singlebit_p instead of
  rb_big_abs_find_minbit.
  (rb_big_abs_find_minbit): Removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 12:05:57 +00:00
akr d35616e694 * bignum.c (rb_integer_unpack): Don't use rb_funcall if possible.
* random.c: Use uint32_t for elements of seed.
  (make_seed_value): Use rb_integer_unpack.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 07:40:03 +00:00
akr 0056591f50 * internal.h (INTEGER_PACK_FORCE_BIGNUM): New flag constant.
* bignum.c (rb_integer_unpack): Support INTEGER_PACK_FORCE_BIGNUM.

* random.c (int_pair_to_real_inclusive): Use
  INTEGER_PACK_FORCE_BIGNUM to use rb_big_mul instead of rb_funcall. 



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 06:00:04 +00:00
akr 97b5a9c102 Refine error messages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 22:16:15 +00:00
akr 8ce912bdb3 * bignum.c (integer_pack_loop_setup): word_num_nailbytes_ret argument
removed.
  (rb_integer_pack): Follow the above change.
  (rb_integer_unpack): Follow the above change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 15:56:59 +00:00
akr 3dcea601c7 * bignum.c (validate_integer_pack_format): Renamed from
validate_integer_format.
  (integer_pack_loop_setup): Renamed from integer_format_loop_setup.
  (integer_pack_fill_dd): Renamed from int_export_fill_dd.
  (integer_pack_take_lowbits): Renamed from int_export_take_lowbits.
  (integer_unpack_push_bits): Renamed from int_import_push_bits.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 15:39:07 +00:00
akr f31aed6255 * bignum.c (rb_integer_pack): Arguments changed. Use flags to
specify word order and byte order.
  (rb_integer_unpack): Ditto.
  (validate_integer_format): Follow the above change.
  (integer_format_loop_setup): Ditto.

* pack.c: Ditto.

* internal.h: Ditto.
  (INTEGER_PACK_MSWORD_FIRST): Defined.
  (INTEGER_PACK_LSWORD_FIRST): Ditto.
  (INTEGER_PACK_MSBYTE_FIRST): Ditto.
  (INTEGER_PACK_LSBYTE_FIRST): Ditto.
  (INTEGER_PACK_NATIVE_BYTE_ORDER): Ditto.
  (INTEGER_PACK_LITTLE_ENDIAN): Ditto.
  (INTEGER_PACK_BIG_ENDIAN): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 15:02:39 +00:00