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/apache/php_apache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sapi/apache/php_apache.c') diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c index f6e9e61203..05bf75b226 100644 --- a/sapi/apache/php_apache.c +++ b/sapi/apache/php_apache.c @@ -129,7 +129,7 @@ static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRML static PHP_MINIT_FUNCTION(apache) { #ifdef ZTS - ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL); + TSRMG_ALLOCATE(php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL); #else php_apache_globals_ctor(&php_apache_info TSRMLS_CC); #endif -- 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/apache/php_apache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sapi/apache/php_apache.c') diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c index 05bf75b226..f6e9e61203 100644 --- a/sapi/apache/php_apache.c +++ b/sapi/apache/php_apache.c @@ -129,7 +129,7 @@ static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRML static PHP_MINIT_FUNCTION(apache) { #ifdef ZTS - TSRMG_ALLOCATE(php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL); + ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL); #else php_apache_globals_ctor(&php_apache_info TSRMLS_CC); #endif -- 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/apache/php_apache.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'sapi/apache/php_apache.c') diff --git a/sapi/apache/php_apache.c b/sapi/apache/php_apache.c index f6e9e61203..b151495b66 100644 --- a/sapi/apache/php_apache.c +++ b/sapi/apache/php_apache.c @@ -120,7 +120,7 @@ PHP_INI_END() -static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRMLS_DC) +static void php_apache_globals_ctor(php_apache_info_struct *apache_globals) { apache_globals->in_request = 0; } @@ -131,7 +131,7 @@ static PHP_MINIT_FUNCTION(apache) #ifdef ZTS ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL); #else - php_apache_globals_ctor(&php_apache_info TSRMLS_CC); + php_apache_globals_ctor(&php_apache_info); #endif REGISTER_INI_ENTRIES(); return SUCCESS; @@ -298,11 +298,11 @@ PHP_FUNCTION(apache_child_terminate) ap_child_terminate( ((request_rec *)SG(server_context)) ); RETURN_TRUE; } else { /* tell them to get lost! */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function is disabled"); + php_error_docref(NULL, E_WARNING, "This function is disabled"); RETURN_FALSE; } #else - php_error_docref(NULL TSRMLS_CC, E_WARNING, "This function is not supported in this build"); + php_error_docref(NULL, E_WARNING, "This function is not supported in this build"); RETURN_FALSE; #endif } @@ -316,7 +316,7 @@ PHP_FUNCTION(apache_note) int note_name_len, note_val_len; char *old_val; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¬e_name, ¬e_name_len, ¬e_val, ¬e_val_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", ¬e_name, ¬e_name_len, ¬e_val, ¬e_val_len) == FAILURE) { return; } @@ -350,29 +350,29 @@ PHP_FUNCTION(virtual) int filename_len; request_rec *rr = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) { return; } if (!(rr = sub_req_lookup_uri (filename, ((request_rec *) SG(server_context))))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", filename); + php_error_docref(NULL, E_WARNING, "Unable to include '%s' - URI lookup failed", filename); if (rr) destroy_sub_req (rr); RETURN_FALSE; } if (rr->status != 200) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", filename); + php_error_docref(NULL, E_WARNING, "Unable to include '%s' - error finding URI", filename); if (rr) destroy_sub_req (rr); RETURN_FALSE; } - php_output_end_all(TSRMLS_C); - php_header(TSRMLS_C); + php_output_end_all(); + php_header(); if (run_sub_req(rr)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - request execution failed", filename); + php_error_docref(NULL, E_WARNING, "Unable to include '%s' - request execution failed", filename); if (rr) destroy_sub_req (rr); RETURN_FALSE; @@ -440,7 +440,7 @@ PHP_FUNCTION(apache_setenv) char *var = NULL, *val = NULL; request_rec *r = (request_rec *) SG(server_context); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", &var, &var_len, &val, &val_len, &top) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|b", &var, &var_len, &val, &val_len, &top) == FAILURE) { return; } @@ -462,12 +462,12 @@ PHP_FUNCTION(apache_lookup_uri) int filename_len; request_rec *rr=NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename, &filename_len) == FAILURE) { return; } if (!(rr = sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "URI lookup failed '%s'", filename); + php_error_docref(NULL, E_WARNING, "URI lookup failed '%s'", filename); RETURN_FALSE; } @@ -540,12 +540,12 @@ PHP_FUNCTION(apache_exec_uri) int filename_len; request_rec *rr=NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &filename, &filename_len) == FAILURE) { return; } if(!(rr = ap_sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "URI lookup failed", filename); + php_error_docref(NULL, E_WARNING, "URI lookup failed", filename); RETURN_FALSE; } -- cgit v1.2.1