9os

Experimental kernel using plan9 ideas for embedded device
git clone git://git.simple-cc.org/9os
Log | Files | Refs | README | LICENSE

rand.c (250B)


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