Req #62375 [Wfx]: Add constant "GMP_LIMB_BITS" to GMP

From: Date: Mon, 02 Jul 2018 16:06:17 +0000
Subject: Req #62375 [Wfx]: Add constant "GMP_LIMB_BITS" to GMP
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216074@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62375&edit=1 ID: 62375 Updated by: nikic@php.net Reported by: info at bastian-born dot de Summary: Add constant "GMP_LIMB_BITS" to GMP Status: Wont fix Type: Feature/Change Request Package: GNU MP related Operating System: All PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Just for the record, gmp_random() has indeed been deprecated in PHP 7.2. Previous Comments: ------------------------------------------------------------------------ [2016-03-27 12:55:22] 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? ------------------------------------------------------------------------ [2016-03-26 11:35:22] nikic@php.net 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.) ------------------------------------------------------------------------ [2015-09-24 20:43:31] 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. ------------------------------------------------------------------------ [2012-06-20 18:16:47] info at bastian-born dot de Description: ------------ 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: --------------- <?php 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62375&edit=1

« previous php.bugs (#216074) next »