Skip to content

Commit af5b15f

Browse files
committed
Random Extension: minor fixes
1 parent 3ccc236 commit af5b15f

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

ext/random_ext/php_random_ext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ PHPAPI zend_long php_random_range(php_random *random, zend_long min, zend_long m
6363
PHPAPI void php_random_array_data_shuffle(php_random *random, zval *array);
6464
PHPAPI void php_random_string_shuffle(php_random *random, char *str, zend_long len);
6565

66-
#endif /* PHP_RANDOM_H_MODULE */
66+
#endif /* PHP_RANDOM_EXT_H */

ext/random_ext/random_ext.c

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,50 @@
1414
+----------------------------------------------------------------------+
1515
*/
1616

17+
/*
18+
The following functions are based on a C++ class MTRand by
19+
Richard J. Wagner. For more information see the web page at
20+
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/C-LANG/MersenneTwister.h
21+
Mersenne Twister random number generator -- a C++ class MTRand
22+
Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
23+
Richard J. Wagner v1.0 15 May 2003 [email protected]
24+
The Mersenne Twister is an algorithm for generating random numbers. It
25+
was designed with consideration of the flaws in various other generators.
26+
The period, 2^19937-1, and the order of equidistribution, 623 dimensions,
27+
are far greater. The generator is also fast; it avoids multiplication and
28+
division, and it benefits from caches and pipelines. For more information
29+
see the inventors' web page at http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
30+
Reference
31+
M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally
32+
Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on
33+
Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30.
34+
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
35+
Copyright (C) 2000 - 2003, Richard J. Wagner
36+
All rights reserved.
37+
Redistribution and use in source and binary forms, with or without
38+
modification, are permitted provided that the following conditions
39+
are met:
40+
1. Redistributions of source code must retain the above copyright
41+
notice, this list of conditions and the following disclaimer.
42+
2. Redistributions in binary form must reproduce the above copyright
43+
notice, this list of conditions and the following disclaimer in the
44+
documentation and/or other materials provided with the distribution.
45+
3. The names of its contributors may not be used to endorse or promote
46+
products derived from this software without specific prior written
47+
permission.
48+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
51+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
52+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
53+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
54+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
55+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
56+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
57+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
58+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59+
*/
60+
1761
#ifdef HAVE_CONFIG_H
1862
# include "config.h"
1963
#endif
@@ -779,7 +823,7 @@ PHP_METHOD(Random, __unserialize)
779823
/* {{{ PHP_MINIT_FUNCTION */
780824
PHP_MINIT_FUNCTION(random_ext)
781825
{
782-
/* Random\NumberGenerator\RandomNumberGenerator */
826+
/* Random\NumberGenerator */
783827
random_ce_Random_NumberGenerator = register_class_Random_NumberGenerator();
784828

785829
/* Random\NumberGenerator\XorShift128Plus */

ext/random_ext/random_ext.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function generate(): int {}
5353
final class Random
5454
{
5555
// FIXME: stub generator (gen_stub.php) does not supported.
56-
// private Random\NumberGenerator\RandomNumberGenerator $rng;
56+
// private Random\NumberGeneratorm $rng;
5757
private mixed $rng;
5858

5959
public function __construct(?Random\NumberGenerator $rng = null) {}

ext/random_ext/random_ext_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: d5f5afc735100bce1a76f2a16522c5832a65b2f0 */
2+
* Stub hash: 72e03ec3a21486d6426fc0658f0c133247da141f */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Random_NumberGenerator_generate, 0, 0, IS_LONG, 0)
55
ZEND_END_ARG_INFO()

0 commit comments

Comments
 (0)