@@ -776,6 +776,35 @@ PHP_FUNCTION(random_int)
776
776
}
777
777
/* }}} */
778
778
779
+ /* {{{ PHP_GINIT_FUNCTION */
780
+ static PHP_GINIT_FUNCTION (random )
781
+ {
782
+ random_globals -> random_fd = -1 ;
783
+
784
+ random_globals -> combined_lcg = php_random_status_alloc (& php_random_algo_combinedlcg , true);
785
+ random_globals -> combined_lcg_seeded = false;
786
+
787
+ random_globals -> mt19937 = php_random_status_alloc (& php_random_algo_mt19937 , true);
788
+ random_globals -> mt19937_seeded = false;
789
+ }
790
+ /* }}} */
791
+
792
+ /* {{{ PHP_GSHUTDOWN_FUNCTION */
793
+ static PHP_GSHUTDOWN_FUNCTION (random )
794
+ {
795
+ if (random_globals -> random_fd > 0 ) {
796
+ close (random_globals -> random_fd );
797
+ random_globals -> random_fd = -1 ;
798
+ }
799
+
800
+ php_random_status_free (random_globals -> combined_lcg , true);
801
+ random_globals -> combined_lcg = NULL ;
802
+
803
+ php_random_status_free (random_globals -> mt19937 , true);
804
+ random_globals -> mt19937 = NULL ;
805
+ }
806
+ /* }}} */
807
+
779
808
/* {{{ PHP_MINIT_FUNCTION */
780
809
PHP_MINIT_FUNCTION (random )
781
810
{
@@ -828,43 +857,13 @@ PHP_MINIT_FUNCTION(random)
828
857
REGISTER_LONG_CONSTANT ("MT_RAND_MT19937" , MT_RAND_MT19937 , CONST_CS | CONST_PERSISTENT );
829
858
REGISTER_LONG_CONSTANT ("MT_RAND_PHP" , MT_RAND_PHP , CONST_CS | CONST_PERSISTENT );
830
859
831
- RANDOM_G (random_fd ) = -1 ;
832
-
833
- RANDOM_G (combined_lcg ) = php_random_status_alloc (& php_random_algo_combinedlcg , true);
834
- RANDOM_G (combined_lcg_seeded ) = false;
835
-
836
- RANDOM_G (mt19937 ) = php_random_status_alloc (& php_random_algo_mt19937 , true);
837
- RANDOM_G (mt19937_seeded ) = false;
838
-
839
- return SUCCESS ;
840
- }
841
- /* }}} */
842
-
843
- /* {{{ PHP_MSHUTDOWN_FUNCTION */
844
- PHP_MSHUTDOWN_FUNCTION (random )
845
- {
846
- if (RANDOM_G (random_fd ) > 0 ) {
847
- close (RANDOM_G (random_fd ));
848
- RANDOM_G (random_fd ) = -1 ;
849
- }
850
-
851
- php_random_status_free (RANDOM_G (combined_lcg ), true);
852
- RANDOM_G (combined_lcg ) = NULL ;
853
-
854
- php_random_status_free (RANDOM_G (mt19937 ), true);
855
- RANDOM_G (mt19937 ) = NULL ;
856
-
857
860
return SUCCESS ;
858
861
}
859
862
/* }}} */
860
863
861
864
/* {{{ PHP_RINIT_FUNCTION */
862
865
PHP_RINIT_FUNCTION (random )
863
866
{
864
- #if defined(ZTS ) && defined(COMPILE_DL_RANDOM )
865
- ZEND_TSRMLS_CACHE_UPDATE ();
866
- #endif
867
-
868
867
RANDOM_G (combined_lcg_seeded ) = false;
869
868
RANDOM_G (mt19937_seeded ) = false;
870
869
@@ -878,14 +877,14 @@ zend_module_entry random_module_entry = {
878
877
"random" , /* Extension name */
879
878
ext_functions , /* zend_function_entry */
880
879
PHP_MINIT (random ), /* PHP_MINIT - Module initialization */
881
- PHP_MSHUTDOWN ( random ), /* PHP_MSHUTDOWN - Module shutdown */
880
+ NULL , /* PHP_MSHUTDOWN - Module shutdown */
882
881
PHP_RINIT (random ), /* PHP_RINIT - Request initialization */
883
882
NULL , /* PHP_RSHUTDOWN - Request shutdown */
884
883
NULL , /* PHP_MINFO - Module info */
885
884
PHP_VERSION , /* Version */
886
885
PHP_MODULE_GLOBALS (random ), /* ZTS Module globals */
887
- NULL , /* PHP_GINIT - Global initialization */
888
- NULL , /* PHP_GSHUTDOWN - Global shutdown */
886
+ PHP_GINIT ( random ), /* PHP_GINIT - Global initialization */
887
+ PHP_GSHUTDOWN ( random ), /* PHP_GSHUTDOWN - Global shutdown */
889
888
NULL , /* Post deactivate */
890
889
STANDARD_MODULE_PROPERTIES_EX
891
890
};
0 commit comments