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

209 Коммитов

Автор SHA1 Сообщение Дата
nobu e02186f526 random.c: get rid of blocking
* random.c (fill_random_bytes_syscall): get rid of blocking when
  no entropy is available.  based on the patch by mame in
  [ruby-core:70114].  [Bug #11395]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-25 12:03:50 +00:00
kazu b091903c5c fix compile error with clang
* random.c (fill_random_bytes_syscall): fix compile error with
  clang. [ruby-core:69931] [Bug #11343]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-14 15:01:39 +00:00
kazu 4f66d02c97 * random.c (fill_random_bytes_syscall): fix compile error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07 09:21:11 +00:00
normal 50c0a20025 random.c: fix failures on old Linux
This follows the behavior of fill_random_bytes_urandom and fixes
the following failures I encountered on my old machine:

1) Error:
TestSecureRandom#test_s_random_bytes_without_openssl:
NotImplementedError: No random device
    $RUBYDIR/lib/securerandom.rb:66:in `gen_random'
    $RUBYDIR/lib/securerandom.rb:94:in `random_bytes'
    $RUBYDIR/test/test_securerandom.rb:12:in `test_s_random_bytes'
    $RUBYDIR/test/test_securerandom.rb:97:in `block in test_s_random_bytes_without_openssl'
    $RUBYDIR/lib/tmpdir.rb:88:in `mktmpdir'
    $RUBYDIR/test/test_securerandom.rb:85:in `test_s_random_bytes_without_openssl'

  2) Error:
TestSecureRandom#test_s_urlsafe_base64:
NotImplementedError: No random device
    $RUBYDIR/lib/securerandom.rb:66:in `gen_random'
    $RUBYDIR/lib/securerandom.rb:94:in `random_bytes'
    $RUBYDIR/lib/securerandom.rb:164:in `urlsafe_base64'
    $RUBYDIR/test/test_securerandom.rb:131:in `block in test_s_urlsafe_base64'
    $RUBYDIR/test/test_securerandom.rb:130:in `times'
    $RUBYDIR/test/test_securerandom.rb:130:in `test_s_urlsafe_base64'

  3) Error:
TestSecureRandom#test_uuid:
NotImplementedError: No random device
    $RUBYDIR/lib/securerandom.rb:66:in `gen_random'
    $RUBYDIR/lib/securerandom.rb:94:in `random_bytes'
    $RUBYDIR/lib/securerandom.rb:230:in `uuid'
    $RUBYDIR/test/test_securerandom.rb:160:in `test_uuid'

* random.c (fill_random_bytes_syscall): return -1 for error
* random.c (fill_random_bytes): try urandom on syscall failure

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07 07:46:29 +00:00
nobu bcd96d92f3 random.c: try getrandom
* random.c (fill_random_bytes_syscall): try getrandom system call
  on Linux if supported by the kernel.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07 06:26:06 +00:00
nobu e96955e8f6 random.c: separate fill_random_bytes
* random.c (fill_random_bytes): separate into functions by system
  call and by direct read of urandom device.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07 06:25:55 +00:00
nobu f9c2adf310 random.c: refactor
* random.c (fill_random_bytes): separate non-raced and raced
  conditions, on Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-25 06:32:23 +00:00
nobu 5e132260c4 random.c: fix handle to release
* random.c (fill_random_bytes): release the handle in the static
  variable, not a local variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-19 01:31:03 +00:00
nobu c7988fd29d ruby.h: suppress false warnings
* include/ruby/ruby.h (rb_data_object_alloc_warning): enable only
  if __builtin_choose_expr works with __builtin_constant_p so that
  warnings will be suppressed if klass is 0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-16 07:49:27 +00:00
nobu 5d09df3273 ruby.h: suppress false warnings
* include/ruby/ruby.h (rb_data_object_alloc_warning): enable only
  if __builtin_choose_expr works with __builtin_constant_p so that
  warnings will be suppressed if klass is 0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-16 07:47:48 +00:00
