xref: /csrg-svn/lib/libc/stdlib/rand.c (revision 63434)
142089Sbostic /*-
242089Sbostic  * Copyright (c) 1990 The Regents of the University of California.
342089Sbostic  * All rights reserved.
442089Sbostic  *
542089Sbostic  * %sccs.include.redist.c%
621331Sdist  */
721331Sdist 
826519Sdonn #if defined(LIBC_SCCS) && !defined(lint)
9*63434Sbostic static char sccsid[] = "@(#)rand.c	5.7 (Berkeley) 06/14/93";
1042089Sbostic #endif /* LIBC_SCCS and not lint */
1121331Sdist 
1242089Sbostic #include <sys/types.h>
1342089Sbostic #include <stdlib.h>
141976Swnj 
1542089Sbostic static u_long next = 1;
1642089Sbostic 
1742089Sbostic int
1842089Sbostic rand()
191976Swnj {
20*63434Sbostic 	return ((next = next * 1103515245 + 12345) % ((u_long)RAND_MAX + 1));
211976Swnj }
221976Swnj 
2342089Sbostic void
2442089Sbostic srand(seed)
2542089Sbostic u_int seed;
261976Swnj {
2742089Sbostic 	next = seed;
281976Swnj }
29