summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-random/src/random.c
AgeCommit message (Collapse)Author
2020-10-12Use `mrb_int_value()` instead of `mrb_fixnum_value()`.Yukihiro "Matz" Matsumoto
Where fixnum overflow can happen.
2020-10-12Update `mruby-random` gem to support 32 bit platforms.Yukihiro "Matz" Matsumoto
`sizeof(rand_state)` had been bigger than `sizeof(void*)*3`. Changed random number generator to `Xorshift96` on 32 bit platforms.
2020-10-12Reorganize `Integer` system.Yukihiro "Matz" Matsumoto
- Integrate `Fixnum` and `Integer` - Remove `Integral` - `int / int -> int` - Replace `mrb_fixnum()` to `mrb_int()` - Replace `mrb_fixnum_value()` to `mrb_int_value()`. - Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12Use xoshiro128++ instead of xorshift96/128.Yukihiro "Matz" Matsumoto
2020-10-12Fix `rand_real` to return random number `[0,1)` not `[0,1]`.Yukihiro "Matz" Matsumoto
2020-10-12Rename float configuration option names.Yukihiro "Matz" Matsumoto
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT` - `MRB_USE_FLOAT` => `MRB_USE_FLOAT32` The former is to use `USE_XXX` naming convention. The latter is to make sure `float` is 32bit float and not floating point number in general.
2020-10-12Avoid breaking the `result` array by side-effect in C++.Yukihiro "Matz" Matsumoto
2020-10-12Use functions that take symbols to reduce string litrals in C.Yukihiro "Matz" Matsumoto
2020-10-12Add `MRB_SYM()` for inline symbols.Yukihiro "Matz" Matsumoto
2020-06-29Work around more MSC optimzer bugsRory OConnell
2020-06-26Reduce scope of volatile keyword for MSC bugRory OConnell
2020-06-26Narrower scope working around MSC bugRory OConnell
2020-06-26work around MSC optimization generating non functional codeRory OConnell
2019-09-26Use type predicate macros instead of `mrb_type` if possibleKOBAYASHI Shuji
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for all `enum mrb_vtype`).
2019-08-27Fix build of `mruby-random` on 32-bit modeKOBAYASHI Shuji
2019-08-26Fix `Array#sample` with `MRB_INT32`KOBAYASHI Shuji
Array index became potentially negative because `uint32_t` is cast to `mrb_int`.
2019-07-24Use `MRB_TT_ISTRUCT` for `Random` to reduce memory.Yukihiro "Matz" Matsumoto
When the size of Xorshift128 seed (`sizeof(uint32)*4`) is bigger than ISTRUCT_DATA_SIZE, `Random` uses Xorshift96 instead.
2019-07-22Switch random generator from Mersenne Twister to Xorshit128.Yukihiro "Matz" Matsumoto
Now `rand` can be used with `MRB_WITHOUT_FLOAT`; ref #4576
2019-07-14Error needed/conflicts configurationdearblue
The purpose is to clarify the error if there is a needed/conflicts configuration at compile time.
2018-11-19Remove implicit conversion using `to_int` method.Yukihiro "Matz" Matsumoto
The ISO standard does not include implicit type conversion using `to_int`. This implicit conversion often causes vulnerability. There will be no more attacks like #4120. In addition, we have added internal convenience method `__to_int` which does type check and conversion (from floats).
2018-09-07Clear terminated spacedearblue
2017-07-27Embed small size array elements in the heap.Yukihiro "Matz" Matsumoto
It reduces the memory consumption and sometimes improve the performance as well. For example, the consumed memory size of `bench/bm_ao_render.rb` is reduced from 1.2GB to 1GB, and its total execution time become 18.795 sec from 22.229 sec.
2017-02-02Fetch arguments earlier to avoid a crash.Clayton Smith
2016-11-23Fix segfault in Array#sampleBouke van der Bijl
2016-01-21mruby-random: fixed wrong fixnum conversionYukihiro "Matz" Matsumoto
2015-11-27include changed from by quotes ("") to by brackets (<>); close #3032Yukihiro "Matz" Matsumoto
2014-09-12constify pointer from RARRAY_PTR to detect potential write barrier bugs.Yukihiro "Matz" Matsumoto
if you see compiler errors due to this commit, you'd better to use array-modifying functions, e.g. mrb_ary_set() or mrb_ary_push(), otherwise you might see nasty GC bugs in the future. if you are sure what you are doing, replace `RARRAY_PTR(ary)` by `mrb_ary_ptr(ary)->ptr`. but be warned.
2014-08-20Add API `mrb_data_init` to initialize `MRB_TT_DATA` tagged instance.take_cheeze
2014-07-12remove spaces after open parensYukihiro "Matz" Matsumoto
2014-05-10Pacify MSVC warnings for random.ckyab
2014-04-30remove trailing spacesNobuyoshi Nakada
2014-03-09add data_type check to mruby-randomYukihiro "Matz" Matsumoto
2014-03-09refactoring mruby-randomYukihiro "Matz" Matsumoto
2014-03-09implement Array#sample in mruby-random gemYukihiro "Matz" Matsumoto
2014-03-05remove unused variablecubicdaiya
GLOBAL_RAND_SEED_KEY is no longer used.
2014-03-04Fix #1793mattn
2014-03-02fix a memory leak in mruby-random.Tatsuya Matsumoto
2014-02-25Implement default Random instance.chasonr
Previously, the default random number generator was implemented using static storage. This storage is common to all instances of mruby in a process, and use of the default random number generator in one instance will perturb the default random number generator in other instances. It is also not thread safe. With this change, the default random number generator is defined as Random::DEFAULT, as it is in CRuby.
2014-02-21use 'd' format spec to get Random objecttake_cheeze
2014-02-21use mrb_intern_lit in mruby-randomtake_cheeze
2014-02-14Give the type 'void' to functions have no argument.cubicdaiya
According to the C standard, it is desirable to give the type 'void' to functions have no argument.
2013-11-29rename mrb_intern2() to mrb_intern(); huge API incompatibility; close #1513Yukihiro "Matz" Matsumoto
2013-11-13Changed a variable declaration to top of blockbggd
2013-11-03small style fixYukihiro "Matz" Matsumoto
2013-11-02Added support for Random as an argument to shuffle and shuffle!. Refactored ↵Emiliano Lesende
random gem to use DATA instance type and hold mt_state inside the DATA_PTR instead of in an instance variable.
2013-11-01Added shuffle and shuffle! to the Array class in the Random gem.Emiliano Lesende
2013-08-15redesign mruby/data.h API; use DATA_PTR() for raw data pointer, ↵Yukihiro "Matz" Matsumoto
DATA_GET_PTR() to type safe retrieval (TypeError will be raised), DATA_CHECK_GET_PTR() to get nil if type mismatched
2013-07-14Replace mrb_intern() with mrb_intern2() in random.cJun Hiroe
2013-05-26Add MRB_WORD_BOXING mode (represent mrb_value as a word)kimu_shu
2013-04-29use mrb_free to free random stateYukihiro "Matz" Matsumoto