odaira 270630c628 * random.c (random_raw_seed): Avoid calling fill_random_bytes()
if the requested size is 0. AIX returns -1 for 0-byte read from
/dev/urandom, while other UNIX returns 0. With this change,
Random.raw_seed(0) consistently retuns "" in any UNIX.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-04 23:44:59 +00:00
nobu 3bc9d1d0f4 random.c: suppress a warning
* random.c (fill_random_bytes): use ATOMIC_SIZE_CAS to suppress a
  strict-aliasing warning by gcc 4.9 for mingw.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-15 03:23:36 +00:00
nobu 10a9807030 random.c: ArgumentError for invalid argument
* random.c (rand_random_number): raise ArgumentError for invalid
  argument like as SecureRandom.random_number.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-14 05:40:10 +00:00
nobu dd09b5bf1d random.c: allow negative argument to random_number
* random.c (rand_random_number): allow negative argument as it is
  allowed by SecureRandom.random_number.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-14 04:11:26 +00:00
nobu b1adbd14e5 random.c: rand_random_number
* random.c (rand_random_number): add a method to return a random
  number like SecureRandom to Random::Formatter.
* lib/securerandom.rb (random_bytes): move to Random::Formatter,
  the base method of the module.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-14 03:20:04 +00:00
nobu 03af53f559 random.c: use PRIsVALUE
* random.c (rand_random): use PRIsVALUE to format an error
  message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-14 03:02:05 +00:00
nobu eeeb7ae8c0 random.c: Random.raw_seed
* random.c (random_raw_seed): extract platform dependent random
  seed initialization function as a new method Random.raw_seed.
* lib/securerandom.rb (SecureRandom): use Random.raw_seed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-14 03:01:36 +00:00
nobu e580a631be use 0 for reserved
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 06:38:04 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
nobu 90173785a8 random.c: fix casts
* random.c (fill_random_seed): fix type to cast.  this may or may
  not suppress warnings by icc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-09 14:51:26 +00:00
nobu 876bfc6b4e Init functions don't need ID caches
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-03 03:38:10 +00:00
akr 3c99764bcd * internal.h: Rename macro names: RBIGNUM_FOO to BIGNUM_FOO.
(BIGNUM_EMBED_LEN_NUMBITS): Renamed from RBIGNUM_EMBED_LEN_NUMBITS.
  (BIGNUM_EMBED_LEN_MAX): Renamed from RBIGNUM_EMBED_LEN_MAX.
  (BIGNUM_SIGN_BIT): Renamed from RBIGNUM_SIGN_BIT.
  (BIGNUM_SIGN): Renamed from RBIGNUM_SIGN.
  (BIGNUM_SET_SIGN): Renamed from RBIGNUM_SET_SIGN.
  (BIGNUM_POSITIVE_P): Renamed from RBIGNUM_POSITIVE_P.
  (BIGNUM_NEGATIVE_P): Renamed from RBIGNUM_NEGATIVE_P.
  (BIGNUM_EMBED_FLAG): Renamed from RBIGNUM_EMBED_FLAG.
  (BIGNUM_EMBED_LEN_MASK): Renamed from RBIGNUM_EMBED_LEN_MASK.
  (BIGNUM_EMBED_LEN_SHIFT): Renamed from RBIGNUM_EMBED_LEN_SHIFT.
  (BIGNUM_LEN): Renamed from RBIGNUM_LEN.
  (RBIGNUM_DIGITS): Renamed from RBIGNUM_DIGITS.
  (BIGNUM_LENINT): Renamed from RBIGNUM_LENINT.

* bignum.c: Follow the above change.

* gc.c: Ditto.

* marshal.c: Ditto.

* math.c: Ditto.

* numeric.c: Ditto.

* random.c: Ditto.

* rational.c: Ditto.

* sprintf.c: Ditto.

* ext/-test-/bignum/bigzero.c: Ditto.

* ext/-test-/bignum/intpack.c: Ditto.

* ext/bigdecimal/bigdecimal.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-15 21:17:34 +00:00
akr ced9ad5ab5 * random.c (rand_init): Make it possible to specify arbitrary array
for init_genrand().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-20 11:05:38 +00:00
ko1 c5e08b764e * add RUBY_TYPED_FREE_IMMEDIATELY to data types which only use
safe functions during garbage collection such as xfree().
  On default, T_DATA objects are freed at same points as fianlizers.
  This approach protects issues such as reported by [ruby-dev:35578].
  However, freeing T_DATA objects immediately helps heap usage.
  Most of T_DATA (in other words, most of dfree functions) are safe.
  However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default
  for safety.
