X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fprng%2Frand_r.c;h=638614c867911a133d4a3f054c7150e28d5a4425;hb=0636d5977aa796d78869ee310c6e69220b919eee;hp=e96cfba99cdb9c8cb4b2c0d834389b864e857e23;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/prng/rand_r.c b/src/prng/rand_r.c index e96cfba9..638614c8 100644 --- a/src/prng/rand_r.c +++ b/src/prng/rand_r.c @@ -1,6 +1,15 @@ #include +static unsigned temper(unsigned x) +{ + x ^= x>>11; + x ^= x<<7 & 0x9D2C5680; + x ^= x<<15 & 0xEFC60000; + x ^= x>>18; + return x; +} + int rand_r(unsigned *seed) { - return (*seed = *seed * 1103515245 + 12345) & 0x7fffffff; + return temper(*seed = *seed * 1103515245 + 12345)/2; }