musl/src/prng/__rand48_step.c
Szabolcs Nagy 0996faa3d7 prng: make rand_r have 2^32 period instead of 2^31
this is a minor fix to increase the period of the obsolete rand_r a bit.
an include header in __rand48_step.c is fixed as well.
2013-06-08 13:49:12 +00:00

14 lines
299 B
C

#include <stdlib.h>
#include <stdint.h>
uint64_t __rand48_step(unsigned short *xi, unsigned short *lc)
{
uint64_t a, x;
x = xi[0] | xi[1]<<16 | xi[2]+0ULL<<32;
a = lc[0] | lc[1]<<16 | lc[2]+0ULL<<32;
x = a*x + lc[3];
xi[0] = x;
xi[1] = x>>16;
xi[2] = x>>32;
return x & 0xffffffffffffull;
}