|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62375 Add constant "GMP_LIMB_BITS" to GMP
Submitted: 2012-06-20 18:16 UTC Modified: 2018-07-02 16:06 UTC
Avg. Score:3.5 ± 1.2
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: info at bastian-born dot de Assigned:
Status: Wont fix Package: GNU MP related
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-06-20 18:16 UTC] info at bastian-born dot de
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".

Test script:

echo "Bitcount: " . GMP_LIMB_BITS . "\n";
echo "Random with 128bit length: " . gmp_strval( gmp_random( 128 / GMP_LIMB_BITS ) );

Expected result:
Bitcount: 64
Random with 128bit length: 100835271651583136351260143038692948194


201206201530-gmp.c.patch (last revision 2012-06-20 18:17 UTC by info at bastian-born dot de)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-24 20:43 UTC] rainer dot jung at kippdata dot de
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.
 [2016-03-26 11:35 UTC]
-Status: Open +Status: Wont fix
 [2016-03-26 11:35 UTC]
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.)
 [2016-03-27 12:55 UTC] info at bastianborn dot de
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?
 [2018-07-02 16:06 UTC]
Just for the record, gmp_random() has indeed been deprecated in PHP 7.2.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 14:01:28 2024 UTC