* cont.c: ditto.
* dir.c: ditto.
* encoding.c: ditto.
* enumerator.c: ditto.
* error.c: ditto.
* file.c: ditto.
* gc.c: ditto.
* io.c: ditto.
* iseq.c: ditto.
* marshal.c: ditto.
* parse.y: ditto.
* proc.c: ditto.
* process.c: ditto.
* random.c: ditto.
* thread.c: ditto.
* time.c: ditto.
* transcode.c: ditto.
* variable.c: ditto.
* vm.c: ditto.
* vm_backtrace.c: ditto.
* vm_trace.c: ditto.
* ext/bigdecimal/bigdecimal.c: ditto.
* ext/objspace/objspace.c: ditto.
* ext/stringio/stringio.c: ditto.
* ext/strscan/strscan.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 11:16:54 +00:00
mame e7f484d469 * random.c (make_seed_value): a local array declaration was accessed
out of scope.  Coverity Scan found this bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-02 12:41:08 +00:00
ko1 dc626dbab3 * include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
  usecase of this macro is not acquire raw pointer, but acquire
  read-only pointer. So we rename to better name.
  RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
  (I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
  string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
  catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 08:24:34 +00:00
nobu 26feae3958 random.c: coerce before check negative
* random.c (rb_random_ulong_limited): coerce before check negative.
  [Fixes GH-379]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-13 13:13:02 +00:00
ko1 8741a39777 * random.c (random_load): use RARRAY_RAWPTR() instead of
RARRAY_PTR() because there is no new reference.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-07 04:20:56 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
akr e39523b77b * random.c (rand_int): Use rb_big_uminus.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-11 22:33:01 +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 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 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
charliesome 6c5000b5f1 * random.c (limited_big_rand): declare rnd, lim and mask as uint32_t
to avoid 64 bit to 32 bit shorten warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 10:33:05 +00:00
akr 14140eb16b * random.c: Unused RBignum internal accessing macros removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 10:07:05 +00:00
akr a76abae51d * random.c (limited_big_rand): The argument, limit, is changed to
VALUE.  Use rb_integer_pack and rb_integer_unpack.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 10:05:37 +00:00
akr 483cbff8dc * random.c (make_seed_value): Fix the length given for
rb_integer_unpack.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 08:15:51 +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 8a1609040e * random.c (rand_init): Add a cast to fix clang compile error:
random.c:410:32: error: implicit conversion loses integer precision:
  'size_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
  This cast doesn't cause a problem because len is not bigger than
  MT_MAX_STATE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 07:01:19 +00:00
akr ccce83c454 * random.c (rand_init): Use rb_integer_pack.
(roomof): Removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 06:46:45 +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 6b5be413bb * random.c (int_pair_to_real_inclusive): Use rb_funcall instead of
rb_big_mul because rb_integer_unpack can return a Fixnum.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 03:01:33 +00:00
akr 8ca1e1238e * random.c (int_pair_to_real_inclusive): Use rb_integer_pack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 02:18:14 +00:00
akr 479b17ed12 * random.c (int_pair_to_real_inclusive): Use rb_integer_unpack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-08 00:50:40 +00:00
akr 9ebd008f32 * random.c (random_load): Use rb_integer_pack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 23:12:55 +00:00
akr b0f14c8b58 * random.c (numberof): Removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 21:16:12 +00:00
akr 8bc16423cc * random.c: include internal.h.
(mt_state): Use rb_integer_unpack.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 21:01:42 +00:00
akr 99638b5d1f * random.c (int_pair_to_real_inclusive): Add a cast to BDIGIT.
(random_load): Fix shift width for fixnums.
  Re-implement bignum extraction without ifdefs.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 11:07:05 +00:00
ko1 4f401816ff * gc.c: support RGENGC. [ruby-trunk - Feature #8339]
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
2013-05-13 18:07:47 +00:00