summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/rand.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/stdlib/rand.c')
-rw-r--r--src/lib/libc/stdlib/rand.c12
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)
35static char *rcsid = "$OpenBSD: rand.c,v 1.2 1996/08/19 08:33:44 tholo Exp $"; 35static 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 $";
41static u_long next = 1; 41static u_long next = 1;
42 42
43int 43int
44rand_r(seed)
45u_int *seed;
46{
47 *seed = *seed * 1103515245 + 12345;
48 return (u_int)(*seed / 65536) % ((u_int)RAND_MAX + 1);
49}
50
51int
44rand() 52rand()
45{ 53{
46 return ((next = next * 1103515245 + 12345) % ((u_int)RAND_MAX + 1)); 54 return rand_r(&next);
47} 55}
48 56
49void 57void