diff options
author | 1996-08-10 21:41:08 +0000 | |
---|---|---|
committer | 1996-08-10 21:41:08 +0000 | |
commit | 9d9e279b041a9bb2d1430043f2cb5fecc6cb6e0f (patch) | |
tree | 43d7f843f22167be86eb35696f2ebea8970168cd /sys/lib/libkern/random.c | |
parent | call bindresvport() instead of faking it badly (diff) | |
download | wireguard-openbsd-9d9e279b041a9bb2d1430043f2cb5fecc6cb6e0f.tar.xz wireguard-openbsd-9d9e279b041a9bb2d1430043f2cb5fecc6cb6e0f.zip |
srandom() seeds random() at boottime
Diffstat (limited to 'sys/lib/libkern/random.c')
-rw-r--r-- | sys/lib/libkern/random.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/lib/libkern/random.c b/sys/lib/libkern/random.c index 14a10320f63..970cbf4bc6c 100644 --- a/sys/lib/libkern/random.c +++ b/sys/lib/libkern/random.c @@ -42,10 +42,11 @@ * and whatever else we might use it for. The result is uniform on * [0, 2^31 - 1]. */ +u_long __randseed = 1; + u_long random() { - static u_long randseed = 1; register long x, hi, lo, t; /* @@ -54,12 +55,12 @@ random() * Park and Miller, Communications of the ACM, vol. 31, no. 10, * October 1988, p. 1195. */ - x = randseed; + x = __randseed; hi = x / 127773; lo = x % 127773; t = 16807 * lo - 2836 * hi; if (t <= 0) t += 0x7fffffff; - randseed = t; + __randseed = t; return (t); } |