summaryrefslogtreecommitdiff
path: root/random.c
AgeCommit message (Collapse)Author
2013-06-07* random.c (random_load): Use rb_integer_pack.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07* random.c (numberof): Removed.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07* random.c: include internal.h.akr
(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-05* random.c (int_pair_to_real_inclusive): Add a cast to BDIGIT.akr
(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-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
2013-05-13* include/ruby/ruby.h: constify RBasic::klass and addko1
RBASIC_CLASS(obj) macro which returns a class of `obj'. This change is a part of RGENGC branch [ruby-trunk - Feature #8339]. * object.c: add new function rb_obj_reveal(). This function reveal interal (hidden) object by rb_obj_hide(). Note that do not change class before and after hiding. Only permitted example is: klass = RBASIC_CLASS(obj); rb_obj_hide(obj); .... rb_obj_reveal(obj, klass); TODO: API design. rb_obj_reveal() should be replaced with others. TODO: modify constified variables using cast may be harmful for compiler's analysis and optimizaton. Any idea to prohibt inserting RBasic::klass directly? If rename RBasic::klass and force to use RBASIC_CLASS(obj), then all codes such as `RBASIC(obj)->klass' will be compilation error. Is it acceptable? (We have similar experience at Ruby 1.9, for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)". * internal.h: add some macros. * RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal object. * RBASIC_SET_CLASS(obj, cls) set RBasic::klass. * RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS without write barrier (planned). * RCLASS_SET_SUPER(a, b) set super class of a. * array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c, file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c, parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c, string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c: Use above macros and functions to access RBasic::klass. * ext/coverage/coverage.c, ext/readline/readline.c, ext/socket/ancdata.c, ext/socket/init.c, * ext/zlib/zlib.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* random.c: Document Random::DEFAULT by @eLobato [Fixes GH-304]zzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-16* configure.in: check struct timeval exist or not.kosaki
* include/ruby/missing.h (struct timeval): check HAVE_STRUCT_TIMEVAL properly. and don't include sys/time.h if struct timeval exist. * file.c: include sys/time.h explicitly. * random.c: ditto. * thread_pthread.c: ditto. * time.c: ditto. * ext/date/date_strftime.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-24random.c: increase limit for generic randnobu
* random.c (rb_random_ulong_limited): limit is inclusive, but generic rand method should return a number less than it, so increase for the difference. [ruby-core:52779] [Bug #7935] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-22random.c: fix error messagenobu
* random.c (rb_random_ulong_limited): fix error message for negative value. [ruby-dev:47061] [Bug #7903] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-03* random.c: Document range argument for Kernel#rand.zzak
[ruby-core:51794] [Bug #7770] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-03random.c, rational.c: make marshal methods privatenobu
* random.c (Init_Random), rational.c (Init_Rational): make marshal methods private. [Feature #6539] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09random.c: BYTE_ORDERnobu
* random.c (BYTE_ORDER): define using configured WORDS_BIGENDIAN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09siphashnobu
* random.c (rb_memhash): use siphash. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20* include/ruby/ruby.h: add C APIs.nari
VALUE rb_newobj_of(VALUE klass, VALUE flags) #define NEWOBJ_OF(obj,type,klass,flags) These allow to change a allocation strategy depending on klass or flags. * gc.c: ditto * array.c: use new C API. * bignum.c: ditto * class.c: ditto * complex.c: ditto * ext/socket/ancdata.c: ditto * ext/socket/option.c: ditto * hash.c: ditto * io.c: ditto * marshal.c: ditto * numeric.c: ditto * object.c: ditto * random.c: ditto * range.c: ditto * rational.c: ditto * re.c: ditto * string.c: ditto * struct.c: ditto [Feature #7177][Feature #7047] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-09random.c: rb_random_ulong_limitednobu
* random.c (rb_random_ulong_limited): new function to return a random value from 0 upto limit as unsigned long, simillary to rb_genrand_ulong_limited but with arbitrary RNG object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23* include/ruby/ruby.h: introduce flonum technique forko1
64bit CPU environment (sizeof(double) == sizeof(VALUE)). flonum technique enables to avoid double object creation if the double value d is in range about between 1.72723e-77 < |d| <= 1.15792e+77 or 0.0. flonum Float value is immediate and their lowest two bits are b10. If flonum is activated, then USE_FLONUM macro is 1. I'll write detailed in this technique on https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/Flonum_tech * benchmark/bmx_temp.rb: add an benchmark for simple Float calculation. * gc.c (id2ref, rb_obj_id): add flonum Float support. * include/ruby/intern.h: move decl of rb_float_new(double) to include/ruby/ruby.h. * insns.def, vm.c, vm_insnhelper.c: add flonum optimization and simplify source code. * vm_insnhelper.h (FLONUM_2_P): added. * marshal.c: support flonum output. * numeric.c (rb_float_new_in_heap): added. * parse.y: support flonum. * random.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-20random.c: refine error messagenobu
* random.c (rb_random_real): refine error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-22random.c: check initialize and loadnobu
* random.c (random_init, random_load): cannot initialize frozen object again, nor with tainted/untrusted object. [Bug #6540] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-19* random.c (rb_random_int32): get rid of "warning: constant 0x100000000kosaki
is so big it is long" warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05obj_init_copynobu
* object.c (rb_obj_init_copy): should check if trusted too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-19 * random.c (random_init): Clarify that the default seed isdrbrain
Random.new_seed, not zero. Based on patch by Roger Pack. [ruby-trunk - Bug #6313] * random.c (rb_f_srand): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14* include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]marcandre
* array.c: Use rb_check_arity / rb_error_arity * class.c: ditto * enumerator.c: ditto * eval.c: ditto * file.c: ditto * hash.c: ditto * numeric.c: ditto * proc.c: ditto * process.c: ditto * random.c: ditto * re.c: ditto * signal.c: ditto * string.c: ditto * struct.c: ditto * transcode.c: ditto * vm_eval.c: ditto * vm_insnhelper.c: ditto & implementation of rb_error_arity * test/ruby/test_arity.rb: tests for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-11* random.c (Init_Random): removed rb_Random_DEFAULT and register asnobu
mark-object instead of global variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-11* random.c (random_s_rand): ensure default PRNG is re-initializednobu
after fork. patched by Eric Wong. [ruby-core:41209][Bug #5661] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-18* random.c: remove a duplicated comment.mrkn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29* process.c (ruby_setsid): use rb_cloexec_open.akr
(rb_daemon): ditto. * ruby.c (load_file_internal): ditto. * file.c (rb_file_s_truncate): ditto. (file_load_ok): ditto. * random.c (fill_random_seed): ditto. * ext/pty/pty.c (chfunc): ditto. (get_device_once): ditto. * ext/io/console/console.c (console_dev): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-22* include/ruby/intern.h (rb_fd_set_cloexec): declared.akr
* io.c (rb_fd_set_cloexec): new function. (ruby_dup): call rb_fd_set_cloexec to set close-on-exec flag. (rb_sysopen_internal): ditto. (rb_pipe): ditto. (io_reopen): ditto. (io_cntl): ditto. * process.c (rb_f_exec): change the default :close_others option to true. (rb_f_system): ditto. (move_fds_to_avoid_crash): call rb_fd_set_cloexec to set close-on-exec flag. (ruby_setsid): ditto. (rb_daemon): ditto. * thread_pthread.c (rb_thread_create_timer_thread): call rb_fd_set_cloexec to set close-on-exec flag. * ruby.c (load_file_internal): ditto. * file.c (rb_file_s_truncate): ditto. (file_load_ok): ditto. * random.c (fill_random_seed): ditto. * ext/pty/pty.c (chfunc): ditto. (get_device_once): ditto. * ext/openssl/ossl_bio.c (ossl_obj2bio): ditto. * ext/socket/init.c (rsock_socket): ditto. (rsock_s_accept_nonblock): ditto. (rsock_s_accept): ditto. * ext/socket/socket.c (rsock_sock_s_socketpair): ditto. * ext/socket/ancdata.c (discard_cmsg): ditto. (make_io_for_unix_rights): ditto. * ext/socket/unixsocket.c (unix_recv_io): ditto. * ext/io/console/console.c (console_dev): ditto. [ruby-core:38140] [Feature #5041] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-05* random.c: Improve documentation of Random. Patch by Gregorydrbrain
Parkhurst. [Ruby 1.9 - Bug #5410] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-04* random.c (Init_Random): Add a top-level comment for Random. Patchdrbrain
by Brett Bim. [Ruby 1.9 - Bug #5403] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29* use RB_TYPE_P which is optimized for constant types, instead ofnobu
comparison with TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-20* include/ruby/intern.h (rb_update_max_fd): declaration moved fromakr
internal.h. * file.c: ditto. * io.c: call rb_update_max_fd for each new fds. * process.c: ditto. * random.c: ditto. * ruby.c: ditto. * ext/io/console/console.c: ditto. * ext/openssl/ossl_bio.c: ditto. * ext/pty/pty.c: ditto. * ext/socket/init.c: ditto. * ext/socket/socket.c: ditto. * ext/socket/ancdata.c: ditto. * ext/socket/unixsocket.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-27* random.c: Documentation fix for Random#bytesmarcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-15* remove trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-25* random.c (random_rand): remove unused variables.naruse
* struct.c (rb_struct_define_without_accessor): ditto. * strftime.c (rb_strftime_with_timespec): ditto. * sprintf.c: ditto. * time.c (time_asctime): remove useless GetTimeval(). * thread_pthread.c: cast to (void *) for %p. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-24* random.c (rb_f_rand, random_s_rand): RDocs for them.sorah
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-24* random.c (random_s_rand, Init_Random): Random.rand should behave asmrkn
Random::DEFAULT.rand rather than Kernel#rand. * random.c (rand_range, random_rand): rand_range function extracted from random_rand function. * random.c (rb_f_rand): accept a Range argument as Random#rand [ruby-dev:43427] #4605 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-20* random.c (rb_f_srand): fix rdoc: srand(0)'s 0 is a seed.naruse
[ruby-core:35833] fixes #4590 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-05* random.c (random_rand): suppress a warning.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-25* random.c: parenthesize macro arguments.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-11-20* random.c (random_rand): get rid of overflow.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-04* random.c (rand_init): This checks the value is in 32bit or not,naruse
so use int32_t, not int. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-04* random.c (rand_init): remove useless assignment.naruse
* re.c (update_char_offset): remove unused variable. * re.c (read_escaped_byte): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-10* random.c (rb_genrand_ulong_limited): renamed fromnaruse
rb_rand_internal and now this is public API. * include/ruby/ruby.h (rb_genrand_ulong_limited): added. * bignum.c (big_sparse_p): use rb_genrand_ulong_limited. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-26* random.c (rb_random_int32): suppress warning on LP64 platforms.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25* array.c (rb_ary_{shuffle_bang,sample}): use Random class object.nobu
* random.c (try_get_rnd): use default_rand for Random as same as singleton methods. * random.c (rb_random_real): check the range of result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25reverted to r29091; r29092 breaks test-allshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25* random.c (rb_random_int32): fixed typo.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25* random.c (rb_random_real): check the range of result.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-08-25* array.c (rb_ary_{shuffle_bang,sample}): use Random class object.nobu
* random.c (try_get_rnd): use default_rand for Random as same as singleton methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e