xref: /csrg-svn/lib/libc/stdlib/rand.c (revision 42089)
1*42089Sbostic /*-
2*42089Sbostic  * Copyright (c) 1990 The Regents of the University of California.
3*42089Sbostic  * All rights reserved.
4*42089Sbostic  *
5*42089Sbostic  * %sccs.include.redist.c%
621331Sdist  */
721331Sdist 
826519Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*42089Sbostic static char sccsid[] = "@(#)rand.c	5.3 (Berkeley) 05/15/90";
10*42089Sbostic #endif /* LIBC_SCCS and not lint */
1121331Sdist 
12*42089Sbostic #include <sys/types.h>
13*42089Sbostic #include <sys/stdc.h>
14*42089Sbostic #include <stdlib.h>
151976Swnj 
16*42089Sbostic static u_long next = 1;
17*42089Sbostic 
18*42089Sbostic int
19*42089Sbostic rand()
201976Swnj {
21*42089Sbostic 	return ((next = next * 1103515245 + 12345) % RAND_MAX);
221976Swnj }
231976Swnj 
24*42089Sbostic void
25*42089Sbostic srand(seed)
26*42089Sbostic u_int seed;
271976Swnj {
28*42089Sbostic 	next = seed;
291976Swnj }
30