Commit 35f2a89d by Andi Kleen Committed by Andi Kleen

Use urandom to get random seed

When available use /dev/urandom to get the random seem. This will lower the probability
of collisions.

On other systems it will fallback to the old methods.

Passes bootstrap + testsuite on x86_64. Ok?

gcc/:

2011-09-26   Andi Kleen <ak@linux.intel.com>

	* toplev.c (init_local_tick): Try reading random seed from /dev/urandom

From-SVN: r179348
parent dde8b360
2011-09-26 Andi Kleen <ak@linux.intel.com>
* toplev.c (init_local_tick): Try reading random seed from /dev/urandom
2011-09-26 Andi Kleen <ak@linux.intel.com>
* hwint.h (HOST_WIDE_INT_PRINT_HEX_PURE): Add.
* lto-streamer.c (lto_get_section_name): Remove crc32_string.
Handle numerical random seed.
......@@ -262,7 +262,17 @@ init_local_tick (void)
{
if (!flag_random_seed)
{
/* Get some more or less random data. */
/* Try urandom first. Time of day is too likely to collide.
In case of any error we just use the local tick. */
int fd = open ("/dev/urandom", O_RDONLY);
if (fd >= 0)
{
read (fd, &random_seed, sizeof (random_seed));
close (fd);
}
/* Now get the tick anyways */
#ifdef HAVE_GETTIMEOFDAY
{
struct timeval tv;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment