Re: libc and random functions
| From: | David Coallier | Date: | Thu, 19 Jul 2007 17:26:34 +0000 |
| Subject: | Re: libc and random functions | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-31106@lists.php.net to get a copy of this message | ||
On 7/19/07, David Coallier <davidc@php.net> wrote:
On 7/19/07, Antony Dovgal <antony@zend.com> wrote: On 19.07.2007 17:41, Keryx Web wrote:Sorry I did not quite answer your question in my email + patch. Yes it works correctly as it is, however, with this patch, the random numbers being generated are using an algorithm (Mersenne Twister) that allows us to give more randomness if I may use the term. So it simply doesn't *fix* anything, but improves random number generation. There are various reasons why people are using random generated numbers and mt_ is more random than rand*. Simply it. It does not **fix** something that is broken, simply improves it. Yes we could still use a rock to make fire, and it still works fine, but might as well use matches, lenses or lighters. It's more effective and faster.Ilia Alshanetsky wrote:What I don't understand about the crypt thing you propose - is what problem are you trying to fix this way? If there are no problems, then please don't improve anything not broken. "No reasons to keep it" is wrong, there is at least one reason to keep it as is - it works fine.Also @Antony Dovgal in the "let blocks" thread Short answer: No. The reason I posted my suggestions on this list was that a while ago I had a few ideas as to how PHP could be improved.Do you have a patch?
-- Wbr, Antony Dovgal -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php Here are three patches against HEAD [1], 5_2 [2] and the pecl repository [3] (Do not shout just yet, I'll explain). The idea of the patches are pretty simple, aliasing rand, srand, getrandmax to mt_rand, mt_srand, and mt_getrandmax. The goal is simply having a better number generation. Nothing fancier, or more different, but simply it. It works great (compiling great against 5_2, HEAD) and Crisitan Rodriguez also tried the compilation. After a bit of discussion with Jani, I came to realize that keeping the wrapper macro for php_rand, php_srand is plain useless. Yes some pecl extensions do rely on them (and for those who do, I also provided a patch [3]). We both realized that there's not many extensions relying on php_rand and php_srand thus removed it completely.. Here are the patches: [1] HEAD : http://dev.agoraproduction.com/php/php6/head-mt-changes.diff-- David Coallier, Founder & Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18[2] 5_2 : http://dev.agoraproduction.com/php/5_2/5.2-mt-changes.diff[3] PECL : http://dev.agoraproduction.com/php/php6/pecl-mt-changes.diff Please note that the mt-changes patches are not only changing ext/standard/* but also the ext/* relying on them. (soap, mcrypt) but also a small change in main/reentrancy.c both in 5_2 and HEAD. Thanks, -- David Coallier, Founder & Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18