diff options
author | Anatol Belski <ab@php.net> | 2014-09-25 18:48:27 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-09-25 18:48:27 +0200 |
commit | d11734b4b00f57de80d931ad1c522e00082443af (patch) | |
tree | c4fdd11760b3db34994144b4cd5b4c169eaf71d4 /main | |
parent | a2dd6069420c77b4f070ef10916be0d5c9afe84f (diff) | |
download | php-git-d11734b4b00f57de80d931ad1c522e00082443af.tar.gz |
reworked the patch, less new stuff but worky
TLS is already used in TSRM, the way exporting the tsrm cache through
a thread local variable is not portable. Additionally, the current
patch suffers from bugs which are hard to find, but prevent it to
be worky with apache. What is done here is mainly uses the idea
from the RFC patch, but
- __thread variable is removed
- offset math and declarations are removed
- extra macros and definitions are removed
What is done merely is
- use an inline function to access the tsrm cache. The function uses
the portable tsrm_tls_get macro which is cheap
- all the TSRM_* macros are set to placebo. Thus this opens the way
remove them later
Except that, the logic is old. TSRMLS_FETCH will have to be done once
per thread, then tsrm_get_ls_cache() can be used. Things seeming to be
worky are cli, cli server and apache. I also tried to enable bz2
shared and it has worked out of the box. The change is yet minimal
diffing to the current master bus is a worky start, IMHO. Though will
have to recheck the other previously done SAPIs - embed and cgi.
The offsets can be added to the tsrm_resource_type struct, then
it'll not be needed to declare them in the userspace. Even the
"done" member type can be changed to int16 or smaller, then adding
the offset as int16 will not change the struct size. As well on the
todo might be removing the hashed storage, thread_id != thread_id and
linked list logic in favour of the explicit TLS operations.
Diffstat (limited to 'main')
-rw-r--r-- | main/SAPI.c | 4 | ||||
-rw-r--r-- | main/SAPI.h | 2 | ||||
-rw-r--r-- | main/main.c | 9 | ||||
-rw-r--r-- | main/output.c | 2 | ||||
-rw-r--r-- | main/php.h | 2 | ||||
-rw-r--r-- | main/php_globals.h | 2 | ||||
-rw-r--r-- | main/php_output.h | 1 |
7 files changed, 11 insertions, 11 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index f00e3c728b..50ea8c0a16 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -52,7 +52,7 @@ #include "php_content_types.h" #ifdef ZTS -TSRMG_D(sapi_globals_struct, sapi_globals_id); +SAPI_API int sapi_globals_id; #else sapi_globals_struct sapi_globals; #endif @@ -88,7 +88,7 @@ SAPI_API void sapi_startup(sapi_module_struct *sf) sapi_module = *sf; #ifdef ZTS - TSRMG_ALLOCATE(sapi_globals_id, sizeof(sapi_globals_struct), (ts_allocate_ctor) sapi_globals_ctor, (ts_allocate_dtor) sapi_globals_dtor); + ts_allocate_id(&sapi_globals_id, sizeof(sapi_globals_struct), (ts_allocate_ctor) sapi_globals_ctor, (ts_allocate_dtor) sapi_globals_dtor); # ifdef PHP_WIN32 _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); # endif diff --git a/main/SAPI.h b/main/SAPI.h index 4e2b4cd420..79661371d9 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -143,7 +143,7 @@ typedef struct _sapi_globals_struct { BEGIN_EXTERN_C() #ifdef ZTS # define SG(v) TSRMG(sapi_globals_id, sapi_globals_struct *, v) -TSRMG_DH(sapi_globals_struct, sapi_globals_id); +SAPI_API extern int sapi_globals_id; #else # define SG(v) (sapi_globals.v) extern SAPI_API sapi_globals_struct sapi_globals; diff --git a/main/main.c b/main/main.c index 2a78d4b0d2..63144de418 100644 --- a/main/main.c +++ b/main/main.c @@ -124,7 +124,7 @@ PHPAPI int (*php_register_internal_extensions_func)(TSRMLS_D) = php_register_int #ifndef ZTS php_core_globals core_globals; #else -TSRMG_D(php_core_globals, core_globals_id); +PHPAPI int core_globals_id; #endif #ifdef PHP_WIN32 @@ -2048,6 +2048,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod zend_module_entry *module; #ifdef ZTS zend_executor_globals *executor_globals; + void ***tsrm_ls; php_core_globals *core_globals; #endif @@ -2072,7 +2073,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod #endif #ifdef ZTS - TSRMLS_INIT(); + tsrm_ls = ts_resource(0); #endif #ifdef PHP_WIN32 @@ -2111,10 +2112,10 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod #ifdef ZTS executor_globals = ts_resource(executor_globals_id); - TSRMG_ALLOCATE(core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor); + ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor); core_globals = ts_resource(core_globals_id); #ifdef PHP_WIN32 - TSRMG_ALLOCATE(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); + 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 #else php_startup_ticks(TSRMLS_C); diff --git a/main/output.c b/main/output.c index 65c8152bc0..2f3f8d5a34 100644 --- a/main/output.c +++ b/main/output.c @@ -160,7 +160,7 @@ PHPAPI void php_output_shutdown(void) PHPAPI int php_output_activate(TSRMLS_D) { #ifdef ZTS - //memset((*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(output_globals_id)], 0, sizeof(zend_output_globals)); + memset((*((void ***) tsrm_get_ls_cache()))[TSRM_UNSHUFFLE_RSRC_ID(output_globals_id)], 0, sizeof(zend_output_globals)); #else memset(&output_globals, 0, sizeof(zend_output_globals)); #endif diff --git a/main/php.h b/main/php.h index 224a65dd82..2a683e1924 100644 --- a/main/php.h +++ b/main/php.h @@ -301,7 +301,7 @@ static inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling() {} PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC) PHP_ATTRIBUTE_FORMAT(printf, 4, 0); -#ifdef PASS_TSRMLS +#ifdef ZTS #define PHP_ATTR_FMT_OFFSET 1 #else #define PHP_ATTR_FMT_OFFSET 0 diff --git a/main/php_globals.h b/main/php_globals.h index 0e088d20f0..a60efe69de 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -27,7 +27,7 @@ typedef struct _php_core_globals php_core_globals; #ifdef ZTS # define PG(v) TSRMG(core_globals_id, php_core_globals *, v) -TSRMG_DH(php_core_globals, core_globals_id); +extern PHPAPI int core_globals_id; #else # define PG(v) (core_globals.v) extern ZEND_API struct _php_core_globals core_globals; diff --git a/main/php_output.h b/main/php_output.h index d3c3e072d0..02b2b85d13 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -153,7 +153,6 @@ ZEND_END_MODULE_GLOBALS(output) /* there should not be a need to use OG() from outside of output.c */ #ifdef ZTS -TSRMG_DH(php_output_globals, output_globals_id); # define OG(v) TSRMG(output_globals_id, zend_output_globals *, v) #else # define OG(v) (output_globals.v) |