go to bug id or search bugs for
For the gmp_random() function you need the number of bits per limb to calculate the correct limiter value (parameter).
This patch will register the constant "GMP_LIMB_BITS".
echo "Bitcount: " . GMP_LIMB_BITS . "\n";
echo "Random with 128bit length: " . gmp_strval( gmp_random( 128 / GMP_LIMB_BITS ) );
Random with 128bit length: 100835271651583136351260143038692948194
Add a Patch
Add a Pull Request
Agreed, that patch would be very useful. For example the ext/gmp/tests/gmp_random_seed.phpt test currently fails on Solaris, because it only works when GMP_LIMB_BITS is 64. On Solaris 32 Bits Sparc it is 32 and gmp_random() produces other values.
As PHP 5.6 introduced gmp_random_bits(), which does not depend on the limb size, this should no longer be relevant. (We would be able to introduce this constant only on versions of PHP that already have gmp_random_bits.)
Nice to see there is a proper function for that now. But the old gmp_random() still exists and can never work properly. Maybe we should mark it as deprecated?