diff options
Diffstat (limited to 'src/lib/libc/stdlib/rand.c')
-rw-r--r-- | src/lib/libc/stdlib/rand.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/rand.c b/src/lib/libc/stdlib/rand.c index f270ffd986..61fb66e5ec 100644 --- a/src/lib/libc/stdlib/rand.c +++ b/src/lib/libc/stdlib/rand.c | |||
@@ -32,7 +32,7 @@ | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | static char *rcsid = "$OpenBSD: rand.c,v 1.2 1996/08/19 08:33:44 tholo Exp $"; | 35 | static char *rcsid = "$OpenBSD: rand.c,v 1.3 1998/11/20 11:18:50 d Exp $"; |
36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
37 | 37 | ||
38 | #include <sys/types.h> | 38 | #include <sys/types.h> |
@@ -41,9 +41,17 @@ static char *rcsid = "$OpenBSD: rand.c,v 1.2 1996/08/19 08:33:44 tholo Exp $"; | |||
41 | static u_long next = 1; | 41 | static u_long next = 1; |
42 | 42 | ||
43 | int | 43 | int |
44 | rand_r(seed) | ||
45 | u_int *seed; | ||
46 | { | ||
47 | *seed = *seed * 1103515245 + 12345; | ||
48 | return (u_int)(*seed / 65536) % ((u_int)RAND_MAX + 1); | ||
49 | } | ||
50 | |||
51 | int | ||
44 | rand() | 52 | rand() |
45 | { | 53 | { |
46 | return ((next = next * 1103515245 + 12345) % ((u_int)RAND_MAX + 1)); | 54 | return rand_r(&next); |
47 | } | 55 | } |
48 | 56 | ||
49 | void | 57 | void |