summaryrefslogtreecommitdiff
path: root/random.c
Commit message (Collapse)AuthorAgeFilesLines
* [DOC] Improve Random::Formatter docszverok2022-12-111-0/+3
| | | | | | | * Make its usage more obvious (by providing more detailed examples); * Include mention of it into Random itself; * Small cleanups of docs.
* [Bug #19100] Add `init_int32` function to `rb_random_interface_t`Nobuyoshi Nakada2022-11-101-8/+13
| | | | | Distinguish initialization by single word from initialization by array.
* Add version to the interface of Random extensionsNobuyoshi Nakada2022-11-101-0/+9
|
* Respect `USE_COMMON_RANDOM` macro by a command line option [ci skip]Nobuyoshi Nakada2022-10-171-3/+7
|
* Fix debug messages [ci skip]Nobuyoshi Nakada2022-10-171-2/+5
|
* Expand tabs [ci skip]Takashi Kokubun2022-07-211-240/+240
| | | | [Misc #18891]
* [DOC] Mark up the code for Kernel#rand as the same as Random#randNobuyoshi Nakada2022-01-131-1/+1
|
* Remove deprecated Random::DEFAULT [Feature #17351]Nobuyoshi Nakada2022-01-011-3/+0
|
* [DOC] Add documentation for Random.rand and Random.seedChris AtLee2021-12-201-3/+18
|
* [DOC] random number by rangeNobuyoshi Nakada2021-12-161-2/+6
|
* [DOC] Add call sequences of Random using a rangeNobuyoshi Nakada2021-12-131-4/+9
|
* [DOC] Improve Random::Formatter description and exampleNobuyoshi Nakada2021-12-131-1/+8
|
* Fix stack buffer overflowNobuyoshi Nakada2021-12-101-5/+2
| | | | https://hackerone.com/reports/1306859
* Check the reading size rangeNobuyoshi Nakada2021-11-061-4/+19
|
* random.c: simplify Random object deallocationKazuki Yamaguchi2021-10-271-8/+1
| | | | | | | | | | | This is a follow-up for commit 265c0022390e ("Do not allocate ractor-local storage in dfree function during GC", 2021-02-09). The comparison with the default rb_random_mt_t is useless in the first place, since it is never equal: no actual Random object is associated with it. [Bug #17653] https://bugs.ruby-lang.org/issues/17653
* [Win32] Prefer Cryptography Next Generation APINobuyoshi Nakada2021-10-021-1/+21
| | | | | | | | | | | | | [BCryptGenRandom] is available since Windows Vista / Windows Server 2008. Regarding [CryptGenRandom]: > This API is deprecated. New and existing software should start > using Cryptography Next Generation APIs. Microsoft may remove > this API in future releases. [BCryptGenRandom]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom [CryptGenRandom]: https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom
* HCRYPTPROV is not a HANDLENobuyoshi Nakada2021-09-241-7/+14
| | | | | Even though it is called "handle" and prefixed with "H", and its value looks like a handle.
* Using RB_FLOAT_TYPE_P macroS-H-GAMELINKS2021-09-121-2/+2
|
* Use C99-defined macros to classify a floating-point numberNobuyoshi Nakada2021-08-271-1/+1
|
* netbsd coroutine uses assembly instead and little build fix.David Carlier2021-08-241-1/+1
|
* rand_bytes: prefer rng->get_bytes卜部昌平2021-06-241-1/+1
| | | | | Because why not. There was no use case of rng->get_bytes before this changeset.
* Fix compilation errors in FreeBSDPeter Zhu2021-05-041-2/+2
| | | | __FreeBSD_version is defined in sys/param.h.
* Fix -Wundef warnings for patterns `#if HAVE`Benoit Daloze2021-05-041-1/+1
| | | | | | * See [Feature #17752] * Using this to detect them: git grep -P 'if\s+HAVE' | grep -Pv 'HAVE_LONG_LONG|/ChangeLog|HAVE_TYPEOF'
* Include CommonCrypto/CommonCryptoError.h for old XcodeNobuyoshi Nakada2021-03-191-0/+1
|
* Use CommonRandom if availableNobuyoshi Nakada2021-03-191-3/+18
|
* Fixed syntax error with gcc on macOSNobuyoshi Nakada2021-03-041-1/+1
| | | | | | | Security/Authorization.h defines AuthorizationExternalForm by using clang extension which allows variably modified types in a file scope. As we just need high-level accessors only, include Security/SecRandom.h instead.
* Do not allocate ractor-local storage in dfree function during GCNobuyoshi Nakada2021-02-091-1/+2
|
* OpenBSD has getentropy, but no sys/random.hKazuhiro NISHIYAMA2021-01-181-1/+3
| | | | | | | | | | | | | https://man.openbsd.org/getentropy Try to fix https://rubyci.s3.amazonaws.com/openbsd-current/ruby-master/log/20210118T023008Z.fail.html.gz ``` compiling random.c random.c:53:11: fatal error: 'sys/random.h' file not found # include <sys/random.h> ^~~~~~~~~~~~~~ 1 error generated. ```
* random generator update for Mac proposalDavid CARLIER2021-01-171-2/+18
| | | | | using getentropy for seeding, reading 256 bytes at a time to avoid the EIO errno since this is the maximum.
* Include missing AvailabilityMacros.hNobuyoshi Nakada2021-01-171-0/+4
|
* Remove possibility of using same seedsNobuyoshi Nakada2021-01-101-2/+2
|
* Random instance methodszverok2020-12-211-0/+7
|
* Deprecate Random::DEFAULTBenoit Daloze2020-12-141-0/+2
| | | | * Closes [Feature #17351].
* Remove references to Random::DEFAULT in the documentationBenoit Daloze2020-12-141-8/+6
| | | | | * Random::DEFAULT is no longer a Random instance, and referencing it is more confusing than helpful. Related to [Feature #17351]
* ractor local storage C-APIKoichi Sasada2020-12-011-11/+22
| | | | | | | | | | | | | | | | | | | | | | To manage ractor-local data for C extension, the following APIs are defined. * rb_ractor_local_storage_value_newkey * rb_ractor_local_storage_value * rb_ractor_local_storage_value_set * rb_ractor_local_storage_ptr_newkey * rb_ractor_local_storage_ptr * rb_ractor_local_storage_ptr_set At first, you need to create a key of storage by rb_ractor_local_(value|ptr)_newkey(). For ptr storage, it accepts the type of storage, how to mark and how to free with ractor's lifetime. rb_ractor_local_storage_value/set are used to access a VALUE and rb_ractor_local_storage_ptr/set are used to access a pointer. random.c uses this API.
* Use opaque struct pointer than voidNobuyoshi Nakada2020-11-271-2/+2
|
* mark default_randKoichi Sasada2020-11-271-0/+7
| | | | default_rand can points a Bignum seed, so it should be marked.
* per-ractor Random::DEFAULTKoichi Sasada2020-11-271-37/+32
| | | | | | | | | | Random generators are not Ractor-safe, so we need to prepare per-ractor default random genearators. This patch set `Random::DEFAULT = Randm` (not a Random instance, but the Random class) and singleton methods like `Random.rand()` use a per-ractor random generator. [Feature #17322]
* [DOC] Mersenne Twister isn't cryptographically secure [ci skip]Nobuyoshi Nakada2020-11-271-1/+2
|
* rb_const_set sets the class path nowNobuyoshi Nakada2020-10-091-1/+0
|
* Added `rb_random_base_init`Nobuyoshi Nakada2020-09-071-1/+8
| | | | To enclose the initialization of Random::Base part.
* Added WITH_REAL macrosNobuyoshi Nakada2020-09-071-1/+1
| | | | | | Added `WITH_REAL` versions to `RB_RANDOM_INTERFACE` macros. Also these macros including "without real" versions no longer contain the terminator (semicolon and comma).
* Added `get_real` interfaceNobuyoshi Nakada2020-09-071-0/+1
|
* Added rb_int_pair_to_realNobuyoshi Nakada2020-09-071-0/+6
|
* separate rb_random_tNobuyoshi Nakada2020-09-071-120/+230
| | | | | | | | | | | | * random.c: separate abstract rb_random_t and rb_random_mt_t for Mersenne Twister implementation. * include/ruby/random.h: the interface for extensions of Random class. * DLL imported symbol reference is not constant on Windows. * check if properly initialized.
* Random::BaseNobuyoshi Nakada2020-09-071-6/+13
| | | | | * random.c (InitVM_Random): introduce abstract super class Random::Base.
* RARRAY_AREF: convert into an inline function卜部昌平2020-08-151-0/+1
| | | | | | RARRAY_AREF has been a macro for reasons. We might not be able to change that for public APIs, but why not relax the situation internally to make it an inline function.
* rand_range: do not goto into a branch卜部昌平2020-06-291-1/+1
| | | | | I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
* sed -i 's|ruby/impl|ruby/internal|'卜部昌平2020-05-111-1/+1
| | | | To fix build failures.
* sed -i s|ruby/3|ruby/impl|g卜部昌平2020-05-111-1/+1
| | | | This shall fix compile errors.