From b3aebda9eaf55706af2e21178f229a171725a168 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sat, 20 Sep 2014 20:22:14 +0100 Subject: native tls initial patch --- sapi/embed/php_embed.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sapi/embed/php_embed.h') diff --git a/sapi/embed/php_embed.h b/sapi/embed/php_embed.h index b62fd9fe24..a109a1bba2 100644 --- a/sapi/embed/php_embed.h +++ b/sapi/embed/php_embed.h @@ -27,14 +27,14 @@ #include
#include -#ifdef ZTS -#define PTSRMLS_D void ****ptsrm_ls +#ifdef PASS_TSRMLS +#define PTSRMLS_D void ***ptsrm_ls #define PTSRMLS_DC , PTSRMLS_D #define PTSRMLS_C &tsrm_ls #define PTSRMLS_CC , PTSRMLS_C #define PHP_EMBED_START_BLOCK(x,y) { \ - void ***tsrm_ls; \ + void **tsrm_ls; \ php_embed_init(x, y PTSRMLS_CC); \ zend_first_try { -- cgit v1.2.1 From d11734b4b00f57de80d931ad1c522e00082443af Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Thu, 25 Sep 2014 18:48:27 +0200 Subject: 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. --- sapi/embed/php_embed.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sapi/embed/php_embed.h') diff --git a/sapi/embed/php_embed.h b/sapi/embed/php_embed.h index a109a1bba2..b62fd9fe24 100644 --- a/sapi/embed/php_embed.h +++ b/sapi/embed/php_embed.h @@ -27,14 +27,14 @@ #include
#include -#ifdef PASS_TSRMLS -#define PTSRMLS_D void ***ptsrm_ls +#ifdef ZTS +#define PTSRMLS_D void ****ptsrm_ls #define PTSRMLS_DC , PTSRMLS_D #define PTSRMLS_C &tsrm_ls #define PTSRMLS_CC , PTSRMLS_C #define PHP_EMBED_START_BLOCK(x,y) { \ - void **tsrm_ls; \ + void ***tsrm_ls; \ php_embed_init(x, y PTSRMLS_CC); \ zend_first_try { -- cgit v1.2.1 From bdeb220f48825642f84cdbf3ff23a30613c92e86 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 13 Dec 2014 23:06:14 +0100 Subject: first shot remove TSRMLS_* things --- sapi/embed/php_embed.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sapi/embed/php_embed.h') diff --git a/sapi/embed/php_embed.h b/sapi/embed/php_embed.h index b62fd9fe24..e29f99766b 100644 --- a/sapi/embed/php_embed.h +++ b/sapi/embed/php_embed.h @@ -54,7 +54,7 @@ } zend_catch { \ /* int exit_status = EG(exit_status); */ \ } zend_end_try(); \ - php_embed_shutdown(TSRMLS_C); \ + php_embed_shutdown(); \ } #ifndef PHP_WIN32 @@ -65,7 +65,7 @@ BEGIN_EXTERN_C() EMBED_SAPI_API int php_embed_init(int argc, char **argv PTSRMLS_DC); -EMBED_SAPI_API void php_embed_shutdown(TSRMLS_D); +EMBED_SAPI_API void php_embed_shutdown(void); extern EMBED_SAPI_API sapi_module_struct php_embed_module; END_EXTERN_C() -- cgit v1.2.1 From af21b3b6dcef4ce0c04f3e8126574f5660fd0a83 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 17 Dec 2014 10:52:28 +0100 Subject: get rid of TSRMLS_* in the embed SAPI --- sapi/embed/php_embed.h | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'sapi/embed/php_embed.h') diff --git a/sapi/embed/php_embed.h b/sapi/embed/php_embed.h index e29f99766b..82afa686d2 100644 --- a/sapi/embed/php_embed.h +++ b/sapi/embed/php_embed.h @@ -27,29 +27,10 @@ #include
#include -#ifdef ZTS -#define PTSRMLS_D void ****ptsrm_ls -#define PTSRMLS_DC , PTSRMLS_D -#define PTSRMLS_C &tsrm_ls -#define PTSRMLS_CC , PTSRMLS_C - -#define PHP_EMBED_START_BLOCK(x,y) { \ - void ***tsrm_ls; \ - php_embed_init(x, y PTSRMLS_CC); \ - zend_first_try { - -#else -#define PTSRMLS_D -#define PTSRMLS_DC -#define PTSRMLS_C -#define PTSRMLS_CC - #define PHP_EMBED_START_BLOCK(x,y) { \ php_embed_init(x, y); \ zend_first_try { -#endif - #define PHP_EMBED_END_BLOCK() \ } zend_catch { \ /* int exit_status = EG(exit_status); */ \ @@ -63,8 +44,12 @@ #define EMBED_SAPI_API #endif +#ifdef ZTS +ZEND_TSRMLS_CACHE_EXTERN; +#endif + BEGIN_EXTERN_C() -EMBED_SAPI_API int php_embed_init(int argc, char **argv PTSRMLS_DC); +EMBED_SAPI_API int php_embed_init(int argc, char **argv); EMBED_SAPI_API void php_embed_shutdown(void); extern EMBED_SAPI_API sapi_module_struct php_embed_module; END_EXTERN_C() -- cgit v1.2.1