summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/rand.c
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2003-02-04 11:24:08 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2003-02-04 11:24:08 +0000
commitddd972a9bd5f8a73cd9eb33181072d07ea99aa73 (patch)
treeb794978ed6263b8a5298e3cbb4e07dc4fce01682 /lib/libc/stdlib/rand.c
parent3967e18ad6a675e4fe0ec1cfe1754be37274b893 (diff)
Notes
Diffstat (limited to 'lib/libc/stdlib/rand.c')
-rw-r--r--lib/libc/stdlib/rand.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/libc/stdlib/rand.c b/lib/libc/stdlib/rand.c
index 47bb36dcad9b..dcc445f13ebd 100644
--- a/lib/libc/stdlib/rand.c
+++ b/lib/libc/stdlib/rand.c
@@ -51,6 +51,8 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#endif /* TEST */
+#define NSHUFF 100 /* to drop part of seed -> 1st value correlation */
+
static int
do_rand(unsigned long *ctx)
{
@@ -108,7 +110,11 @@ void
srand(seed)
u_int seed;
{
+ int i;
+
next = seed;
+ for (i = 0; i < NSHUFF; i++)
+ (void)do_rand(&next);
}
@@ -137,7 +143,7 @@ sranddev()
unsigned long junk;
gettimeofday(&tv, NULL);
- next = (getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk;
+ srand((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk);
}
}