mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* random.c (fill_random_seed): /dev/urandom is not available on
DOSISH systems. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
115c220b4d
commit
ed52949e79
2 changed files with 12 additions and 3 deletions
|
@ -1,4 +1,7 @@
|
|||
Fri Jul 17 13:55:53 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Fri Jul 17 13:58:26 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* random.c (fill_random_seed): /dev/urandom is not available on
|
||||
DOSISH systems.
|
||||
|
||||
* random.c (random_equal): new method Random#==.
|
||||
|
||||
|
|
10
random.c
10
random.c
|
@ -375,19 +375,25 @@ random_init(int argc, VALUE *argv, VALUE obj)
|
|||
|
||||
#define DEFAULT_SEED_LEN (DEFAULT_SEED_CNT * sizeof(int))
|
||||
|
||||
#if defined(S_ISCHR) && !defined(DOSISH)
|
||||
# define USE_DEV_URANDOM 1
|
||||
#else
|
||||
# define USE_DEV_URANDOM 0
|
||||
#endif
|
||||
|
||||
static void
|
||||
fill_random_seed(unsigned int seed[DEFAULT_SEED_CNT])
|
||||
{
|
||||
static int n = 0;
|
||||
struct timeval tv;
|
||||
#ifdef S_ISCHR
|
||||
#if USE_DEV_URANDOM
|
||||
int fd;
|
||||
struct stat statbuf;
|
||||
#endif
|
||||
|
||||
memset(seed, 0, DEFAULT_SEED_LEN);
|
||||
|
||||
#ifdef S_ISCHR
|
||||
#if USE_DEV_URANDOM
|
||||
if ((fd = open("/dev/urandom", O_RDONLY
|
||||
#ifdef O_NONBLOCK
|
||||
|O_NONBLOCK
|
||||
|
|
Loading…
Reference in a new issue