43
43
ZEND_GET_MODULE (spl )
44
44
#endif
45
45
46
- ZEND_DECLARE_MODULE_GLOBALS (spl )
46
+ ZEND_TLS zend_string * spl_autoload_extensions ;
47
+ ZEND_TLS HashTable * spl_autoload_functions ;
47
48
48
49
#define SPL_DEFAULT_FILE_EXTENSIONS ".inc,.php"
49
50
50
- /* {{{ PHP_GINIT_FUNCTION */
51
- static PHP_GINIT_FUNCTION (spl )
52
- {
53
- spl_globals -> autoload_extensions = NULL ;
54
- spl_globals -> autoload_functions = NULL ;
55
- }
56
- /* }}} */
57
-
58
51
static zend_class_entry * spl_find_ce_by_name (zend_string * name , bool autoload )
59
52
{
60
53
zend_class_entry * ce ;
@@ -307,7 +300,7 @@ PHP_FUNCTION(spl_autoload)
307
300
}
308
301
309
302
if (!file_exts ) {
310
- file_exts = SPL_G ( autoload_extensions ) ;
303
+ file_exts = spl_autoload_extensions ;
311
304
}
312
305
313
306
if (file_exts == NULL ) { /* autoload_extensions is not initialized, set to defaults */
@@ -345,17 +338,17 @@ PHP_FUNCTION(spl_autoload_extensions)
345
338
}
346
339
347
340
if (file_exts ) {
348
- if (SPL_G ( autoload_extensions ) ) {
349
- zend_string_release_ex (SPL_G ( autoload_extensions ) , 0 );
341
+ if (spl_autoload_extensions ) {
342
+ zend_string_release_ex (spl_autoload_extensions , 0 );
350
343
}
351
- SPL_G ( autoload_extensions ) = zend_string_copy (file_exts );
344
+ spl_autoload_extensions = zend_string_copy (file_exts );
352
345
}
353
346
354
- if (SPL_G ( autoload_extensions ) == NULL ) {
347
+ if (spl_autoload_extensions == NULL ) {
355
348
RETURN_STRINGL (SPL_DEFAULT_FILE_EXTENSIONS , sizeof (SPL_DEFAULT_FILE_EXTENSIONS ) - 1 );
356
349
} else {
357
- zend_string_addref (SPL_G ( autoload_extensions ) );
358
- RETURN_STR (SPL_G ( autoload_extensions ) );
350
+ zend_string_addref (spl_autoload_extensions );
351
+ RETURN_STR (spl_autoload_extensions );
359
352
}
360
353
} /* }}} */
361
354
@@ -413,17 +406,17 @@ static bool autoload_func_info_equals(
413
406
}
414
407
415
408
static zend_class_entry * spl_perform_autoload (zend_string * class_name , zend_string * lc_name ) {
416
- if (!SPL_G ( autoload_functions ) ) {
409
+ if (!spl_autoload_functions ) {
417
410
return NULL ;
418
411
}
419
412
420
413
/* We don't use ZEND_HASH_FOREACH here,
421
414
* because autoloaders may be added/removed during autoloading. */
422
415
HashPosition pos ;
423
- zend_hash_internal_pointer_reset_ex (SPL_G ( autoload_functions ) , & pos );
416
+ zend_hash_internal_pointer_reset_ex (spl_autoload_functions , & pos );
424
417
while (1 ) {
425
418
autoload_func_info * alfi =
426
- zend_hash_get_current_data_ptr_ex (SPL_G ( autoload_functions ) , & pos );
419
+ zend_hash_get_current_data_ptr_ex (spl_autoload_functions , & pos );
427
420
if (!alfi ) {
428
421
break ;
429
422
}
@@ -451,7 +444,7 @@ static zend_class_entry *spl_perform_autoload(zend_string *class_name, zend_stri
451
444
}
452
445
}
453
446
454
- zend_hash_move_forward_ex (SPL_G ( autoload_functions ) , & pos );
447
+ zend_hash_move_forward_ex (spl_autoload_functions , & pos );
455
448
}
456
449
return NULL ;
457
450
}
@@ -480,12 +473,12 @@ PHP_FUNCTION(spl_autoload_call)
480
473
} while (0)
481
474
482
475
static Bucket * spl_find_registered_function (autoload_func_info * find_alfi ) {
483
- if (!SPL_G ( autoload_functions ) ) {
476
+ if (!spl_autoload_functions ) {
484
477
return NULL ;
485
478
}
486
479
487
480
autoload_func_info * alfi ;
488
- ZEND_HASH_FOREACH_PTR (SPL_G ( autoload_functions ) , alfi ) {
481
+ ZEND_HASH_FOREACH_PTR (spl_autoload_functions , alfi ) {
489
482
if (autoload_func_info_equals (alfi , find_alfi )) {
490
483
return _p ;
491
484
}
@@ -514,11 +507,11 @@ PHP_FUNCTION(spl_autoload_register)
514
507
"spl_autoload_register() will always throw" );
515
508
}
516
509
517
- if (!SPL_G ( autoload_functions ) ) {
518
- ALLOC_HASHTABLE (SPL_G ( autoload_functions ) );
519
- zend_hash_init (SPL_G ( autoload_functions ) , 1 , NULL , autoload_func_info_zval_dtor , 0 );
510
+ if (!spl_autoload_functions ) {
511
+ ALLOC_HASHTABLE (spl_autoload_functions );
512
+ zend_hash_init (spl_autoload_functions , 1 , NULL , autoload_func_info_zval_dtor , 0 );
520
513
/* Initialize as non-packed hash table for prepend functionality. */
521
- zend_hash_real_init_mixed (SPL_G ( autoload_functions ) );
514
+ zend_hash_real_init_mixed (spl_autoload_functions );
522
515
}
523
516
524
517
/* If first arg is not null */
@@ -558,10 +551,10 @@ PHP_FUNCTION(spl_autoload_register)
558
551
RETURN_TRUE ;
559
552
}
560
553
561
- zend_hash_next_index_insert_ptr (SPL_G ( autoload_functions ) , alfi );
562
- if (prepend && SPL_G ( autoload_functions ) -> nNumOfElements > 1 ) {
554
+ zend_hash_next_index_insert_ptr (spl_autoload_functions , alfi );
555
+ if (prepend && spl_autoload_functions -> nNumOfElements > 1 ) {
563
556
/* Move the newly created element to the head of the hashtable */
564
- HT_MOVE_TAIL_TO_HEAD (SPL_G ( autoload_functions ) );
557
+ HT_MOVE_TAIL_TO_HEAD (spl_autoload_functions );
565
558
}
566
559
567
560
RETURN_TRUE ;
@@ -580,15 +573,15 @@ PHP_FUNCTION(spl_autoload_unregister)
580
573
if (fcc .function_handler && zend_string_equals_literal (
581
574
fcc .function_handler -> common .function_name , "spl_autoload_call" )) {
582
575
/* Don't destroy the hash table, as we might be iterating over it right now. */
583
- zend_hash_clean (SPL_G ( autoload_functions ) );
576
+ zend_hash_clean (spl_autoload_functions );
584
577
RETURN_TRUE ;
585
578
}
586
579
587
580
autoload_func_info * alfi = autoload_func_info_from_fci (& fci , & fcc );
588
581
Bucket * p = spl_find_registered_function (alfi );
589
582
autoload_func_info_destroy (alfi );
590
583
if (p ) {
591
- zend_hash_del_bucket (SPL_G ( autoload_functions ) , p );
584
+ zend_hash_del_bucket (spl_autoload_functions , p );
592
585
RETURN_TRUE ;
593
586
}
594
587
@@ -605,8 +598,8 @@ PHP_FUNCTION(spl_autoload_functions)
605
598
}
606
599
607
600
array_init (return_value );
608
- if (SPL_G ( autoload_functions ) ) {
609
- ZEND_HASH_FOREACH_PTR (SPL_G ( autoload_functions ) , alfi ) {
601
+ if (spl_autoload_functions ) {
602
+ ZEND_HASH_FOREACH_PTR (spl_autoload_functions , alfi ) {
610
603
if (alfi -> closure ) {
611
604
GC_ADDREF (alfi -> closure );
612
605
add_next_index_object (return_value , alfi -> closure );
@@ -723,21 +716,21 @@ PHP_MINIT_FUNCTION(spl)
723
716
724
717
PHP_RINIT_FUNCTION (spl ) /* {{{ */
725
718
{
726
- SPL_G ( autoload_extensions ) = NULL ;
727
- SPL_G ( autoload_functions ) = NULL ;
719
+ spl_autoload_extensions = NULL ;
720
+ spl_autoload_functions = NULL ;
728
721
return SUCCESS ;
729
722
} /* }}} */
730
723
731
724
PHP_RSHUTDOWN_FUNCTION (spl ) /* {{{ */
732
725
{
733
- if (SPL_G ( autoload_extensions ) ) {
734
- zend_string_release_ex (SPL_G ( autoload_extensions ) , 0 );
735
- SPL_G ( autoload_extensions ) = NULL ;
726
+ if (spl_autoload_extensions ) {
727
+ zend_string_release_ex (spl_autoload_extensions , 0 );
728
+ spl_autoload_extensions = NULL ;
736
729
}
737
- if (SPL_G ( autoload_functions ) ) {
738
- zend_hash_destroy (SPL_G ( autoload_functions ) );
739
- FREE_HASHTABLE (SPL_G ( autoload_functions ) );
740
- SPL_G ( autoload_functions ) = NULL ;
730
+ if (spl_autoload_functions ) {
731
+ zend_hash_destroy (spl_autoload_functions );
732
+ FREE_HASHTABLE (spl_autoload_functions );
733
+ spl_autoload_functions = NULL ;
741
734
}
742
735
return SUCCESS ;
743
736
} /* }}} */
@@ -753,10 +746,6 @@ zend_module_entry spl_module_entry = {
753
746
PHP_RSHUTDOWN (spl ),
754
747
PHP_MINFO (spl ),
755
748
PHP_SPL_VERSION ,
756
- PHP_MODULE_GLOBALS (spl ),
757
- PHP_GINIT (spl ),
758
- NULL ,
759
- NULL ,
760
- STANDARD_MODULE_PROPERTIES_EX
749
+ STANDARD_MODULE_PROPERTIES
761
750
};
762
751
/* }}} */
0 commit comments