rand.c 233 B

123456789101112131415161718
  1. /* $Id$ */
  2. static long seed = 1L;
  3. int rand()
  4. {
  5. seed = (1103515245L * seed + 12345) & 0x7FFFFFFF;
  6. #if _EM_WSIZE == 4
  7. return (int) seed;
  8. #else
  9. return ((int)(seed >> 8) & 0x7FFF);
  10. #endif
  11. }
  12. srand(n)
  13. unsigned n;
  14. {
  15. seed = n;
  16. }