xref: /original-bsd/lib/libc/stdlib/rand.c (revision 3705696b)
1 /*-
2  * Copyright (c) 1990, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)rand.c	8.1 (Berkeley) 06/14/93";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <sys/types.h>
13 #include <stdlib.h>
14 
15 static u_long next = 1;
16 
17 int
18 rand()
19 {
20 	return ((next = next * 1103515245 + 12345) % ((u_long)RAND_MAX + 1));
21 }
22 
23 void
24 srand(seed)
25 u_int seed;
26 {
27 	next = seed;
28 }
29