summaryrefslogtreecommitdiff
path: root/bignum.c
AgeCommit message (Collapse)Author
2013-06-12* bignum.c (rb_integer_unpack_2comp): New function.akr
(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* bignum.c (integer_unpack_num_bdigits_generic): Rewritten withoutakr
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* bignum.c (validate_integer_pack_format): supported_flags argumentakr
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-11* internal.h (INTEGER_PACK_NEGATIVE): Defined.akr
(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* bignum.c (validate_integer_pack_format): Don't require a word orderakr
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* bignum.c (validate_integer_pack_format): Refine error messages.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-11* bignum.c (validate_integer_pack_format): numwords argument added.akr
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* bignum.c (rb_integer_pack_internal): Renamed from rb_integer_packakr
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-10Update comment.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10Update a comment.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10Update doc.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10* bignum.c (rb_integer_pack): Returns sign instead of words.akr
(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* bignum.c (integer_unpack_num_bdigits_small: Extracted fromakr
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-09* bignum.c (absint_numwords_small): New function.akr
(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* bignum.c (absint_numwords_bytes): New function.akr
(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-09Update an error message.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-09* bignum.c (rb_absint_numwords): Return (size_t)-1 when overflow.akr
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* bignum.c (rb_absint_numwords): Renamed from rb_absint_size_in_word.akr
* 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* bignum.c (rb_integer_pack): numwords_allocated argument removed.akr
* 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* bignum.c (big2str_base_powerof2): New function.akr
(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-08* bignum.c (rb_absint_singlebit_p): New function.akr
* 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* bignum.c (rb_integer_unpack): Don't use rb_funcall if possible.akr
* 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* internal.h (INTEGER_PACK_FORCE_BIGNUM): New flag constant.akr
* 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-07Refine error messages.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07* bignum.c (integer_pack_loop_setup): word_num_nailbytes_ret argumentakr
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* bignum.c (validate_integer_pack_format): Renamed fromakr
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* bignum.c (rb_integer_pack): Arguments changed. Use flags toakr
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* bignum.c (rb_integer_pack): Renamed from rb_int_export.akr
(rb_integer_unpack): Renamed from rb_int_import. * internal.h, pack.c: Follow the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07Update comment.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07* bignum.c (integer_format_loop_setup): Extracted from rb_int_exportakr
and rb_int_import. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07* bignum.c (validate_integer_format): Extracted from rb_int_export andakr
rb_int_import. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07* bignum.c (rb_absint_size): Use numberof.akr
(rb_int_export): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07* bignum.oc (rb_absint_size): Declare a variable, i, just before usedakr
to suppress a warning. (rb_int_export): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07* bignum.c (rb_absint_size): explicit cast to BDIGIT to avoid implicitcharliesome
64 bit to 32 bit shortening warning * bignum.c (rb_int_export): ditto * bignum.c (int_import_push_bits): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07use NUM2SIZET and SIZET2NUMnobu
* configure.in: revert r41106. size_t may not be unsigned * bignum.c (rb_absint_size_in_word, rb_int_export, rb_int_import): use NUM2SIZET() and SIZET2NUM() already defined in ruby/ruby.h. * ext/-test-/bignum/export.c (rb_int_export_m): ditto. * ext/-test-/bignum/import.c (rb_int_import_m): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07* bignum.c (rb_int_import): explicitly casting BDIGIT_DBL to BDIGITmrkn
to prevent warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-06Arguments renamed.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-06* internal.h (rb_int_export): countp argument is split intoakr
wordcount_allocated and wordcount. * bignum.c (rb_int_export): Follow the above change. * pack.c (pack_pack): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-06* bignum.c (rb_int_import): New function.akr
(int_import_push_bits): Ditto. * internal.h (rb_int_import): Declared. * pack.c (pack_unpack): Use rb_int_import for BER compressed integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-06* configure.in: Invoke RUBY_REPLACE_TYPE for size_t.akr
Don't invoke RUBY_CHECK_PRINTF_PREFIX for size_t to avoid conflict with RUBY_REPLACE_TYPE. * internal.h (rb_absint_size): Declared. (rb_absint_size_in_word): Ditto. (rb_int_export): Ditto. * bignum.c (rb_absint_size): New function. (rb_absint_size_in_word): Ditto. (int_export_fill_dd): Ditto. (int_export_take_lowbits): Ditto. (rb_int_export): Ditto. * pack.c (pack_pack): Use rb_int_export for BER compressed integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05* bignum.c (big_fdiv): Use nlz() instead of bdigbitsize().akr
(bdigbitsize): Removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-04* bignum.c (rb_big_pow): Don't need to multiply SIZEOF_BDIGITS.akr
Use nlz instead of bitlength_bdigit. (bitlength_bdigit): Removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-04* bignum.c (bitlength_bdigit): Fix an off-by-one error.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-03* bignum.c (bitlength_bdigit): New function.akr
(rb_big_pow): Use bitlength_bdigit instead of ffs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-31* bignum.c: Use BDIGIT type for hbase.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-31* bignum.c (calc_hbase): Make hbase the maximum power of baseakr
representable in BDIGIT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-31* bignum.c (calc_hbase): Extracted from rb_big2str0.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-31* bignum.c: Don't hard code SIZEOF_BDIGITS for log_base(hbase).akr
(big2str_orig): hbase_numdigits argument added. (big2str_karatsuba): Ditto. (rb_big2str0): Calculate hbase_numdigits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19fix typos. Patch by k_takata.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* gc.c: support RGENGC. [ruby-trunk - Feature #8339]ko1
See this ticet about RGENGC. * gc.c: Add several flags: * RGENGC_DEBUG: if >0, then prints debug information. * RGENGC_CHECK_MODE: if >0, add assertions. * RGENGC_PROFILE: if >0, add profiling features. check GC.stat and GC::Profiler. * include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0). * array.c: add write barriers for T_ARRAY and generate sunny objects. * include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if you want to access raw pointers. If you modify the contents which pointer pointed, then you need to care write barrier. * bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects. * complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX and generate sunny objects. * rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write barriers for T_RATIONAL and generate sunny objects. * internal.h: add write barriers for RBasic::klass. * numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects. * object.c (rb_class_allocate_instance), range.c: generate sunny T_OBJECT objects. * string.c: add write barriers for T_STRING and generate sunny objects. * variable.c: add write barriers for ivars. * vm_insnhelper.c (vm_setivar): ditto. * include/ruby/ruby.h, debug.c: use two flags FL_WB_PROTECTED and FL_OLDGEN. * node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED): move flag bits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e