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 --- main/php_output.h | 1 + 1 file changed, 1 insertion(+) (limited to 'main/php_output.h') diff --git a/main/php_output.h b/main/php_output.h index 02b2b85d13..d3c3e072d0 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -153,6 +153,7 @@ 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) -- 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. --- main/php_output.h | 1 - 1 file changed, 1 deletion(-) (limited to 'main/php_output.h') 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) -- cgit v1.2.1 From f7900367116f333b5a4582b29a2c1f7d2d9b6453 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Fri, 26 Sep 2014 11:06:02 +0200 Subject: some cleanups for TSRMLS_FETCH and direct tsrm_ls usage in main --- main/php_output.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'main/php_output.h') diff --git a/main/php_output.h b/main/php_output.h index 02b2b85d13..bcce8720e1 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -102,13 +102,8 @@ typedef struct _php_output_context { int op; php_output_buffer in; php_output_buffer out; -#ifdef ZTS - void ***tsrm_ls; -#endif } php_output_context; -#define PHP_OUTPUT_TSRMLS(ctx) TSRMLS_FETCH_FROM_CTX((ctx)->tsrm_ls) - /* old-style, stateless callback */ typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC); /* new-style, opaque context callback */ -- cgit v1.2.1 From ebaa6a74a51d435c81489d7ea5df41e286135465 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Tue, 7 Oct 2014 09:09:46 +0200 Subject: force more static tsrmls cache usage --- main/php_output.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main/php_output.h') diff --git a/main/php_output.h b/main/php_output.h index bcce8720e1..69a45878cd 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -148,7 +148,7 @@ ZEND_END_MODULE_GLOBALS(output) /* there should not be a need to use OG() from outside of output.c */ #ifdef ZTS -# define OG(v) TSRMG(output_globals_id, zend_output_globals *, v) +# define OG(v) ZEND_TSRMG(output_globals_id, zend_output_globals *, v) #else # define OG(v) (output_globals.v) #endif -- cgit v1.2.1 From c00424e427930a33e6d8645cc3f23fb78ed29b9f Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 15 Oct 2014 09:37:55 +0200 Subject: bring back all the TSRMLS_FETCH() stuff for better comparability with the mainstream --- main/php_output.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'main/php_output.h') diff --git a/main/php_output.h b/main/php_output.h index 69a45878cd..17cec92e53 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -104,6 +104,9 @@ typedef struct _php_output_context { php_output_buffer out; } php_output_context; +/* XXX remove this after TLS branch merge */ +#define PHP_OUTPUT_TSRMLS(ctx) + /* old-style, stateless callback */ typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC); /* new-style, opaque context callback */ -- 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 --- main/php_output.h | 126 +++++++++++++++++++++++++++--------------------------- 1 file changed, 63 insertions(+), 63 deletions(-) (limited to 'main/php_output.h') diff --git a/main/php_output.h b/main/php_output.h index bf756de5ce..f2f5848280 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -108,15 +108,15 @@ typedef struct _php_output_context { #define PHP_OUTPUT_TSRMLS(ctx) /* old-style, stateless callback */ -typedef void (*php_output_handler_func_t)(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode TSRMLS_DC); +typedef void (*php_output_handler_func_t)(char *output, size_t output_len, char **handled_output, size_t *handled_output_len, int mode); /* new-style, opaque context callback */ typedef int (*php_output_handler_context_func_t)(void **handler_context, php_output_context *output_context); /* output handler context dtor */ -typedef void (*php_output_handler_context_dtor_t)(void *opaq TSRMLS_DC); +typedef void (*php_output_handler_context_dtor_t)(void *opaq); /* conflict check callback */ -typedef int (*php_output_handler_conflict_check_t)(const char *handler_name, size_t handler_name_len TSRMLS_DC); +typedef int (*php_output_handler_conflict_check_t)(const char *handler_name, size_t handler_name_len); /* ctor for aliases */ -typedef struct _php_output_handler *(*php_output_handler_alias_ctor_t)(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags TSRMLS_DC); +typedef struct _php_output_handler *(*php_output_handler_alias_ctor_t)(const char *handler_name, size_t handler_name_len, size_t chunk_size, int flags); typedef struct _php_output_handler_user_func_t { zend_fcall_info fci; @@ -132,7 +132,7 @@ typedef struct _php_output_handler { php_output_buffer buffer; void *opaq; - void (*dtor)(void *opaq TSRMLS_DC); + void (*dtor)(void *opaq); union { php_output_handler_user_func_t *user; @@ -159,19 +159,19 @@ PHPAPI ZEND_EXTERN_MODULE_GLOBALS(output); #endif /* convenience macros */ -#define PHPWRITE(str, str_len) php_output_write((str), (str_len) TSRMLS_CC) -#define PHPWRITE_H(str, str_len) php_output_write_unbuffered((str), (str_len) TSRMLS_CC) +#define PHPWRITE(str, str_len) php_output_write((str), (str_len)) +#define PHPWRITE_H(str, str_len) php_output_write_unbuffered((str), (str_len)) -#define PUTC(c) (php_output_write(&(c), 1 TSRMLS_CC), (c)) -#define PUTC_H(c) (php_output_write_unbuffered(&(c), 1 TSRMLS_CC), (c)) +#define PUTC(c) (php_output_write(&(c), 1), (c)) +#define PUTC_H(c) (php_output_write_unbuffered(&(c), 1), (c)) #define PUTS(str) do { \ const char *__str = (str); \ - php_output_write(__str, strlen(__str) TSRMLS_CC); \ + php_output_write(__str, strlen(__str)); \ } while (0) #define PUTS_H(str) do { \ const char *__str = (str); \ - php_output_write_unbuffered(__str, strlen(__str) TSRMLS_CC); \ + php_output_write_unbuffered(__str, strlen(__str)); \ } while (0) @@ -182,10 +182,10 @@ extern const char php_output_devnull_handler_name[sizeof("null output handler")] #define php_output_tearup() \ php_output_startup(); \ - php_output_activate(TSRMLS_C) + php_output_activate() #define php_output_teardown() \ - php_output_end_all(TSRMLS_C); \ - php_output_deactivate(TSRMLS_C); \ + php_output_end_all(); \ + php_output_deactivate(); \ php_output_shutdown() /* MINIT */ @@ -193,58 +193,58 @@ PHPAPI void php_output_startup(void); /* MSHUTDOWN */ PHPAPI void php_output_shutdown(void); -PHPAPI void php_output_register_constants(TSRMLS_D); +PHPAPI void php_output_register_constants(void); /* RINIT */ -PHPAPI int php_output_activate(TSRMLS_D); +PHPAPI int php_output_activate(void); /* RSHUTDOWN */ -PHPAPI void php_output_deactivate(TSRMLS_D); - -PHPAPI void php_output_set_status(int status TSRMLS_DC); -PHPAPI int php_output_get_status(TSRMLS_D); -PHPAPI void php_output_set_implicit_flush(int flush TSRMLS_DC); -PHPAPI const char *php_output_get_start_filename(TSRMLS_D); -PHPAPI int php_output_get_start_lineno(TSRMLS_D); - -PHPAPI size_t php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC); -PHPAPI size_t php_output_write(const char *str, size_t len TSRMLS_DC); - -PHPAPI int php_output_flush(TSRMLS_D); -PHPAPI void php_output_flush_all(TSRMLS_D); -PHPAPI int php_output_clean(TSRMLS_D); -PHPAPI void php_output_clean_all(TSRMLS_D); -PHPAPI int php_output_end(TSRMLS_D); -PHPAPI void php_output_end_all(TSRMLS_D); -PHPAPI int php_output_discard(TSRMLS_D); -PHPAPI void php_output_discard_all(TSRMLS_D); - -PHPAPI int php_output_get_contents(zval *p TSRMLS_DC); -PHPAPI int php_output_get_length(zval *p TSRMLS_DC); -PHPAPI int php_output_get_level(TSRMLS_D); -PHPAPI php_output_handler* php_output_get_active_handler(TSRMLS_D); - -PHPAPI int php_output_start_default(TSRMLS_D); -PHPAPI int php_output_start_devnull(TSRMLS_D); - -PHPAPI int php_output_start_user(zval *output_handler, size_t chunk_size, int flags TSRMLS_DC); -PHPAPI int php_output_start_internal(const char *name, size_t name_len, php_output_handler_func_t output_handler, size_t chunk_size, int flags TSRMLS_DC); - -PHPAPI php_output_handler *php_output_handler_create_user(zval *handler, size_t chunk_size, int flags TSRMLS_DC); -PHPAPI php_output_handler *php_output_handler_create_internal(const char *name, size_t name_len, php_output_handler_context_func_t handler, size_t chunk_size, int flags TSRMLS_DC); - -PHPAPI void php_output_handler_set_context(php_output_handler *handler, void *opaq, void (*dtor)(void* TSRMLS_DC) TSRMLS_DC); -PHPAPI int php_output_handler_start(php_output_handler *handler TSRMLS_DC); -PHPAPI int php_output_handler_started(const char *name, size_t name_len TSRMLS_DC); -PHPAPI int php_output_handler_hook(php_output_handler_hook_t type, void *arg TSRMLS_DC); -PHPAPI void php_output_handler_dtor(php_output_handler *handler TSRMLS_DC); -PHPAPI void php_output_handler_free(php_output_handler **handler TSRMLS_DC); - -PHPAPI int php_output_handler_conflict(const char *handler_new, size_t handler_new_len, const char *handler_set, size_t handler_set_len TSRMLS_DC); -PHPAPI int php_output_handler_conflict_register(const char *handler_name, size_t handler_name_len, php_output_handler_conflict_check_t check_func TSRMLS_DC); -PHPAPI int php_output_handler_reverse_conflict_register(const char *handler_name, size_t handler_name_len, php_output_handler_conflict_check_t check_func TSRMLS_DC); - -PHPAPI php_output_handler_alias_ctor_t php_output_handler_alias(const char *handler_name, size_t handler_name_len TSRMLS_DC); -PHPAPI int php_output_handler_alias_register(const char *handler_name, size_t handler_name_len, php_output_handler_alias_ctor_t func TSRMLS_DC); +PHPAPI void php_output_deactivate(void); + +PHPAPI void php_output_set_status(int status); +PHPAPI int php_output_get_status(void); +PHPAPI void php_output_set_implicit_flush(int flush); +PHPAPI const char *php_output_get_start_filename(void); +PHPAPI int php_output_get_start_lineno(void); + +PHPAPI size_t php_output_write_unbuffered(const char *str, size_t len); +PHPAPI size_t php_output_write(const char *str, size_t len); + +PHPAPI int php_output_flush(void); +PHPAPI void php_output_flush_all(void); +PHPAPI int php_output_clean(void); +PHPAPI void php_output_clean_all(void); +PHPAPI int php_output_end(void); +PHPAPI void php_output_end_all(void); +PHPAPI int php_output_discard(void); +PHPAPI void php_output_discard_all(void); + +PHPAPI int php_output_get_contents(zval *p); +PHPAPI int php_output_get_length(zval *p); +PHPAPI int php_output_get_level(void); +PHPAPI php_output_handler* php_output_get_active_handler(void); + +PHPAPI int php_output_start_default(void); +PHPAPI int php_output_start_devnull(void); + +PHPAPI int php_output_start_user(zval *output_handler, size_t chunk_size, int flags); +PHPAPI int php_output_start_internal(const char *name, size_t name_len, php_output_handler_func_t output_handler, size_t chunk_size, int flags); + +PHPAPI php_output_handler *php_output_handler_create_user(zval *handler, size_t chunk_size, int flags); +PHPAPI php_output_handler *php_output_handler_create_internal(const char *name, size_t name_len, php_output_handler_context_func_t handler, size_t chunk_size, int flags); + +PHPAPI void php_output_handler_set_context(php_output_handler *handler, void *opaq, void (*dtor)(void*)); +PHPAPI int php_output_handler_start(php_output_handler *handler); +PHPAPI int php_output_handler_started(const char *name, size_t name_len); +PHPAPI int php_output_handler_hook(php_output_handler_hook_t type, void *arg); +PHPAPI void php_output_handler_dtor(php_output_handler *handler); +PHPAPI void php_output_handler_free(php_output_handler **handler); + +PHPAPI int php_output_handler_conflict(const char *handler_new, size_t handler_new_len, const char *handler_set, size_t handler_set_len); +PHPAPI int php_output_handler_conflict_register(const char *handler_name, size_t handler_name_len, php_output_handler_conflict_check_t check_func); +PHPAPI int php_output_handler_reverse_conflict_register(const char *handler_name, size_t handler_name_len, php_output_handler_conflict_check_t check_func); + +PHPAPI php_output_handler_alias_ctor_t php_output_handler_alias(const char *handler_name, size_t handler_name_len); +PHPAPI int php_output_handler_alias_register(const char *handler_name, size_t handler_name_len, php_output_handler_alias_ctor_t func); END_EXTERN_C() -- cgit v1.2.1