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 --- Zend/zend_ini_scanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zend/zend_ini_scanner.c') diff --git a/Zend/zend_ini_scanner.c b/Zend/zend_ini_scanner.c index 2abf1140fc..7b2a0e25ff 100644 --- a/Zend/zend_ini_scanner.c +++ b/Zend/zend_ini_scanner.c @@ -103,7 +103,7 @@ /* Globals Macros */ #define SCNG INI_SCNG #ifdef ZTS -ZEND_API ts_rsrc_id ini_scanner_globals_id; +TSRMG_D(zend_ini_scanner_globals, ini_scanner_globals_id); #else ZEND_API zend_ini_scanner_globals ini_scanner_globals; #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. --- Zend/zend_ini_scanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zend/zend_ini_scanner.c') diff --git a/Zend/zend_ini_scanner.c b/Zend/zend_ini_scanner.c index 7b2a0e25ff..2abf1140fc 100644 --- a/Zend/zend_ini_scanner.c +++ b/Zend/zend_ini_scanner.c @@ -103,7 +103,7 @@ /* Globals Macros */ #define SCNG INI_SCNG #ifdef ZTS -TSRMG_D(zend_ini_scanner_globals, ini_scanner_globals_id); +ZEND_API ts_rsrc_id ini_scanner_globals_id; #else ZEND_API zend_ini_scanner_globals ini_scanner_globals; #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 --- Zend/zend_ini_scanner.c | 66 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'Zend/zend_ini_scanner.c') diff --git a/Zend/zend_ini_scanner.c b/Zend/zend_ini_scanner.c index 61e7575dad..770e719c91 100644 --- a/Zend/zend_ini_scanner.c +++ b/Zend/zend_ini_scanner.c @@ -189,7 +189,7 @@ static void zend_ini_copy_typed_value(zval *retval, const int type, const char * } } -static void _yy_push_state(int new_state TSRMLS_DC) +static void _yy_push_state(int new_state) { zend_stack_push(&SCNG(state_stack), (void *) &YYGETCONDITION()); YYSETCONDITION(new_state); @@ -197,14 +197,14 @@ static void _yy_push_state(int new_state TSRMLS_DC) #define yy_push_state(state_and_tsrm) _yy_push_state(yyc##state_and_tsrm) -static void yy_pop_state(TSRMLS_D) +static void yy_pop_state(void) { int *stack_state = zend_stack_top(&SCNG(state_stack)); YYSETCONDITION(*stack_state); zend_stack_del_top(&SCNG(state_stack)); } -static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC) +static void yy_scan_buffer(char *str, unsigned int len) { YYCURSOR = (YYCTYPE*)str; SCNG(yy_start) = YYCURSOR; @@ -215,7 +215,7 @@ static void yy_scan_buffer(char *str, unsigned int len TSRMLS_DC) /* {{{ init_ini_scanner() */ -static int init_ini_scanner(int scanner_mode, zend_file_handle *fh TSRMLS_DC) +static int init_ini_scanner(int scanner_mode, zend_file_handle *fh) { /* Sanity check */ if (scanner_mode != ZEND_INI_SCANNER_NORMAL && scanner_mode != ZEND_INI_SCANNER_RAW && scanner_mode != ZEND_INI_SCANNER_TYPED) { @@ -242,7 +242,7 @@ static int init_ini_scanner(int scanner_mode, zend_file_handle *fh TSRMLS_DC) /* {{{ shutdown_ini_scanner() */ -void shutdown_ini_scanner(TSRMLS_D) +void shutdown_ini_scanner(void) { zend_stack_destroy(&SCNG(state_stack)); if (ini_filename) { @@ -253,7 +253,7 @@ void shutdown_ini_scanner(TSRMLS_D) /* {{{ zend_ini_scanner_get_lineno() */ -int zend_ini_scanner_get_lineno(TSRMLS_D) +int zend_ini_scanner_get_lineno(void) { return SCNG(lineno); } @@ -261,7 +261,7 @@ int zend_ini_scanner_get_lineno(TSRMLS_D) /* {{{ zend_ini_scanner_get_filename() */ -char *zend_ini_scanner_get_filename(TSRMLS_D) +char *zend_ini_scanner_get_filename(void) { return ini_filename ? ini_filename : "Unknown"; } @@ -269,21 +269,21 @@ char *zend_ini_scanner_get_filename(TSRMLS_D) /* {{{ zend_ini_open_file_for_scanning() */ -int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRMLS_DC) +int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode) { char *buf; size_t size; - if (zend_stream_fixup(fh, &buf, &size TSRMLS_CC) == FAILURE) { + if (zend_stream_fixup(fh, &buf, &size) == FAILURE) { return FAILURE; } - if (init_ini_scanner(scanner_mode, fh TSRMLS_CC) == FAILURE) { - zend_file_handle_dtor(fh TSRMLS_CC); + if (init_ini_scanner(scanner_mode, fh) == FAILURE) { + zend_file_handle_dtor(fh); return FAILURE; } - yy_scan_buffer(buf, (unsigned int)size TSRMLS_CC); + yy_scan_buffer(buf, (unsigned int)size); return SUCCESS; } @@ -291,15 +291,15 @@ int zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode TSRML /* {{{ zend_ini_prepare_string_for_scanning() */ -int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC) +int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode) { int len = (int)strlen(str); - if (init_ini_scanner(scanner_mode, NULL TSRMLS_CC) == FAILURE) { + if (init_ini_scanner(scanner_mode, NULL) == FAILURE) { return FAILURE; } - yy_scan_buffer(str, len TSRMLS_CC); + yy_scan_buffer(str, len); return SUCCESS; } @@ -307,7 +307,7 @@ int zend_ini_prepare_string_for_scanning(char *str, int scanner_mode TSRMLS_DC) /* {{{ zend_ini_escape_string() */ -static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_type TSRMLS_DC) +static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_type) { register char *s, *t; char *end; @@ -354,7 +354,7 @@ static void zend_ini_escape_string(zval *lval, char *str, int len, char quote_ty } /* }}} */ -int ini_lex(zval *ini_lval TSRMLS_DC) +int ini_lex(zval *ini_lval) { restart: SCNG(yy_text) = YYCURSOR; @@ -614,9 +614,9 @@ yy17: #line 487 "Zend/zend_ini_scanner.l" { /* Start option value */ if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) { - yy_push_state(ST_RAW TSRMLS_CC); + yy_push_state(ST_RAW); } else { - yy_push_state(ST_VALUE TSRMLS_CC); + yy_push_state(ST_VALUE); } return '='; } @@ -680,9 +680,9 @@ yy23: { /* Section start */ /* Enter section data lookup state */ if (SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW) { - yy_push_state(ST_SECTION_RAW TSRMLS_CC); + yy_push_state(ST_SECTION_RAW); } else { - yy_push_state(ST_SECTION_VALUE TSRMLS_CC); + yy_push_state(ST_SECTION_VALUE); } return TC_SECTION; } @@ -725,7 +725,7 @@ yy28: EAT_TRAILING_WHITESPACE_EX('['); /* Enter offset lookup state */ - yy_push_state(ST_OFFSET TSRMLS_CC); + yy_push_state(ST_OFFSET); RETURN_TOKEN(TC_OFFSET, yytext, yyleng); } @@ -1114,7 +1114,7 @@ yy70: yyleng = YYCURSOR - SCNG(yy_text); #line 639 "Zend/zend_ini_scanner.l" { /* #Comment */ - zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on line %d", zend_ini_scanner_get_filename(TSRMLS_C), SCNG(lineno)); + zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on line %d", zend_ini_scanner_get_filename(), SCNG(lineno)); BEGIN(INITIAL); SCNG(lineno)++; return END_OF_LINE; @@ -1292,7 +1292,7 @@ yy81: yyleng = YYCURSOR - SCNG(yy_text); - zend_ini_escape_string(ini_lval, yytext, yyleng, '"' TSRMLS_CC); + zend_ini_escape_string(ini_lval, yytext, yyleng, '"'); return TC_QUOTED_STRING; } #line 1299 "Zend/zend_ini_scanner.c" @@ -1306,7 +1306,7 @@ yy83: yyleng = YYCURSOR - SCNG(yy_text); #line 578 "Zend/zend_ini_scanner.l" { /* Double quoted '"' string ends */ - yy_pop_state(TSRMLS_C); + yy_pop_state(); return '"'; } #line 1313 "Zend/zend_ini_scanner.c" @@ -1320,7 +1320,7 @@ yy84: yyleng = YYCURSOR - SCNG(yy_text); #line 445 "Zend/zend_ini_scanner.l" { /* Variable start */ - yy_push_state(ST_VARNAME TSRMLS_CC); + yy_push_state(ST_VARNAME); return TC_DOLLAR_CURLY; } #line 1327 "Zend/zend_ini_scanner.c" @@ -1457,7 +1457,7 @@ yy97: yyleng = YYCURSOR - SCNG(yy_text); #line 573 "Zend/zend_ini_scanner.l" { /* Double quoted '"' string start */ - yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC); + yy_push_state(ST_DOUBLE_QUOTES); return '"'; } #line 1464 "Zend/zend_ini_scanner.c" @@ -1879,7 +1879,7 @@ yy134: yyleng = YYCURSOR - SCNG(yy_text); #line 445 "Zend/zend_ini_scanner.l" { /* Variable start */ - yy_push_state(ST_VARNAME TSRMLS_CC); + yy_push_state(ST_VARNAME); return TC_DOLLAR_CURLY; } #line 1886 "Zend/zend_ini_scanner.c" @@ -2382,7 +2382,7 @@ yy183: yyleng = YYCURSOR - SCNG(yy_text); #line 573 "Zend/zend_ini_scanner.l" { /* Double quoted '"' string start */ - yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC); + yy_push_state(ST_DOUBLE_QUOTES); return '"'; } #line 2389 "Zend/zend_ini_scanner.c" @@ -2829,7 +2829,7 @@ yy224: yyleng = YYCURSOR - SCNG(yy_text); #line 445 "Zend/zend_ini_scanner.l" { /* Variable start */ - yy_push_state(ST_VARNAME TSRMLS_CC); + yy_push_state(ST_VARNAME); return TC_DOLLAR_CURLY; } #line 2836 "Zend/zend_ini_scanner.c" @@ -3084,7 +3084,7 @@ yy243: yyleng = YYCURSOR - SCNG(yy_text); #line 573 "Zend/zend_ini_scanner.l" { /* Double quoted '"' string start */ - yy_push_state(ST_DOUBLE_QUOTES TSRMLS_CC); + yy_push_state(ST_DOUBLE_QUOTES); return '"'; } #line 3091 "Zend/zend_ini_scanner.c" @@ -4641,7 +4641,7 @@ yy309: yyleng = YYCURSOR - SCNG(yy_text); #line 445 "Zend/zend_ini_scanner.l" { /* Variable start */ - yy_push_state(ST_VARNAME TSRMLS_CC); + yy_push_state(ST_VARNAME); return TC_DOLLAR_CURLY; } #line 4648 "Zend/zend_ini_scanner.c" @@ -4803,7 +4803,7 @@ yy324: yyleng = YYCURSOR - SCNG(yy_text); #line 460 "Zend/zend_ini_scanner.l" { /* Variable end */ - yy_pop_state(TSRMLS_C); + yy_pop_state(); return '}'; } #line 4810 "Zend/zend_ini_scanner.c" -- cgit v1.2.1