| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
| |
Because why not. There was no use case of rng->get_bytes before this
changeset.
|
|
|
|
| |
__FreeBSD_version is defined in sys/param.h.
|
|
|
|
|
|
| |
* See [Feature #17752]
* Using this to detect them:
git grep -P 'if\s+HAVE' | grep -Pv 'HAVE_LONG_LONG|/ChangeLog|HAVE_TYPEOF'
|
| |
|
| |
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
```
|
|
|
|
|
| |
using getentropy for seeding, reading 256 bytes at a time to avoid
the EIO errno since this is the maximum.
|
| |
|
| |
|
| |
|
|
|
|
| |
* Closes [Feature #17351].
|
|
|
|
|
| |
* Random::DEFAULT is no longer a Random instance, and referencing it is
more confusing than helpful. Related to [Feature #17351]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
default_rand can points a Bignum seed, so it should be marked.
|
|
|
|
|
|
|
|
|
|
| |
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]
|
| |
|
| |
|
|
|
|
| |
To enclose the initialization of Random::Base part.
|
|
|
|
|
|
| |
Added `WITH_REAL` versions to `RB_RANDOM_INTERFACE` macros. Also
these macros including "without real" versions no longer contain
the terminator (semicolon and comma).
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.c (InitVM_Random): introduce abstract super class
Random::Base.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea. Better refactor.
|
|
|
|
| |
To fix build failures.
|
|
|
|
| |
This shall fix compile errors.
|
|
|
|
|
| |
An expression using `static const` value seems not considered as
`static const` by Visual C.
|
|
|
|
| |
And utilize more bits even if DBL_MANT_DIG > 53.
|
| |
|
|
|
| |
Split ruby.h
|
|
|
|
| |
To prevent from leaking the seed data.
|
|
|
|
|
| |
Expanding less random data with MT is not needed when it
succeeded.
|
| |
|
|
|
|
|
| |
The role of this is a so-called "salt" but not "seed", rename to
get rid of confusion with other "seed" of PRNG.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead. This would significantly
speed up incremental builds.
We take the following inclusion order in this changeset:
1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very
first thing among everything).
2. RUBY_EXTCONF_H if any.
3. Standard C headers, sorted alphabetically.
4. Other system headers, maybe guarded by #ifdef
5. Everything else, sorted alphabetically.
Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
|
|
|
|
|
|
|
| |
With these macros implemented we can write codes just like we can assume
the compiler being clang. MSC_VERSION_SINCE is defined to implement
those macros, but turned out to be handy for other places. The -fdeclspec
compiler flag is necessary for clang to properly handle __has_declspec().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
same as `rand(endless_range)`
Before:
```
$ ruby -e 'rand(..1)'
Traceback (most recent call last):
2: from -e:1:in `<main>'
1: from -e:1:in `rand'
-e:1:in `-': nil can't be coerced into Integer (TypeError)
```
After:
```
$ ruby -e 'rand(..1)'
Traceback (most recent call last):
1: from -e:1:in `<main>'
-e:1:in `rand': Numerical argument out of domain (Errno::EDOM)
```
|
| |
|
|
|
|
|
|
| |
We can check the function pointer passed to
rb_define_singleton_method like how we do so in rb_define_method.
Doing so revealed many arity mismatches.
|
| |
|
|
|
|
|
| |
* random.c: renamed random_data_type as random_mt_type, and append
"MT" to `wrap_struct_name`, respecting the implementation.
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|
|
|
|
| |
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
|