shithub: scc

ref: c598dd38d7d921a59b9afa44fa5b7c8b8ae08e37
dir: /libc/src/rand.c/

View raw version
/* See LICENSE file for copyright and license details. */

#include <stdlib.h>
#undef rand

static int next;

void
srand(unsigned seed)
{
	next = seed;
}

int
rand(void)  /* RAND_MAX assumed to be 32767. */
{
	next = next * 1103515245 + 12345;
	return (unsigned)(next/65536) % 32768;
}