6 /* Simple Park-Miller */
8 static __thread
unsigned long pmseed
= 29264;
11 fast_srandom(unsigned long seed_
)
23 fast_random(unsigned int max
)
26 lo
= 16807 * (pmseed
& 0xffff);
27 hi
= 16807 * (pmseed
>> 16);
28 lo
+= (hi
& 0x7fff) << 16;
30 pmseed
= (lo
& 0x7fffffff) + (lo
>> 31);
31 return ((pmseed
& 0xffff) * max
) >> 16;
37 /* Construct (1,2) IEEE float from our random integer */
38 /* http://rgba.org/articles/sfrand/sfrand.htm */
39 union { unsigned long ul
; float f
; } p
;
40 p
.ul
= (((pmseed
*= 16807) & 0x007fffff) - 1) | 0x3f800000;