mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* expand tabs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1a8583de72
commit
61ffc7a0ae
1 changed files with 15 additions and 15 deletions
30
random.c
30
random.c
|
|
@ -398,21 +398,21 @@ fill_random_bytes_syscall(void *seed, size_t size, int need_secure)
|
||||||
{
|
{
|
||||||
static rb_atomic_t try_syscall = 1;
|
static rb_atomic_t try_syscall = 1;
|
||||||
if (try_syscall) {
|
if (try_syscall) {
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if (!need_secure)
|
if (!need_secure)
|
||||||
flags = GRND_NONBLOCK;
|
flags = GRND_NONBLOCK;
|
||||||
do {
|
do {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
ret = getrandom(((char*)seed) + offset, size - offset, flags);
|
ret = getrandom(((char*)seed) + offset, size - offset, flags);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
ATOMIC_SET(try_syscall, 0);
|
ATOMIC_SET(try_syscall, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
offset += (size_t)ret;
|
offset += (size_t)ret;
|
||||||
} while(offset < size);
|
} while(offset < size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue