diff options
author | Dmitry Stogov <dmitry@zend.com> | 2019-03-14 03:01:01 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2019-03-14 03:01:01 +0300 |
commit | 9499484ed2f0377678b2b4d88573327ee0e4ce6d (patch) | |
tree | 2253189b70e711565902d2c372fe5d93ce111358 /main/main.c | |
parent | a1b7bc0c8148eaf728fccdffe147e3bc0c03f18e (diff) | |
download | php-git-9499484ed2f0377678b2b4d88573327ee0e4ce6d.tar.gz |
Implemented a faster way to access predefined TSRM resources - CG(), EG(), etc.
Diffstat (limited to 'main/main.c')
-rw-r--r-- | main/main.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/main/main.c b/main/main.c index 5e18630bd9..6286990f62 100644 --- a/main/main.c +++ b/main/main.c @@ -116,6 +116,7 @@ PHPAPI int (*php_register_internal_extensions_func)(void) = php_register_interna php_core_globals core_globals; #else PHPAPI int core_globals_id; +PHPAPI size_t core_globals_offset; #endif #define SAFE_FILENAME(f) ((f)?(f):"-") @@ -2151,7 +2152,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod php_output_startup(); #ifdef ZTS - ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor); + ts_allocate_fast_id(&core_globals_id, &core_globals_offset, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor); #ifdef PHP_WIN32 ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor) php_win32_core_globals_ctor, (ts_allocate_dtor) php_win32_core_globals_dtor); #endif @@ -2774,3 +2775,37 @@ PHPAPI int php_lint_script(zend_file_handle *file) return retval; } /* }}} */ + +#ifdef ZTS +/* {{{ php_reserve_tsrm_memory + */ +PHPAPI void php_reserve_tsrm_memory(void) +{ + tsrm_reserve( + TSRM_ALIGNED_SIZE(sizeof(zend_compiler_globals)) + + TSRM_ALIGNED_SIZE(sizeof(zend_executor_globals)) + + TSRM_ALIGNED_SIZE(sizeof(zend_php_scanner_globals)) + + TSRM_ALIGNED_SIZE(sizeof(zend_ini_scanner_globals)) + + TSRM_ALIGNED_SIZE(sizeof(virtual_cwd_globals)) + +#ifdef ZEND_SIGNALS + TSRM_ALIGNED_SIZE(sizeof(zend_signal_globals_t)) + +#endif + TSRM_ALIGNED_SIZE(zend_mm_globals_size()) + + TSRM_ALIGNED_SIZE(zend_gc_globals_size()) + + TSRM_ALIGNED_SIZE(sizeof(php_core_globals)) + + TSRM_ALIGNED_SIZE(sizeof(sapi_globals_struct)) + ); +} +/* }}} */ + +/* {{{ php_tsrm_startup + */ +PHPAPI int php_tsrm_startup(void) +{ + int ret = tsrm_startup(1, 1, 0, NULL); + php_reserve_tsrm_memory(); + (void)ts_resource(0); + return ret; +} +/* }}} */ +#endif |