Skip to content

Commit

Permalink
* random.c (fill_random_seed): /dev/urandom is not available on
Browse files Browse the repository at this point in the history
  DOSISH systems.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jul 17, 2009
1 parent 115c220 commit ed52949
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -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#==.

Expand Down
10 changes: 8 additions & 2 deletions random.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ed52949

Please sign in to comment.