aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
Commit message (Collapse)AuthorAgeFilesLines
* * bignum.c (integer_unpack_num_bdigits_generic): Rewritten withoutakr2013-06-121-57/+49
| | | | | | | | | | | 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
* * bignum.c (validate_integer_pack_format): supported_flags argumentakr2013-06-121-3/+19
| | | | | | | | | | 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
* * internal.h (INTEGER_PACK_NEGATIVE): Defined.akr2013-06-111-7/+6
| | | | | | | | | | | | | | | | | | | | | (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
* * bignum.c (validate_integer_pack_format): Don't require a word orderakr2013-06-111-2/+3
| | | | | | | | | | | | | | 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
* * bignum.c (validate_integer_pack_format): Refine error messages.akr2013-06-111-2/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (validate_integer_pack_format): numwords argument added.akr2013-06-111-7/+5
| | | | | | | | | | 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
* * bignum.c (rb_integer_pack_internal): Renamed from rb_integer_packakr2013-06-111-34/+149
| | | | | | | | | | | | | | | | | | | 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
* Update comment.akr2013-06-101-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update a comment.akr2013-06-101-1/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update doc.akr2013-06-101-5/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_integer_pack): Returns sign instead of words.akr2013-06-101-21/+24
| | | | | | | | | | | | | | | | | | | | | | (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
* * bignum.c (integer_unpack_num_bdigits_small: Extracted fromakr2013-06-101-24/+89
| | | | | | | | | | | | | 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
* * bignum.c (absint_numwords_small): New function.akr2013-06-091-2/+25
| | | | | | | | (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
* * bignum.c (absint_numwords_bytes): New function.akr2013-06-091-25/+101
| | | | | | | | | (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
* Update an error message.akr2013-06-091-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_absint_numwords): Return (size_t)-1 when overflow.akr2013-06-091-22/+64
| | | | | | | | | | | | 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
* * bignum.c (rb_absint_numwords): Renamed from rb_absint_size_in_word.akr2013-06-091-2/+2
| | | | | | | | | | | | | * 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
* * bignum.c (rb_integer_pack): numwords_allocated argument removed.akr2013-06-091-36/+7
| | | | | | | | | | | | | | | | | | * 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
* * bignum.c (big2str_base_powerof2): New function.akr2013-06-091-0/+37
| | | | | | | (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
* * bignum.c (rb_absint_singlebit_p): New function.akr2013-06-081-0/+46
| | | | | | | | | | | | * 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
* * bignum.c (rb_integer_unpack): Don't use rb_funcall if possible.akr2013-06-081-12/+25
| | | | | | | | | * 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
* * internal.h (INTEGER_PACK_FORCE_BIGNUM): New flag constant.akr2013-06-081-0/+2
| | | | | | | | | | | * 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
* Refine error messages.akr2013-06-071-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (integer_pack_loop_setup): word_num_nailbytes_ret argumentakr2013-06-071-21/+10
| | | | | | | | | | 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
* * bignum.c (validate_integer_pack_format): Renamed fromakr2013-06-071-14/+14
| | | | | | | | | | | | 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
* * bignum.c (rb_integer_pack): Arguments changed. Use flags toakr2013-06-071-43/+57
| | | | | | | | | | | | | | | | | | | | | | 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
* * bignum.c (rb_integer_pack): Renamed from rb_int_export.akr2013-06-071-2/+2
| | | | | | | | | | (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
* Update comment.akr2013-06-071-4/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (integer_format_loop_setup): Extracted from rb_int_exportakr2013-06-071-72/+82
| | | | | | | | and rb_int_import. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (validate_integer_format): Extracted from rb_int_export andakr2013-06-071-22/+20
| | | | | | | | rb_int_import. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_absint_size): Use numberof.akr2013-06-071-4/+4
| | | | | | | | (rb_int_export): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.oc (rb_absint_size): Declare a variable, i, just before usedakr2013-06-071-8/+13
| | | | | | | | | 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
* * bignum.c (rb_absint_size): explicit cast to BDIGIT to avoid implicitcharliesome2013-06-071-3/+3
| | | | | | | | 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
* use NUM2SIZET and SIZET2NUMnobu2013-06-071-7/+7
| | | | | | | | | | | | | * 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
* * bignum.c (rb_int_import): explicitly casting BDIGIT_DBL to BDIGITmrkn2013-06-071-1/+1
| | | | | | to prevent warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Arguments renamed.akr2013-06-061-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (rb_int_export): countp argument is split intoakr2013-06-061-14/+13
| | | | | | | | | | | | 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
* * bignum.c (rb_int_import): New function.akr2013-06-061-1/+154
| | | | | | | | | | | (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
* * configure.in: Invoke RUBY_REPLACE_TYPE for size_t.akr2013-06-061-0/+321
| | | | | | | | | | | | | | | | | | | | | 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
* * bignum.c (big_fdiv): Use nlz() instead of bdigbitsize().akr2013-06-051-27/+4
| | | | | | | (bdigbitsize): Removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (rb_big_pow): Don't need to multiply SIZEOF_BDIGITS.akr2013-06-041-20/+2
| | | | | | | | | 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
* * bignum.c (bitlength_bdigit): Fix an off-by-one error.akr2013-06-041-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (bitlength_bdigit): New function.akr2013-06-031-1/+19
| | | | | | | | (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
* * bignum.c: Use BDIGIT type for hbase.akr2013-05-311-5/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (calc_hbase): Make hbase the maximum power of baseakr2013-05-311-6/+6
| | | | | | | | representable in BDIGIT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c (calc_hbase): Extracted from rb_big2str0.akr2013-05-311-6/+18
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * bignum.c: Don't hard code SIZEOF_BDIGITS for log_base(hbase).akr2013-05-311-8/+11
| | | | | | | | | | (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
* fix typos. Patch by k_takata.ktsj2013-05-191-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c: support RGENGC. [ruby-trunk - Feature #8339]ko12013-05-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* * bignum.c: remove redundant decl for big_lshift() big_rshift().kosaki2013-05-121-3/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e