scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

rand.c (227B)


      1 #include <stdlib.h>
      2 #undef rand
      3 
      4 static int next;
      5 
      6 void
      7 srand(unsigned seed)
      8 {
      9 	next = seed;
     10 }
     11 
     12 int
     13 rand(void)  /* RAND_MAX assumed to be 32767. */
     14 {
     15 	next = next * 1103515245 + 12345;
     16 	return (unsigned)(next/65536) % 32768;
     17 }