Original code used ‘long’ where 32-bit integers are enough. This can be
a problem on LP64. Switch to custom MT19337 PRNG implementation adapted
by myself from algorithm pseudo-code that is functionally equivalent but
doesn't use ‘long’.
Add genrand_uniform() function that generates uniformly distributed
random integers modulo N, and use it in place of naive calculations.
This function uses the trick adapted from OpenBSD implementation of
arc4random_uniform() to calculate 2^32 modulo N.
Original code used ‘long’ where 32-bit integers are enough. This can be a problem on LP64. Switch to custom MT19337 PRNG implementation adapted by myself from algorithm pseudo-code that is functionally equivalent but doesn't use ‘long’.
Add genrand_uniform() function that generates uniformly distributed random integers modulo N, and use it in place of naive calculations. This function uses the trick adapted from OpenBSD implementation of arc4random_uniform() to calculate 2^32 modulo N.