1
0
Fork 0
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:
nobu 2009-07-17 04:58:38 +00:00
parent 115c220b4d
commit ed52949e79
2 changed files with 12 additions and 3 deletions

View file

@ -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#==.

View file

@ -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