summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/rand.c
diff options
context:
space:
mode:
authorpat <>2005-03-30 18:51:49 +0000
committerpat <>2005-03-30 18:51:49 +0000
commit894b6ab0099e7d9ca2ad9acb75246cd0a4542167 (patch)
treef9fb8e9324f6cbdc10d72cab8b889d470252465a /src/lib/libc/stdlib/rand.c
parent162f8b042bf31ab94714a6f194e9836c08c085f5 (diff)
downloadopenbsd-894b6ab0099e7d9ca2ad9acb75246cd0a4542167.tar.gz
openbsd-894b6ab0099e7d9ca2ad9acb75246cd0a4542167.tar.bz2
openbsd-894b6ab0099e7d9ca2ad9acb75246cd0a4542167.zip
ansi + de-register
ok otto deraadt
Diffstat (limited to 'src/lib/libc/stdlib/rand.c')
-rw-r--r--src/lib/libc/stdlib/rand.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/lib/libc/stdlib/rand.c b/src/lib/libc/stdlib/rand.c
index d58d040ad5..6b27ad46d3 100644
--- a/src/lib/libc/stdlib/rand.c
+++ b/src/lib/libc/stdlib/rand.c
@@ -28,7 +28,7 @@
28 */ 28 */
29 29
30#if defined(LIBC_SCCS) && !defined(lint) 30#if defined(LIBC_SCCS) && !defined(lint)
31static char *rcsid = "$OpenBSD: rand.c,v 1.7 2003/06/02 20:18:38 millert Exp $"; 31static char *rcsid = "$OpenBSD: rand.c,v 1.8 2005/03/30 18:51:49 pat Exp $";
32#endif /* LIBC_SCCS and not lint */ 32#endif /* LIBC_SCCS and not lint */
33 33
34#include <sys/types.h> 34#include <sys/types.h>
@@ -37,25 +37,20 @@ static char *rcsid = "$OpenBSD: rand.c,v 1.7 2003/06/02 20:18:38 millert Exp $";
37static u_int next = 1; 37static u_int next = 1;
38 38
39int 39int
40rand_r(seed) 40rand_r(u_int *seed)
41u_int *seed;
42{ 41{
43
44 *seed = *seed * 1103515245 + 12345; 42 *seed = *seed * 1103515245 + 12345;
45 return (*seed % ((u_int)RAND_MAX + 1)); 43 return (*seed % ((u_int)RAND_MAX + 1));
46} 44}
47 45
48int 46int
49rand() 47rand(void)
50{ 48{
51
52 return (rand_r(&next)); 49 return (rand_r(&next));
53} 50}
54 51
55void 52void
56srand(seed) 53srand(u_int seed)
57u_int seed;
58{ 54{
59
60 next = seed; 55 next = seed;
61} 56}