1
0

rand_r.c 234 B

123456789101112131415
  1. #include <stdlib.h>
  2. static unsigned temper(unsigned x)
  3. {
  4. x ^= x>>11;
  5. x ^= x<<7 & 0x9D2C5680;
  6. x ^= x<<15 & 0xEFC60000;
  7. x ^= x>>18;
  8. return x;
  9. }
  10. int rand_r(unsigned *seed)
  11. {
  12. return temper(*seed = *seed * 1103515245 + 12345)/2;
  13. }