diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 2003-02-04 11:24:08 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 2003-02-04 11:24:08 +0000 |
| commit | ddd972a9bd5f8a73cd9eb33181072d07ea99aa73 (patch) | |
| tree | b794978ed6263b8a5298e3cbb4e07dc4fce01682 /lib/libc/stdlib/random.c | |
| parent | 3967e18ad6a675e4fe0ec1cfe1754be37274b893 (diff) | |
Notes
Diffstat (limited to 'lib/libc/stdlib/random.c')
| -rw-r--r-- | lib/libc/stdlib/random.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c index 82af94c851fc..64310cd8685e 100644 --- a/lib/libc/stdlib/random.c +++ b/lib/libc/stdlib/random.c @@ -142,6 +142,8 @@ __FBSDID("$FreeBSD$"); */ #define MAX_TYPES 5 /* max number of types above */ +#define NSHUFF 100 /* to drop part of seed -> 1st value correlation */ + static long degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; static long seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; @@ -264,19 +266,20 @@ void srandom(x) unsigned long x; { - long i; + long i, lim; + state[0] = x; if (rand_type == TYPE_0) - state[0] = x; + lim = NSHUFF; else { - state[0] = x; for (i = 1; i < rand_deg; i++) state[i] = good_rand(state[i - 1]); fptr = &state[rand_sep]; rptr = &state[0]; - for (i = 0; i < 10 * rand_deg; i++) - (void)random(); + lim = 10 * rand_deg; } + for (i = 0; i < lim; i++) + (void)random(); } /* |
