diff options
160 files changed, 468 insertions, 208 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index efdea5c880..67b7ff6002 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -22,6 +22,10 @@ typedef struct _tsrm_tls_entry tsrm_tls_entry; +#if defined(TSRM_WIN32) +/* TSRMLS_CACHE_DEFINE; is already done in Zend, this is being always compiled statically. */ +#endif + struct _tsrm_tls_entry { void **storage; int count; @@ -282,7 +286,7 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_ tsrm_tls_set(*thread_resources_ptr); if (tsrm_new_thread_begin_handler) { - tsrm_new_thread_begin_handler(thread_id, &((*thread_resources_ptr)->storage)); + tsrm_new_thread_begin_handler(thread_id); } for (i=0; i<id_count; i++) { if (resource_types_table[i].done) { @@ -297,7 +301,7 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_ } if (tsrm_new_thread_end_handler) { - tsrm_new_thread_end_handler(thread_id, &((*thread_resources_ptr)->storage)); + tsrm_new_thread_end_handler(thread_id); } tsrm_mutex_unlock(tsmm_mutex); @@ -791,4 +795,9 @@ void tsrm_error_set(int level, char *debug_filename) #endif } +TSRM_API inline void *tsrm_get_ls_cache(void) +{ + return tsrm_tls_get(); +} + #endif /* ZTS */ diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index b232429d4d..83999c3521 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -129,8 +129,8 @@ TSRM_API void ts_free_id(ts_rsrc_id id); #define TSRM_ERROR_LEVEL_CORE 2 #define TSRM_ERROR_LEVEL_INFO 3 -typedef void (*tsrm_thread_begin_func_t)(THREAD_T thread_id, void ***tsrm_ls); -typedef void (*tsrm_thread_end_func_t)(THREAD_T thread_id, void ***tsrm_ls); +typedef void (*tsrm_thread_begin_func_t)(THREAD_T thread_id); +typedef void (*tsrm_thread_end_func_t)(THREAD_T thread_id); TSRM_API int tsrm_error(int level, const char *format, ...); @@ -155,17 +155,33 @@ TSRM_API void *tsrm_new_interpreter_context(void); TSRM_API void *tsrm_set_interpreter_context(void *new_ctx); TSRM_API void tsrm_free_interpreter_context(void *context); +TSRM_API inline void *tsrm_get_ls_cache(void); + +#ifdef TSRM_WIN32 +# define TSRM_TLS __declspec(thread) +#else +# define TSRM_TLS __thread +#endif + #define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1) #define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1) -#define TSRMLS_FETCH() void ***tsrm_ls = (void ***) ts_resource_ex(0, NULL) #define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = (void ***) ctx -#define TSRMLS_SET_CTX(ctx) ctx = (void ***) tsrm_ls -#define TSRMG(id, type, element) (((type) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(id)])->element) -#define TSRMLS_D void ***tsrm_ls -#define TSRMLS_DC , TSRMLS_D -#define TSRMLS_C tsrm_ls -#define TSRMLS_CC , TSRMLS_C +#define TSRMLS_SET_CTX(ctx) ctx = (void ***) tsrm_get_ls_cache() +#define TSRMG(id, type, element) (((type) (*((void ***) tsrm_get_ls_cache()))[TSRM_UNSHUFFLE_RSRC_ID(id)])->element) + +#define TSRMG_STATIC(id, type, element) (((type) (*((void ***) _tsrm_ls_cache))[TSRM_UNSHUFFLE_RSRC_ID(id)])->element) +#define TSRMLS_CACHE_EXTERN extern TSRM_TLS void *_tsrm_ls_cache +#define TSRMLS_CACHE_DEFINE TSRM_TLS void *_tsrm_ls_cache = NULL +#define TSRMLS_CACHE_UPDATE if (!TSRMLS_CACHE) _tsrm_ls_cache = tsrm_get_ls_cache() +#define TSRMLS_CACHE _tsrm_ls_cache + +/* BC only */ +#define TSRMLS_D void +#define TSRMLS_DC +#define TSRMLS_C +#define TSRMLS_CC +#define TSRMLS_FETCH() #ifdef __cplusplus } @@ -176,6 +192,14 @@ TSRM_API void tsrm_free_interpreter_context(void *context); #define TSRMLS_FETCH() #define TSRMLS_FETCH_FROM_CTX(ctx) #define TSRMLS_SET_CTX(ctx) + +#define TSRMG_STATIC(id, type, element) +#define TSRMLS_CACHE_EXTERN +#define TSRMLS_CACHE_DEFINE +#define TSRMLS_CACHE_UPDATE +#define TSRMLS_CACHE + +/* BC only */ #define TSRMLS_D void #define TSRMLS_DC #define TSRMLS_C diff --git a/TSRM/config.w32 b/TSRM/config.w32 index 91b4eead2a..e7d3f3b976 100644 --- a/TSRM/config.w32 +++ b/TSRM/config.w32 @@ -2,4 +2,5 @@ // $Id$ ADD_SOURCES("TSRM", "TSRM.c tsrm_strtok_r.c tsrm_win32.c"); +ADD_FLAG("CFLAGS_BD_TSRM", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 9765874448..b5bd930fd0 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -42,6 +42,9 @@ static tsrm_win32_globals win32_globals; static void tsrm_win32_ctor(tsrm_win32_globals *globals TSRMLS_DC) { +#ifdef ZTS +TSRMLS_CACHE_UPDATE; +#endif globals->process = NULL; globals->shm = NULL; globals->process_size = 0; diff --git a/TSRM/tsrm_win32.h b/TSRM/tsrm_win32.h index beff1e88cf..cb636a6851 100644 --- a/TSRM/tsrm_win32.h +++ b/TSRM/tsrm_win32.h @@ -71,7 +71,8 @@ typedef struct { } tsrm_win32_globals; #ifdef ZTS -# define TWG(v) TSRMG(win32_globals_id, tsrm_win32_globals *, v) +# define TWG(v) TSRMG_STATIC(win32_globals_id, tsrm_win32_globals *, v) +TSRMLS_CACHE_EXTERN; #else # define TWG(v) (win32_globals.v) #endif diff --git a/Zend/Makefile.am b/Zend/Makefile.am index 2a76db36b1..09018a0d3d 100644 --- a/Zend/Makefile.am +++ b/Zend/Makefile.am @@ -20,6 +20,7 @@ libZend_la_SOURCES=\ zend_strtod.c zend_closures.c zend_float.c zend_string.c zend_signal.c \ zend_generators.c zend_virtual_cwd.c zend_ast.c +libZend_la_CFLAGS = -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 libZend_la_LDFLAGS = libZend_la_LIBADD = @ZEND_EXTRA_LIBS@ diff --git a/Zend/zend.c b/Zend/zend.c index 89977e7734..2bb90da5f2 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -120,6 +120,7 @@ static HashTable *global_class_table = NULL; static HashTable *global_constants_table = NULL; static HashTable *global_auto_globals_table = NULL; static HashTable *global_persistent_list = NULL; +ZEND_TSRMLS_CACHE_DEFINE; #endif ZEND_API zend_utility_values zend_uv; @@ -464,6 +465,7 @@ static void compiler_globals_dtor(zend_compiler_globals *compiler_globals TSRMLS static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS_DC) /* {{{ */ { + ZEND_TSRMLS_CACHE_UPDATE; zend_startup_constants(TSRMLS_C); zend_copy_constants(EG(zend_constants), GLOBAL_CONSTANTS_TABLE); zend_init_rsrc_plist(TSRMLS_C); @@ -557,9 +559,11 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions TS zend_executor_globals *executor_globals; extern ZEND_API ts_rsrc_id ini_scanner_globals_id; extern ZEND_API ts_rsrc_id language_scanner_globals_id; + ZEND_TSRMLS_CACHE_UPDATE; #else extern zend_ini_scanner_globals ini_scanner_globals; extern zend_php_scanner_globals language_scanner_globals; + ZEND_TSRMLS_CACHE_UPDATE; #endif start_memory_manager(TSRMLS_C); @@ -705,16 +709,16 @@ void zend_post_startup(TSRMLS_D) /* {{{ */ free(compiler_globals->function_table); free(compiler_globals->class_table); if ((script_encoding_list = (zend_encoding **)compiler_globals->script_encoding_list)) { - compiler_globals_ctor(compiler_globals, tsrm_ls); + compiler_globals_ctor(compiler_globals TSRMLS_CC); compiler_globals->script_encoding_list = (const zend_encoding **)script_encoding_list; } else { - compiler_globals_ctor(compiler_globals, tsrm_ls); + compiler_globals_ctor(compiler_globals TSRMLS_CC); } free(EG(zend_constants)); virtual_cwd_deactivate(TSRMLS_C); - executor_globals_ctor(executor_globals, tsrm_ls); + executor_globals_ctor(executor_globals TSRMLS_CC); global_persistent_list = &EG(persistent_list); zend_copy_ini_directives(TSRMLS_C); #else diff --git a/Zend/zend.h b/Zend/zend.h index b254b2974b..1d4f14b380 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -60,6 +60,22 @@ !ZEND_USER_CODE(EX(prev_execute_data)->func->common.type) || \ !(EX(prev_execute_data)->opline->result_type & EXT_TYPE_UNUSED)) +#ifdef ZEND_ENABLE_STATIC_TSRMLS_CACHE +#define ZEND_TSRMG TSRMG_STATIC +#define ZEND_TSRMLS_CACHE_EXTERN TSRMLS_CACHE_EXTERN +#define ZEND_TSRMLS_CACHE_DEFINE TSRMLS_CACHE_DEFINE +#define ZEND_TSRMLS_CACHE_UPDATE TSRMLS_CACHE_UPDATE +#define ZEND_TSRMLS_CACHE TSRMLS_CACHE +#else +#define ZEND_TSRMG TSRMG +#define ZEND_TSRMLS_CACHE_EXTERN +#define ZEND_TSRMLS_CACHE_DEFINE +#define ZEND_TSRMLS_CACHE_UPDATE +#define ZEND_TSRMLS_CACHE +#endif + +ZEND_TSRMLS_CACHE_EXTERN; + #ifdef HAVE_NORETURN # if defined(ZEND_WIN32) ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...); diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index a1af2fcc7f..66141339e0 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -2080,7 +2080,7 @@ typedef struct _zend_alloc_globals { #ifdef ZTS static int alloc_globals_id; -# define AG(v) TSRMG(alloc_globals_id, zend_alloc_globals *, v) +# define AG(v) ZEND_TSRMG(alloc_globals_id, zend_alloc_globals *, v) #else # define AG(v) (alloc_globals.v) static zend_alloc_globals alloc_globals; @@ -2411,6 +2411,7 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals TSRMLS_DC) return; } #endif + ZEND_TSRMLS_CACHE_UPDATE; alloc_globals->mm_heap = zend_mm_init(); } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index dae6c22026..9c5ca95b8d 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3093,7 +3093,7 @@ static void zend_free_foreach_and_switch_variables(TSRMLS_D) /* {{{ */ opnum_start = get_next_op_number(CG(active_op_array)); #ifdef ZTS - zend_stack_apply_with_argument(&CG(loop_var_stack), ZEND_STACK_APPLY_TOPDOWN, (int (*)(void *element, void *)) generate_free_loop_var TSRMLS_CC); + zend_stack_apply_with_argument(&CG(loop_var_stack), ZEND_STACK_APPLY_TOPDOWN, (int (*)(void *element, void *)) generate_free_loop_var, NULL); #else zend_stack_apply(&CG(loop_var_stack), ZEND_STACK_APPLY_TOPDOWN, (int (*)(void *element)) generate_free_loop_var); #endif diff --git a/Zend/zend_gc.h b/Zend/zend_gc.h index 2eb8ea6ea3..d502f099aa 100644 --- a/Zend/zend_gc.h +++ b/Zend/zend_gc.h @@ -112,7 +112,7 @@ typedef struct _zend_gc_globals { BEGIN_EXTERN_C() ZEND_API extern int gc_globals_id; END_EXTERN_C() -#define GC_G(v) TSRMG(gc_globals_id, zend_gc_globals *, v) +#define GC_G(v) ZEND_TSRMG(gc_globals_id, zend_gc_globals *, v) #else #define GC_G(v) (gc_globals.v) extern ZEND_API zend_gc_globals gc_globals; diff --git a/Zend/zend_globals_macros.h b/Zend/zend_globals_macros.h index ac9b793775..7678b2b01d 100644 --- a/Zend/zend_globals_macros.h +++ b/Zend/zend_globals_macros.h @@ -31,18 +31,17 @@ BEGIN_EXTERN_C() /* Compiler */ #ifdef ZTS -# define CG(v) TSRMG(compiler_globals_id, zend_compiler_globals *, v) -int zendparse(void *compiler_globals); +# define CG(v) ZEND_TSRMG(compiler_globals_id, zend_compiler_globals *, v) #else # define CG(v) (compiler_globals.v) extern ZEND_API struct _zend_compiler_globals compiler_globals; -int zendparse(void); #endif +int zendparse(void); /* Executor */ #ifdef ZTS -# define EG(v) TSRMG(executor_globals_id, zend_executor_globals *, v) +# define EG(v) ZEND_TSRMG(executor_globals_id, zend_executor_globals *, v) #else # define EG(v) (executor_globals.v) extern ZEND_API zend_executor_globals executor_globals; @@ -50,7 +49,7 @@ extern ZEND_API zend_executor_globals executor_globals; /* Language Scanner */ #ifdef ZTS -# define LANG_SCNG(v) TSRMG(language_scanner_globals_id, zend_php_scanner_globals *, v) +# define LANG_SCNG(v) ZEND_TSRMG(language_scanner_globals_id, zend_php_scanner_globals *, v) extern ZEND_API ts_rsrc_id language_scanner_globals_id; #else # define LANG_SCNG(v) (language_scanner_globals.v) @@ -60,7 +59,7 @@ extern ZEND_API zend_php_scanner_globals language_scanner_globals; /* INI Scanner */ #ifdef ZTS -# define INI_SCNG(v) TSRMG(ini_scanner_globals_id, zend_ini_scanner_globals *, v) +# define INI_SCNG(v) ZEND_TSRMG(ini_scanner_globals_id, zend_ini_scanner_globals *, v) extern ZEND_API ts_rsrc_id ini_scanner_globals_id; #else # define INI_SCNG(v) (ini_scanner_globals.v) diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index 20991bf3f9..226fe68a2f 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -36,13 +36,7 @@ #define YYERROR_VERBOSE #define YYSTYPE zval -#ifdef ZTS -#define YYPARSE_PARAM tsrm_ls -#define YYLEX_PARAM tsrm_ls -int ini_parse(void *arg); -#else int ini_parse(void); -#endif #define ZEND_INI_PARSER_CB (CG(ini_parser_param))->ini_parser_cb #define ZEND_INI_PARSER_ARG (CG(ini_parser_param))->arg diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 4d66648055..caa611460d 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -54,10 +54,6 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %expect 2 %code requires { -#ifdef ZTS -# define YYPARSE_PARAM tsrm_ls -# define YYLEX_PARAM tsrm_ls -#endif } %destructor { zend_ast_destroy($$); } <ast> diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h index 0cd9ca4d16..9b1717d5df 100644 --- a/Zend/zend_modules.h +++ b/Zend/zend_modules.h @@ -33,7 +33,7 @@ #define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *zend_module TSRMLS_DC #define ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU zend_module TSRMLS_CC -#define ZEND_MODULE_API_NO 20140815 +#define ZEND_MODULE_API_NO 20141001 #ifdef ZTS #define USING_ZTS 1 #else diff --git a/Zend/zend_signal.h b/Zend/zend_signal.h index 02d6495437..8e99a50bbb 100644 --- a/Zend/zend_signal.h +++ b/Zend/zend_signal.h @@ -65,7 +65,7 @@ typedef struct _zend_signal_globals_t { } zend_signal_globals_t; #ifdef ZTS -# define SIGG(v) TSRMG(zend_signal_globals_id, zend_signal_globals_t *, v) +# define SIGG(v) ZEND_TSRMG(zend_signal_globals_id, zend_signal_globals_t *, v) BEGIN_EXTERN_C() ZEND_API extern int zend_signal_globals_id; END_EXTERN_C() diff --git a/Zend/zend_virtual_cwd.h b/Zend/zend_virtual_cwd.h index 96ac6faa30..ec2875f068 100644 --- a/Zend/zend_virtual_cwd.h +++ b/Zend/zend_virtual_cwd.h @@ -237,7 +237,7 @@ typedef struct _virtual_cwd_globals { #ifdef ZTS extern ts_rsrc_id cwd_globals_id; -# define CWDG(v) TSRMG(cwd_globals_id, virtual_cwd_globals *, v) +# define CWDG(v) ZEND_TSRMG(cwd_globals_id, virtual_cwd_globals *, v) #else extern virtual_cwd_globals cwd_globals; # define CWDG(v) (cwd_globals.v) diff --git a/acinclude.m4 b/acinclude.m4 index 678296aac7..a4d4d509e0 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -2736,7 +2736,7 @@ AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[ enable-libtool-lock | with-pic | with-tags | enable-shared | enable-static | enable-fast-install | with-gnu-ld[)];; # Allow certain TSRM options - with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads[)];; + with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads [)];; # Allow certain Zend options with-zend-vm | enable-maintainer-zts | enable-inline-optimization[)];; diff --git a/configure.in b/configure.in index f947d2f9de..bf770dddc7 100644 --- a/configure.in +++ b/configure.in @@ -333,8 +333,8 @@ case $host_alias in ;; *netware*) PHP_BUILD_PROGRAM - PHP_ADD_SOURCES(/main, internal_functions.c,,PHP_GLOBAL_OBJS) - PHP_ADD_SOURCES(win32, sendmail.c, -I$CFLAGS, PHP_GLOBAL_OBJS) + PHP_ADD_SOURCES(/main, internal_functions.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, PHP_GLOBAL_OBJS) + PHP_ADD_SOURCES(win32, sendmail.c, -I$CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, PHP_GLOBAL_OBJS) PHP7LIB_SHARED_LIBADD=\$\(EXTRA_LIBS\) EXTENSION_DIR=sys:/php$PHP_MAJOR_VERSION/ext PHP_SUBST(PHP7LIB_SHARED_LIBADD) @@ -1454,20 +1454,20 @@ PHP_SUBST(install_binary_targets) PHP_INSTALL_HEADERS([Zend/ TSRM/ include/ main/ main/streams/]) -PHP_ADD_SOURCES(TSRM, TSRM.c tsrm_strtok_r.c) +PHP_ADD_SOURCES(TSRM, TSRM.c tsrm_strtok_r.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c php_sprintf.c \ fopen_wrappers.c alloca.c php_scandir.c \ php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \ strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c \ network.c php_open_temporary_file.c \ - output.c getopt.c) + output.c getopt.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_ADD_SOURCES(main/streams, streams.c cast.c memory.c filter.c \ plain_wrapper.c userspace.c transports.c xp_socket.c mmap.c \ - glob_wrapper.c) + glob_wrapper.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) -PHP_ADD_SOURCES(/main, internal_functions.c,, sapi) +PHP_ADD_SOURCES(/main, internal_functions.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, sapi) case $host_alias in *netware*) @@ -1475,7 +1475,7 @@ case $host_alias in PHP_ADD_BUILD_DIR(netware) ;; *) - PHP_ADD_SOURCES_X(/main, internal_functions_cli.c,, PHP_BINARY_OBJS) + PHP_ADD_SOURCES_X(/main, internal_functions_cli.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, PHP_BINARY_OBJS) ;; esac @@ -1491,7 +1491,8 @@ PHP_ADD_SOURCES(Zend, \ zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c zend_gc.c \ zend_closures.c zend_float.c zend_string.c zend_signal.c zend_generators.c \ zend_virtual_cwd.c zend_ast.c zend_objects.c zend_object_handlers.c zend_objects_API.c \ - zend_default_classes.c zend_inheritance.c) + zend_default_classes.c zend_inheritance.c, \ + -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) dnl Selectively disable optimization due to high RAM usage during dnl compiling the executor. @@ -1501,7 +1502,7 @@ else flag= fi -PHP_ADD_SOURCES_X(Zend, zend_execute.c,,PHP_GLOBAL_OBJS,,$flag) +PHP_ADD_SOURCES_X(Zend, zend_execute.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1,PHP_GLOBAL_OBJS,,$flag) PHP_ADD_BUILD_DIR(main main/streams) PHP_ADD_BUILD_DIR(TSRM) diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index 5c4e8740e4..11f30e47c3 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -127,6 +127,9 @@ zend_module_entry bcmath_module_entry = { }; #ifdef COMPILE_DL_BCMATH +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(bcmath) #endif @@ -140,6 +143,9 @@ PHP_INI_END() */ static PHP_GINIT_FUNCTION(bcmath) { +#if defined(COMPILE_DL_BCMATH) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif bcmath_globals->bc_precision = 0; bc_init_numbers(TSRMLS_C); } diff --git a/ext/bcmath/config.m4 b/ext/bcmath/config.m4 index 3a4ad8c3b3..bc126454b4 100644 --- a/ext/bcmath/config.m4 +++ b/ext/bcmath/config.m4 @@ -11,7 +11,7 @@ libbcmath/src/add.c libbcmath/src/div.c libbcmath/src/init.c libbcmath/src/neg.c libbcmath/src/compare.c libbcmath/src/divmod.c libbcmath/src/int2num.c libbcmath/src/num2long.c libbcmath/src/output.c libbcmath/src/recmul.c \ libbcmath/src/sqrt.c libbcmath/src/zero.c libbcmath/src/debug.c libbcmath/src/doaddsub.c libbcmath/src/nearzero.c libbcmath/src/num2str.c libbcmath/src/raise.c \ libbcmath/src/rmzero.c libbcmath/src/str2num.c, - $ext_shared,,-I@ext_srcdir@/libbcmath/src) + $ext_shared,,-I@ext_srcdir@/libbcmath/src -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_ADD_BUILD_DIR($ext_builddir/libbcmath/src) AC_DEFINE(HAVE_BCMATH, 1, [Whether you have bcmath]) fi diff --git a/ext/bcmath/config.w32 b/ext/bcmath/config.w32 index 3579eadfae..3973c10cbf 100644 --- a/ext/bcmath/config.w32 +++ b/ext/bcmath/config.w32 @@ -4,7 +4,7 @@ ARG_ENABLE("bcmath", "bc style precision math functions", "yes"); if (PHP_BCMATH == "yes") { - EXTENSION("bcmath", "bcmath.c", null, "-Iext/bcmath/libbcmath/src"); + EXTENSION("bcmath", "bcmath.c", null, "-Iext/bcmath/libbcmath/src /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_SOURCES("ext/bcmath/libbcmath/src", "add.c div.c init.c neg.c \ outofmem.c raisemod.c rt.c sub.c compare.c divmod.c int2num.c \ num2long.c output.c recmul.c sqrt.c zero.c debug.c doaddsub.c \ diff --git a/ext/bcmath/php_bcmath.h b/ext/bcmath/php_bcmath.h index 12098cff89..6647894bf0 100644 --- a/ext/bcmath/php_bcmath.h +++ b/ext/bcmath/php_bcmath.h @@ -49,7 +49,10 @@ ZEND_BEGIN_MODULE_GLOBALS(bcmath) ZEND_END_MODULE_GLOBALS(bcmath) #ifdef ZTS -# define BCG(v) TSRMG(bcmath_globals_id, zend_bcmath_globals *, v) +# define BCG(v) ZEND_TSRMG(bcmath_globals_id, zend_bcmath_globals *, v) +# ifdef COMPILE_DL_BCMATH +ZEND_TSRMLS_CACHE_EXTERN; +# endif #else # define BCG(v) (bcmath_globals.v) #endif diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c index e4ed4916af..35fda89963 100644 --- a/ext/com_dotnet/com_extension.c +++ b/ext/com_dotnet/com_extension.c @@ -254,6 +254,9 @@ zend_module_entry com_dotnet_module_entry = { /* }}} */ #ifdef COMPILE_DL_COM_DOTNET +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(com_dotnet) #endif @@ -337,6 +340,9 @@ PHP_INI_END() */ static PHP_GINIT_FUNCTION(com_dotnet) { +#if defined(COMPILE_DL_COM_DOTNET) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif memset(com_dotnet_globals, 0, sizeof(*com_dotnet_globals)); com_dotnet_globals->code_page = CP_ACP; } diff --git a/ext/com_dotnet/config.w32 b/ext/com_dotnet/config.w32 index 1526392c24..3ae2328427 100644 --- a/ext/com_dotnet/config.w32 +++ b/ext/com_dotnet/config.w32 @@ -7,7 +7,8 @@ if (PHP_COM_DOTNET == "yes") { CHECK_LIB('oleaut32.lib', 'com_dotnet'); EXTENSION("com_dotnet", "com_com.c com_dotnet.c com_extension.c \ com_handlers.c com_iterator.c com_misc.c com_olechar.c \ - com_typeinfo.c com_variant.c com_wrapper.c com_saproxy.c com_persist.c"); + com_typeinfo.c com_variant.c com_wrapper.c com_saproxy.c com_persist.c", + null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('HAVE_COM_DOTNET', 1, 'Have COM_DOTNET support'); CHECK_HEADER_ADD_INCLUDE('mscoree.h', 'CFLAGS_COM_DOTNET'); } diff --git a/ext/com_dotnet/php_com_dotnet.h b/ext/com_dotnet/php_com_dotnet.h index cb60083289..5066a044ff 100644 --- a/ext/com_dotnet/php_com_dotnet.h +++ b/ext/com_dotnet/php_com_dotnet.h @@ -53,7 +53,10 @@ ZEND_BEGIN_MODULE_GLOBALS(com_dotnet) ZEND_END_MODULE_GLOBALS(com_dotnet) #ifdef ZTS -# define COMG(v) TSRMG(com_dotnet_globals_id, zend_com_dotnet_globals *, v) +# define COMG(v) ZEND_TSRMG(com_dotnet_globals_id, zend_com_dotnet_globals *, v) +# ifdef COMPILE_DL_COM_DOTNET +ZEND_TSRMLS_CACHE_EXTERN; +# endif #else # define COMG(v) (com_dotnet_globals.v) #endif diff --git a/ext/date/config.w32 b/ext/date/config.w32 index c97df7246c..64a4ae92a1 100755 --- a/ext/date/config.w32 +++ b/ext/date/config.w32 @@ -1,7 +1,7 @@ // $Id$ // vim:ft=javascript -EXTENSION("date", "php_date.c", false, "-Iext/date/lib"); +EXTENSION("date", "php_date.c", false, "/Iext/date/lib /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_SOURCES("ext/date/lib", "astro.c timelib.c dow.c parse_date.c parse_tz.c tm2unixtime.c unixtime2tm.c parse_iso_intervals.c interval.c", "date"); AC_DEFINE('HAVE_DATE', 1, 'Have date/time support'); diff --git a/ext/date/config0.m4 b/ext/date/config0.m4 index 0b46c6803a..867e891f52 100644 --- a/ext/date/config0.m4 +++ b/ext/date/config0.m4 @@ -4,7 +4,7 @@ dnl config.m4 for date extension sinclude(ext/date/lib/timelib.m4) sinclude(lib/timelib.m4) -PHP_DATE_CFLAGS="-I@ext_builddir@/lib" +PHP_DATE_CFLAGS="-I@ext_builddir@/lib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" timelib_sources="lib/astro.c lib/dow.c lib/parse_date.c lib/parse_tz.c lib/timelib.c lib/tm2unixtime.c lib/unixtime2tm.c lib/parse_iso_intervals.c lib/interval.c" diff --git a/ext/date/php_date.h b/ext/date/php_date.h index 134beef24d..667a552218 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -200,7 +200,7 @@ ZEND_BEGIN_MODULE_GLOBALS(date) ZEND_END_MODULE_GLOBALS(date) #ifdef ZTS -#define DATEG(v) TSRMG(date_globals_id, zend_date_globals *, v) +#define DATEG(v) ZEND_TSRMG(date_globals_id, zend_date_globals *, v) #else #define DATEG(v) (date_globals.v) #endif diff --git a/ext/ereg/config.w32 b/ext/ereg/config.w32 index 18a002b44d..887fb0e5b0 100644 --- a/ext/ereg/config.w32 +++ b/ext/ereg/config.w32 @@ -4,7 +4,7 @@ ARG_WITH("ereg", "POSIX extended regular expressions", "yes"); if (PHP_EREG != "no") { - EXTENSION("ereg", "ereg.c", PHP_EREG_SHARED, "-Dregexec=php_regexec -Dregerror=php_regerror -Dregfree=php_regfree -Dregcomp=php_regcomp -Iext/ereg/regex"); + EXTENSION("ereg", "ereg.c", PHP_EREG_SHARED, "-Dregexec=php_regexec -Dregerror=php_regerror -Dregfree=php_regfree -Dregcomp=php_regcomp -Iext/ereg/regex /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_SOURCES("ext/ereg/regex", "regcomp.c regexec.c regerror.c regfree.c", "ereg"); AC_DEFINE('REGEX', 1, 'Bundled regex'); AC_DEFINE('HSREGEX', 1, 'Bundled regex'); diff --git a/ext/ereg/config0.m4 b/ext/ereg/config0.m4 index caec39d285..2089f24a46 100644 --- a/ext/ereg/config0.m4 +++ b/ext/ereg/config0.m4 @@ -33,6 +33,7 @@ if test "$REGEX_TYPE" = "php"; then ereg_regex_headers="regex/" PHP_EREG_CFLAGS="-Dregexec=php_regexec -Dregerror=php_regerror -Dregfree=php_regfree -Dregcomp=php_regcomp" fi +PHP_EREG_CFLAGS="$PHP_EREG_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" PHP_NEW_EXTENSION(ereg, ereg.c $ereg_regex_sources, no,,$PHP_EREG_CFLAGS) PHP_INSTALL_HEADERS([ext/ereg], [php_ereg.h php_regex.h $ereg_regex_headers]) diff --git a/ext/ereg/php_ereg.h b/ext/ereg/php_ereg.h index f1c2676772..a1081e2669 100644 --- a/ext/ereg/php_ereg.h +++ b/ext/ereg/php_ereg.h @@ -54,7 +54,7 @@ ZEND_END_MODULE_GLOBALS(ereg) PHP_MINFO_FUNCTION(ereg); #ifdef ZTS -#define EREG(v) TSRMG(ereg_globals_id, zend_ereg_globals *, v) +#define EREG(v) ZEND_TSRMG(ereg_globals_id, zend_ereg_globals *, v) #else #define EREG(v) (ereg_globals.v) #endif diff --git a/ext/exif/config.m4 b/ext/exif/config.m4 index a3ba9240df..8a3a0d43c2 100644 --- a/ext/exif/config.m4 +++ b/ext/exif/config.m4 @@ -7,5 +7,5 @@ PHP_ARG_ENABLE(exif, whether to enable EXIF (metadata from images) support, if test "$PHP_EXIF" != "no"; then AC_DEFINE(HAVE_EXIF, 1, [Whether you want EXIF (metadata from images) support]) - PHP_NEW_EXTENSION(exif, exif.c, $ext_shared) + PHP_NEW_EXTENSION(exif, exif.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) fi diff --git a/ext/exif/config.w32 b/ext/exif/config.w32 index 38466c809c..595e71bda0 100644 --- a/ext/exif/config.w32 +++ b/ext/exif/config.w32 @@ -5,7 +5,7 @@ ARG_ENABLE("exif", "exif", "no"); if (PHP_EXIF == "yes") { if (ADD_EXTENSION_DEP('exif', 'mbstring')) { - EXTENSION("exif", "exif.c"); + EXTENSION("exif", "exif.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('HAVE_EXIF', 1, 'Have exif'); } else { WARNING("exif support can't be enabled, libxml is not enabled") diff --git a/ext/exif/exif.c b/ext/exif/exif.c index 06e1dae41a..5d00672c5c 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -156,7 +156,10 @@ ZEND_END_MODULE_GLOBALS(exif) ZEND_DECLARE_MODULE_GLOBALS(exif) #ifdef ZTS -#define EXIF_G(v) TSRMG(exif_globals_id, zend_exif_globals *, v) +#define EXIF_G(v) ZEND_TSRMG(exif_globals_id, zend_exif_globals *, v) +#ifdef COMPILE_DL_EXIF +ZEND_TSRMLS_CACHE_DEFINE; +#endif #else #define EXIF_G(v) (exif_globals.v) #endif @@ -208,6 +211,9 @@ PHP_INI_END() */ static PHP_GINIT_FUNCTION(exif) { +#if defined(COMPILE_DL_EXIF) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif exif_globals->encode_unicode = NULL; exif_globals->decode_unicode_be = NULL; exif_globals->decode_unicode_le = NULL; diff --git a/ext/filter/config.m4 b/ext/filter/config.m4 index 676f5d99ef..d589b10078 100644 --- a/ext/filter/config.m4 +++ b/ext/filter/config.m4 @@ -39,7 +39,7 @@ yes CPPFLAGS=$old_CPPFLAGS fi - PHP_NEW_EXTENSION(filter, filter.c sanitizing_filters.c logical_filters.c callback_filter.c, $ext_shared) + PHP_NEW_EXTENSION(filter, filter.c sanitizing_filters.c logical_filters.c callback_filter.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_SUBST(FILTER_SHARED_LIBADD) PHP_INSTALL_HEADERS([ext/filter/php_filter.h]) diff --git a/ext/filter/config.w32 b/ext/filter/config.w32 index b74f3a2fd0..0a9e147569 100644 --- a/ext/filter/config.w32 +++ b/ext/filter/config.w32 @@ -4,6 +4,6 @@ ARG_ENABLE("filter", "Filter Support", "yes"); if (PHP_FILTER == "yes") { - EXTENSION("filter", "filter.c sanitizing_filters.c logical_filters.c callback_filter.c"); + EXTENSION("filter", "filter.c sanitizing_filters.c logical_filters.c callback_filter.c", PHP_FILTER_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); PHP_INSTALL_HEADERS("ext/filter", "php_filter.h"); } diff --git a/ext/filter/filter.c b/ext/filter/filter.c index dec6bfb4ec..d1b2abf2aa 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -153,6 +153,9 @@ zend_module_entry filter_module_entry = { /* }}} */ #ifdef COMPILE_DL_FILTER +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(filter) #endif @@ -192,6 +195,9 @@ PHP_INI_END() static void php_filter_init_globals(zend_filter_globals *filter_globals) /* {{{ */ { +#if defined(COMPILE_DL_FILTER) && defined(ZTS) +ZEND_TSRMLS_CACHE_UPDATE; +#endif ZVAL_UNDEF(&filter_globals->post_array); ZVAL_UNDEF(&filter_globals->get_array); ZVAL_UNDEF(&filter_globals->cookie_array); diff --git a/ext/filter/php_filter.h b/ext/filter/php_filter.h index a82b2e6159..7ddb009b87 100644 --- a/ext/filter/php_filter.h +++ b/ext/filter/php_filter.h @@ -64,7 +64,8 @@ ZEND_BEGIN_MODULE_GLOBALS(filter) ZEND_END_MODULE_GLOBALS(filter) #ifdef ZTS -#define IF_G(v) TSRMG(filter_globals_id, zend_filter_globals *, v) +#define IF_G(v) ZEND_TSRMG(filter_globals_id, zend_filter_globals *, v) +ZEND_TSRMLS_CACHE_EXTERN; #else #define IF_G(v) (filter_globals.v) #endif diff --git a/ext/gmp/config.m4 b/ext/gmp/config.m4 index 0388d548cf..8265fb8dfa 100644 --- a/ext/gmp/config.m4 +++ b/ext/gmp/config.m4 @@ -21,7 +21,7 @@ if test "$PHP_GMP" != "no"; then PHP_ADD_LIBRARY_WITH_PATH(gmp, $GMP_DIR/$PHP_LIBDIR, GMP_SHARED_LIBADD) PHP_ADD_INCLUDE($GMP_DIR/include) - PHP_NEW_EXTENSION(gmp, gmp.c, $ext_shared) + PHP_NEW_EXTENSION(gmp, gmp.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_SUBST(GMP_SHARED_LIBADD) AC_DEFINE(HAVE_GMP, 1, [ ]) fi diff --git a/ext/gmp/config.w32 b/ext/gmp/config.w32 index 8c863f9bc8..7ea36150b2 100644 --- a/ext/gmp/config.w32 +++ b/ext/gmp/config.w32 @@ -6,7 +6,7 @@ ARG_WITH("gmp", "Include GNU MP support.", "no"); if (PHP_GMP != "no") { if (CHECK_LIB("mpir_a.lib", "gmp", PHP_GMP) && CHECK_HEADER_ADD_INCLUDE("gmp.h", "CFLAGS_GMP", PHP_GMP + ";" + PHP_PHP_BUILD + "\\include\\mpir")) { - EXTENSION("gmp", "gmp.c"); + EXTENSION("gmp", "gmp.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('HAVE_GMP', 1, 'GMP support'); AC_DEFINE('HAVE_MPIR', 1, 'MPIR support'); } else { diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index d3bf334640..5d1d1e689e 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -214,6 +214,9 @@ zend_module_entry gmp_module_entry = { /* }}} */ #ifdef COMPILE_DL_GMP +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(gmp) #endif @@ -630,6 +633,9 @@ exit: */ static ZEND_GINIT_FUNCTION(gmp) { +#if defined(COMPILE_DL_GMP) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif gmp_globals->rand_initialized = 0; } /* }}} */ diff --git a/ext/gmp/php_gmp.h b/ext/gmp/php_gmp.h index 0fdc1510f9..27d621bb39 100644 --- a/ext/gmp/php_gmp.h +++ b/ext/gmp/php_gmp.h @@ -93,7 +93,10 @@ ZEND_BEGIN_MODULE_GLOBALS(gmp) ZEND_END_MODULE_GLOBALS(gmp) #ifdef ZTS -#define GMPG(v) TSRMG(gmp_globals_id, zend_gmp_globals *, v) +#define GMPG(v) ZEND_TSRMG(gmp_globals_id, zend_gmp_globals *, v) +#ifdef COMPILE_DL_GMP +ZEND_TSRMLS_CACHE_EXTERN; +#endif #else #define GMPG(v) (gmp_globals.v) #endif diff --git a/ext/iconv/config.m4 b/ext/iconv/config.m4 index 10d21ccc6d..88e5abf97e 100644 --- a/ext/iconv/config.m4 +++ b/ext/iconv/config.m4 @@ -171,7 +171,7 @@ int main() { AC_MSG_RESULT([no]) ]) - PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared,, [-I\"$PHP_ICONV_PREFIX/include\"]) + PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared,, [-I\"$PHP_ICONV_PREFIX/include\" -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) PHP_SUBST(ICONV_SHARED_LIBADD) PHP_INSTALL_HEADERS([ext/iconv/]) else diff --git a/ext/iconv/config.w32 b/ext/iconv/config.w32 index 00ab272423..989a477fa5 100644 --- a/ext/iconv/config.w32 +++ b/ext/iconv/config.w32 @@ -8,7 +8,7 @@ if (PHP_ICONV != "no") { CHECK_LIB("iconv_a.lib", "iconv", PHP_ICONV) || CHECK_LIB("iconv.lib", "iconv", PHP_ICONV)) && CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_ICONV", PHP_ICONV)) { - EXTENSION("iconv", "iconv.c"); + EXTENSION("iconv", "iconv.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE("HAVE_ICONV", 1, "Define if iconv extension is enabled"); AC_DEFINE("HAVE_LIBICONV", 1, "Define if libiconv is available"); diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index a4581e9fad..c8dcc15e99 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -164,12 +164,18 @@ zend_module_entry iconv_module_entry = { /* }}} */ #ifdef COMPILE_DL_ICONV +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(iconv) #endif /* {{{ PHP_GINIT_FUNCTION */ static PHP_GINIT_FUNCTION(iconv) { +#if defined(COMPILE_DL_ICONV) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif iconv_globals->input_encoding = NULL; iconv_globals->output_encoding = NULL; iconv_globals->internal_encoding = NULL; diff --git a/ext/iconv/php_iconv.h b/ext/iconv/php_iconv.h index 1a8330ae24..b2440fc03a 100644 --- a/ext/iconv/php_iconv.h +++ b/ext/iconv/php_iconv.h @@ -73,7 +73,10 @@ ZEND_BEGIN_MODULE_GLOBALS(iconv) ZEND_END_MODULE_GLOBALS(iconv) #ifdef ZTS -# define ICONVG(v) TSRMG(iconv_globals_id, zend_iconv_globals *, v) +# define ICONVG(v) ZEND_TSRMG(iconv_globals_id, zend_iconv_globals *, v) +# ifdef COMPILE_DL_ICONV +ZEND_TSRMLS_CACHE_EXTERN; +# endif #else # define ICONVG(v) (iconv_globals.v) #endif diff --git a/ext/intl/config.m4 b/ext/intl/config.m4 index 5afee4809e..0fbbd0f786 100644 --- a/ext/intl/config.m4 +++ b/ext/intl/config.m4 @@ -85,7 +85,7 @@ if test "$PHP_INTL" != "no"; then breakiterator/codepointiterator_internal.cpp \ breakiterator/codepointiterator_methods.cpp \ idn/idn.c \ - $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS) + $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_ADD_BUILD_DIR($ext_builddir/collator) PHP_ADD_BUILD_DIR($ext_builddir/converter) PHP_ADD_BUILD_DIR($ext_builddir/common) diff --git a/ext/intl/config.w32 b/ext/intl/config.w32 index 22cde6bd6d..4628e434f7 100644 --- a/ext/intl/config.w32 +++ b/ext/intl/config.w32 @@ -8,7 +8,7 @@ if (PHP_INTL != "no") { CHECK_HEADER_ADD_INCLUDE("unicode/utf.h", "CFLAGS_INTL")) { // always build as shared - zend_strtod.c/ICU type conflict EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", true, - "/I \"" + configure_module_dirname + "\""); + "/I \"" + configure_module_dirname + "\" /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_SOURCES(configure_module_dirname + "/collator", "\ collator.c \ collator_attr.c \ diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index b27652aa9a..eb37ce00f1 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -24,9 +24,6 @@ #include "../intl_error.h" typedef struct _php_converter_object { -#ifdef ZTS - void ***tsrm_ls; -#endif UConverter *src, *dest; zend_fcall_info to_cb, from_cb; zend_fcall_info_cache to_cache, from_cache; @@ -229,9 +226,6 @@ static void php_converter_to_u_callback(const void *context, php_converter_object *objval = (php_converter_object*)context; zval retval; zval zargs[4]; -#ifdef ZTS - TSRMLS_D = objval->tsrm_ls; -#endif ZVAL_LONG(&zargs[0], reason); ZVAL_STRINGL(&zargs[1], args->source, args->sourceLimit - args->source); @@ -308,9 +302,6 @@ static void php_converter_from_u_callback(const void *context, zval retval; zval zargs[4]; int i; -#ifdef ZTS - TSRMLS_D = objval->tsrm_ls; -#endif ZVAL_LONG(&zargs[0], reason); array_init(&zargs[1]); @@ -1045,9 +1036,6 @@ static zend_object *php_converter_object_ctor(zend_class_entry *ce, php_converte objval = ecalloc(1, sizeof(php_converter_object) + sizeof(zval) * (ce->default_properties_count - 1)); zend_object_std_init(&objval->obj, ce TSRMLS_CC ); -#ifdef ZTS - objval->tsrm_ls = TSRMLS_C; -#endif intl_error_init(&(objval->error) TSRMLS_CC); objval->obj.handlers = &php_converter_object_handlers; diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index 2c5e74809d..15f058d2b4 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -893,12 +893,18 @@ zend_module_entry intl_module_entry = { /* }}} */ #ifdef COMPILE_DL_INTL +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE( intl ) #endif /* {{{ intl_init_globals */ static PHP_GINIT_FUNCTION(intl) { +#if defined(COMPILE_DL_INTL) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif memset( intl_globals, 0, sizeof(zend_intl_globals) ); } /* }}} */ diff --git a/ext/intl/php_intl.h b/ext/intl/php_intl.h index 3625c4fdcc..265cdb7b9e 100644 --- a/ext/intl/php_intl.h +++ b/ext/intl/php_intl.h @@ -56,7 +56,10 @@ ZEND_END_MODULE_GLOBALS(intl) /* Macro to access request-wide global variables. */ #ifdef ZTS -#define INTL_G(v) TSRMG(intl_globals_id, zend_intl_globals *, v) +#define INTL_G(v) ZEND_TSRMG(intl_globals_id, zend_intl_globals *, v) +#ifdef COMPILE_DL_INTL +ZEND_TSRMLS_CACHE_EXTERN; +#endif #else #define INTL_G(v) (intl_globals.v) #endif diff --git a/ext/json/config.m4 b/ext/json/config.m4 index 26c43a0e3f..9c83a5d893 100644 --- a/ext/json/config.m4 +++ b/ext/json/config.m4 @@ -9,7 +9,7 @@ if test "$PHP_JSON" != "no"; then AC_DEFINE([HAVE_JSON],1 ,[whether to enable JavaScript Object Serialization support]) AC_HEADER_STDC - PHP_NEW_EXTENSION(json, json.c utf8_decode.c JSON_parser.c, $ext_shared) + PHP_NEW_EXTENSION(json, json.c utf8_decode.c JSON_parser.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_INSTALL_HEADERS([ext/json], [php_json.h]) PHP_SUBST(JSON_SHARED_LIBADD) fi diff --git a/ext/json/config.w32 b/ext/json/config.w32 index cedbf42829..60ccf91630 100644 --- a/ext/json/config.w32 +++ b/ext/json/config.w32 @@ -4,7 +4,7 @@ ARG_ENABLE("json", "JavaScript Object Serialization support", "yes"); if (PHP_JSON != "no") { - EXTENSION('json', 'json.c', PHP_JSON_SHARED, ""); + EXTENSION('json', 'json.c', PHP_JSON_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_SOURCES(configure_module_dirname, "JSON_parser.c utf8_decode.c", "json"); PHP_INSTALL_HEADERS("ext/json/", "php_json.h"); } diff --git a/ext/json/json.c b/ext/json/json.c index 8f4f281ef1..91bedcace9 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -125,6 +125,9 @@ static PHP_MINIT_FUNCTION(json) */ static PHP_GINIT_FUNCTION(json) { +#if defined(COMPILE_DL_JSON) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif json_globals->encoder_depth = 0; json_globals->error_code = 0; json_globals->encode_max_depth = 0; @@ -153,6 +156,9 @@ zend_module_entry json_module_entry = { /* }}} */ #ifdef COMPILE_DL_JSON +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(json) #endif diff --git a/ext/json/php_json.h b/ext/json/php_json.h index 5b2dc127dd..64ad811bc7 100644 --- a/ext/json/php_json.h +++ b/ext/json/php_json.h @@ -44,7 +44,10 @@ ZEND_BEGIN_MODULE_GLOBALS(json) ZEND_END_MODULE_GLOBALS(json) #ifdef ZTS -# define JSON_G(v) TSRMG(json_globals_id, zend_json_globals *, v) +# define JSON_G(v) ZEND_TSRMG(json_globals_id, zend_json_globals *, v) +# ifdef COMPILE_DL_JSON +ZEND_TSRMLS_CACHE_EXTERN; +# endif #else # define JSON_G(v) (json_globals.v) #endif diff --git a/ext/libxml/config.w32 b/ext/libxml/config.w32 index 92144f9ad0..e6ad0dc1ab 100644 --- a/ext/libxml/config.w32 +++ b/ext/libxml/config.w32 @@ -9,7 +9,7 @@ if (PHP_LIBXML == "yes") { CHECK_HEADER_ADD_INCLUDE("libxml/parser.h", "CFLAGS_LIBXML") && ADD_EXTENSION_DEP('libxml', 'iconv')) { - EXTENSION("libxml", "libxml.c", false /* never shared */); + EXTENSION("libxml", "libxml.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE("HAVE_LIBXML", 1, "LibXML support"); ADD_FLAG("CFLAGS_LIBXML", "/D LIBXML_STATIC /D LIBXML_STATIC_FOR_DLL /D HAVE_WIN32_THREADS "); if (!PHP_LIBXML_SHARED) { diff --git a/ext/libxml/config0.m4 b/ext/libxml/config0.m4 index 14f5868493..79e94a40ad 100644 --- a/ext/libxml/config0.m4 +++ b/ext/libxml/config0.m4 @@ -17,7 +17,7 @@ if test "$PHP_LIBXML" != "no"; then PHP_SETUP_LIBXML(LIBXML_SHARED_LIBADD, [ AC_DEFINE(HAVE_LIBXML,1,[ ]) - PHP_NEW_EXTENSION(libxml, [libxml.c], $ext_shared) + PHP_NEW_EXTENSION(libxml, [libxml.c], $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_INSTALL_HEADERS([ext/libxml/php_libxml.h]) ], [ AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index 3e4fb60825..ad12e3464d 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -79,6 +79,9 @@ static zend_class_entry *libxmlerror_class_entry; /* {{{ dynamically loadable module stuff */ #ifdef COMPILE_DL_LIBXML +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(libxml) #endif /* COMPILE_DL_LIBXML */ /* }}} */ @@ -268,6 +271,9 @@ static void php_libxml_node_free_list(xmlNodePtr node TSRMLS_DC) /* {{{ startup, shutdown and info functions */ static PHP_GINIT_FUNCTION(libxml) { +#if defined(COMPILE_DL_LIBXML) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif ZVAL_UNDEF(&libxml_globals->stream_context); libxml_globals->error_buffer.s = NULL; libxml_globals->error_list = NULL; diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h index cccc83f8db..ed5a5a70db 100644 --- a/ext/libxml/php_libxml.h +++ b/ext/libxml/php_libxml.h @@ -113,7 +113,10 @@ PHP_LIBXML_API void php_libxml_initialize(void); PHP_LIBXML_API void php_libxml_shutdown(void); #ifdef ZTS -#define LIBXML(v) TSRMG(libxml_globals_id, zend_libxml_globals *, v) +#define LIBXML(v) ZEND_TSRMG(libxml_globals_id, zend_libxml_globals *, v) +#ifdef COMPILE_DL_LIBXML +ZEND_TSRMLS_CACHE_EXTERN; +#endif #else #define LIBXML(v) (libxml_globals.v) #endif diff --git a/ext/mbstring/config.m4 b/ext/mbstring/config.m4 index 25bf238761..bd88ee4b63 100644 --- a/ext/mbstring/config.m4 +++ b/ext/mbstring/config.m4 @@ -31,7 +31,7 @@ AC_DEFUN([PHP_MBSTRING_ADD_INSTALL_HEADERS], [ ]) AC_DEFUN([PHP_MBSTRING_EXTENSION], [ - PHP_NEW_EXTENSION(mbstring, $PHP_MBSTRING_SOURCES, $ext_shared,, $PHP_MBSTRING_CFLAGS) + PHP_NEW_EXTENSION(mbstring, $PHP_MBSTRING_SOURCES, $ext_shared,, $PHP_MBSTRING_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_SUBST(MBSTRING_SHARED_LIBADD) for dir in $PHP_MBSTRING_EXTRA_BUILD_DIRS; do diff --git a/ext/mbstring/config.w32 b/ext/mbstring/config.w32 index cf6143699b..ca1fbcdf28 100644 --- a/ext/mbstring/config.w32 +++ b/ext/mbstring/config.w32 @@ -19,7 +19,7 @@ if (PHP_MBSTRING != "no") { ADD_FLAG("CFLAGS_MBSTRING", get_define("CFLAGS_LIBMBFL") + " /I ext/mbstring/oniguruma /D NOT_RUBY=1 \ /D HAVE_STDARG_PROTOTYPES=1 /D HAVE_STDLIB_H \ - /D HAVE_STRICMP /D EXPORT"); + /D HAVE_STRICMP /D EXPORT /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); PHP_INSTALL_HEADERS("ext/mbstring", "mbstring.h oniguruma/oniguruma.h php_mbregex.h php_onig_compat.h"); } else { @@ -28,7 +28,7 @@ if (PHP_MBSTRING != "no") { ADD_FLAG("CFLAGS_MBSTRING", "-Iext/mbstring/libmbfl -Iext/mbstring/libmbfl/mbfl \ -Iext/mbstring/oniguruma /D NOT_RUBY=1 /D LIBMBFL_EXPORTS=1 \ /D HAVE_STDARG_PROTOTYPES=1 /D HAVE_CONFIG_H /D HAVE_STDLIB_H \ - /D HAVE_STRICMP /D MBFL_DLL_EXPORT=1 /D EXPORT") + /D HAVE_STRICMP /D MBFL_DLL_EXPORT=1 /D EXPORT /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1") FSO.CopyFile("ext\\mbstring\\libmbfl\\config.h.w32", "ext\\mbstring\\libmbfl\\config.h", true); diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 691391ab92..4cc73423d8 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -597,6 +597,9 @@ static sapi_post_entry php_post_entries[] = { /* }}} */ #ifdef COMPILE_DL_MBSTRING +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(mbstring) #endif @@ -1491,6 +1494,10 @@ PHP_INI_END() /* {{{ module global initialize handler */ static PHP_GINIT_FUNCTION(mbstring) { +#if defined(COMPILE_DL_MBSTRING) && defined(ZTS) +ZEND_TSRMLS_CACHE_UPDATE; +#endif + mbstring_globals->language = mbfl_no_language_uni; mbstring_globals->internal_encoding = NULL; mbstring_globals->current_internal_encoding = mbstring_globals->internal_encoding; diff --git a/ext/mbstring/mbstring.h b/ext/mbstring/mbstring.h index 0136f8ef7d..bc6434f81f 100644 --- a/ext/mbstring/mbstring.h +++ b/ext/mbstring/mbstring.h @@ -200,7 +200,8 @@ struct mb_overload_def { }; #ifdef ZTS -#define MBSTRG(v) TSRMG(mbstring_globals_id, zend_mbstring_globals *, v) +#define MBSTRG(v) ZEND_TSRMG(mbstring_globals_id, zend_mbstring_globals *, v) +ZEND_TSRMLS_CACHE_EXTERN; #else #define MBSTRG(v) (mbstring_globals.v) #endif diff --git a/ext/mysql/config.m4 b/ext/mysql/config.m4 index fd7f52ef3a..70bfd7110b 100644 --- a/ext/mysql/config.m4 +++ b/ext/mysql/config.m4 @@ -158,7 +158,7 @@ if test "$PHP_MYSQL" != "no"; then fi AC_DEFINE(HAVE_MYSQL, 1, [Whether you have MySQL]) - PHP_NEW_EXTENSION(mysql, php_mysql.c, $ext_shared) + PHP_NEW_EXTENSION(mysql, php_mysql.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_SUBST(MYSQL_SHARED_LIBADD) if test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL" = "mysqlnd"; then diff --git a/ext/mysql/config.w32 b/ext/mysql/config.w32 index 2a929b4165..0af94d9623 100644 --- a/ext/mysql/config.w32 +++ b/ext/mysql/config.w32 @@ -10,7 +10,7 @@ if (PHP_MYSQL != "no") { PHP_MYSQL = "no"; WARNING("mysql not enabled; mysqlnd is not enabled"); } else { - EXTENSION("mysql", "php_mysql.c"); + EXTENSION("mysql", "php_mysql.c", PHP_MYSQL_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('HAVE_MYSQL', 1, 'Have MySQL library'); MESSAGE("\tusing mysqlnd build"); } @@ -18,7 +18,7 @@ if (PHP_MYSQL != "no") { if (CHECK_LIB("libmysql.lib", "mysql", PHP_MYSQL) && CHECK_HEADER_ADD_INCLUDE("mysql.h", "CFLAGS_MYSQL", PHP_MYSQL + "\\include;" + PHP_PHP_BUILD + "\\include\\mysql;" + PHP_MYSQL)) { - EXTENSION("mysql", "php_mysql.c"); + EXTENSION("mysql", "php_mysql.c", PHP_MYSQL_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('HAVE_MYSQL', 1, 'Have MySQL library'); MESSAGE("\tusing libmysql"); } else { diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 4fcc9ca83a..384ce9a6ba 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -352,6 +352,9 @@ zend_module_entry mysql_module_entry = { /* }}} */ #ifdef COMPILE_DL_MYSQL +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(mysql) #endif @@ -512,6 +515,9 @@ PHP_INI_END() */ static PHP_GINIT_FUNCTION(mysql) { +#if defined(COMPILE_DL_MYSQL) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif mysql_globals->num_persistent = 0; mysql_globals->default_socket = NULL; mysql_globals->default_host = NULL; diff --git a/ext/mysql/php_mysql_structs.h b/ext/mysql/php_mysql_structs.h index 8eb9aa1d29..214a5c689b 100644 --- a/ext/mysql/php_mysql_structs.h +++ b/ext/mysql/php_mysql_structs.h @@ -127,7 +127,10 @@ ZEND_BEGIN_MODULE_GLOBALS(mysql) ZEND_END_MODULE_GLOBALS(mysql) #ifdef ZTS -# define MySG(v) TSRMG(mysql_globals_id, zend_mysql_globals *, v) +# define MySG(v) ZEND_TSRMG(mysql_globals_id, zend_mysql_globals *, v) +# ifdef COMPILE_DL_MYSQL +ZEND_TSRMLS_CACHE_EXTERN; +# endif #else # define MySG(v) (mysql_globals.v) #endif diff --git a/ext/mysqli/config.m4 b/ext/mysqli/config.m4 index f6c86e762b..dedd1bc4a7 100644 --- a/ext/mysqli/config.m4 +++ b/ext/mysqli/config.m4 @@ -75,7 +75,7 @@ if test "$PHP_MYSQLI" != "no"; then mysqli_sources="mysqli.c mysqli_api.c mysqli_prop.c mysqli_nonapi.c \ mysqli_fe.c mysqli_report.c mysqli_driver.c mysqli_warning.c \ mysqli_exception.c mysqli_result_iterator.c $mysqli_extra_sources" - PHP_NEW_EXTENSION(mysqli, $mysqli_sources, $ext_shared) + PHP_NEW_EXTENSION(mysqli, $mysqli_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_SUBST(MYSQLI_SHARED_LIBADD) PHP_INSTALL_HEADERS([ext/mysqli/php_mysqli_structs.h]) diff --git a/ext/mysqli/config.w32 b/ext/mysqli/config.w32 index ab8bcd0087..9213931393 100644 --- a/ext/mysqli/config.w32 +++ b/ext/mysqli/config.w32 @@ -23,7 +23,7 @@ if (PHP_MYSQLI != "no") { "mysqli_warning.c"; if (PHP_MYSQLI == "yes" || PHP_MYSQLI == "mysqlnd") { - EXTENSION("mysqli", mysqli_source); + EXTENSION("mysqli", mysqli_source, PHP_MYSQLI_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('MYSQLI_USE_MYSQLND', 1, 'Using MySQL native driver'); AC_DEFINE('HAVE_MYSQLILIB', 1, 'Have MySQLi library'); ADD_EXTENSION_DEP('mysqli', 'mysqlnd', true); @@ -34,7 +34,7 @@ if (PHP_MYSQLI != "no") { CHECK_HEADER_ADD_INCLUDE("mysql.h", "CFLAGS_MYSQLI", PHP_MYSQLI + "\\include;" + PHP_PHP_BUILD + "\\include\\mysql;" + PHP_MYSQLI)) { - EXTENSION("mysqli", mysqli_source); + EXTENSION("mysqli", mysqli_source, PHP_MYSQLI_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('HAVE_MYSQLILIB', 1, 'Have MySQLi library'); MESSAGE("\tlibmysql build"); PHP_INSTALL_HEADERS("ext/mysqli", "php_mysqli_structs.h"); diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index 6d7210fe59..88b79451b2 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -537,6 +537,9 @@ PHP_INI_END() */ static PHP_GINIT_FUNCTION(mysqli) { +#if defined(COMPILE_DL_MYSQLI) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif mysqli_globals->num_links = 0; mysqli_globals->num_active_persistent = 0; mysqli_globals->num_inactive_persistent = 0; @@ -1030,6 +1033,9 @@ zend_module_entry mysqli_module_entry = { /* }}} */ #ifdef COMPILE_DL_MYSQLI +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(mysqli) #endif diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h index d815df3eee..cf12c5bba5 100644 --- a/ext/mysqli/php_mysqli_structs.h +++ b/ext/mysqli/php_mysqli_structs.h @@ -344,7 +344,10 @@ ZEND_END_MODULE_GLOBALS(mysqli) #ifdef ZTS -#define MyG(v) TSRMG(mysqli_globals_id, zend_mysqli_globals *, v) +#define MyG(v) ZEND_TSRMG(mysqli_globals_id, zend_mysqli_globals *, v) +#ifdef COMPILE_DL_MYSQLI +ZEND_TSRMLS_CACHE_EXTERN; +#endif #else #define MyG(v) (mysqli_globals.v) #endif diff --git a/ext/mysqlnd/config.w32 b/ext/mysqlnd/config.w32 index b13a81530a..ff102310dd 100644 --- a/ext/mysqlnd/config.w32 +++ b/ext/mysqlnd/config.w32 @@ -25,7 +25,7 @@ if (PHP_MYSQLND != "no") { "mysqlnd_statistics.c " + "mysqlnd_wireprotocol.c " + "php_mysqlnd.c "; - EXTENSION("mysqlnd", mysqlnd_source, false); + EXTENSION("mysqlnd", mysqlnd_source, false, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); if ((((PHP_ZLIB=="no") && (CHECK_LIB("zlib_a.lib;zlib.lib", "mysqlnd", PHP_MYSQLND))) || (PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "mysqlnd", PHP_MYSQLND)) || (PHP_ZLIB == "yes" && (!PHP_ZLIB_SHARED))) && diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4 index 1a0136d8db..756a325014 100644 --- a/ext/mysqlnd/config9.m4 +++ b/ext/mysqlnd/config9.m4 @@ -41,7 +41,7 @@ if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then fi mysqlnd_sources="$mysqlnd_base_sources $mysqlnd_ps_sources" - PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, $ext_shared) + PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_ADD_BUILD_DIR([ext/mysqlnd], 1) PHP_INSTALL_HEADERS([ext/mysqlnd/]) fi diff --git a/ext/mysqlnd/mysqlnd.h b/ext/mysqlnd/mysqlnd.h index aab977d24c..2e45740abb 100644 --- a/ext/mysqlnd/mysqlnd.h +++ b/ext/mysqlnd/mysqlnd.h @@ -288,7 +288,10 @@ ZEND_END_MODULE_GLOBALS(mysqlnd) PHPAPI ZEND_EXTERN_MODULE_GLOBALS(mysqlnd) #ifdef ZTS -#define MYSQLND_G(v) TSRMG(mysqlnd_globals_id, zend_mysqlnd_globals *, v) +#define MYSQLND_G(v) ZEND_TSRMG(mysqlnd_globals_id, zend_mysqlnd_globals *, v) +#ifdef COMPILE_DL_MYSQLND +ZEND_TSRMLS_CACHE_EXTERN; +#endif #else #define MYSQLND_G(v) (mysqlnd_globals.v) #endif diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c index f1fde4efbb..c8f682b8e2 100644 --- a/ext/mysqlnd/mysqlnd_debug.c +++ b/ext/mysqlnd/mysqlnd_debug.c @@ -39,8 +39,6 @@ static const char * const mysqlnd_debug_empty_string = ""; static enum_func_status MYSQLND_METHOD(mysqlnd_debug, open)(MYSQLND_DEBUG * self, zend_bool reopen) { - MYSQLND_ZTS(self); - if (!self->file_name) { return FAIL; } @@ -67,7 +65,6 @@ MYSQLND_METHOD(mysqlnd_debug, log)(MYSQLND_DEBUG * self, unsigned int flags = self->flags; char pid_buffer[10], time_buffer[30], file_buffer[200], line_buffer[6], level_buffer[7]; - MYSQLND_ZTS(self); if (!self->stream && FAIL == self->m->open(self, FALSE)) { return FAIL; @@ -165,7 +162,6 @@ MYSQLND_METHOD(mysqlnd_debug, log_va)(MYSQLND_DEBUG *self, unsigned int flags = self->flags; char pid_buffer[10], time_buffer[30], file_buffer[200], line_buffer[6], level_buffer[7]; - MYSQLND_ZTS(self); if (!self->stream && FAIL == self->m->open(self, FALSE)) { return FAIL; @@ -436,7 +432,6 @@ MYSQLND_METHOD(mysqlnd_debug, func_leave)(MYSQLND_DEBUG * self, unsigned int lin static enum_func_status MYSQLND_METHOD(mysqlnd_debug, close)(MYSQLND_DEBUG * self) { - MYSQLND_ZTS(self); if (self->stream) { #ifndef MYSQLND_PROFILING_DISABLED if (!(self->flags & MYSQLND_DEBUG_FLUSH) && (self->flags & MYSQLND_DEBUG_PROFILE_CALLS)) { @@ -718,9 +713,7 @@ PHPAPI MYSQLND_DEBUG * mysqlnd_debug_init(const char * skip_functions[] TSRMLS_DC) { MYSQLND_DEBUG *ret = calloc(1, sizeof(MYSQLND_DEBUG)); -#ifdef ZTS - ret->TSRMLS_C = TSRMLS_C; -#endif + ret->nest_level_limit = 0; ret->pid = getpid(); zend_stack_init(&ret->call_stack, sizeof(char *)); diff --git a/ext/mysqlnd/mysqlnd_debug.h b/ext/mysqlnd/mysqlnd_debug.h index bb4ff3e895..e8dfeb6c4a 100644 --- a/ext/mysqlnd/mysqlnd_debug.h +++ b/ext/mysqlnd/mysqlnd_debug.h @@ -45,9 +45,6 @@ struct st_mysqlnd_debug_methods struct st_mysqlnd_debug { php_stream *stream; -#ifdef ZTS - TSRMLS_D; -#endif unsigned int flags; unsigned int nest_level_limit; int pid; diff --git a/ext/mysqlnd/mysqlnd_driver.c b/ext/mysqlnd/mysqlnd_driver.c index e67d023edb..a35474b9e6 100644 --- a/ext/mysqlnd/mysqlnd_driver.c +++ b/ext/mysqlnd/mysqlnd_driver.c @@ -99,9 +99,7 @@ static void mysqlnd_error_list_pdtor(void * pDest) { MYSQLND_ERROR_LIST_ELEMENT * element = (MYSQLND_ERROR_LIST_ELEMENT *) pDest; -#ifdef ZTS - TSRMLS_FETCH(); -#endif + DBG_ENTER("mysqlnd_error_list_pdtor"); if (element->error) { mnd_pefree(element->error, TRUE); diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c index a16018f6ba..71512e8d46 100644 --- a/ext/mysqlnd/php_mysqlnd.c +++ b/ext/mysqlnd/php_mysqlnd.c @@ -179,6 +179,9 @@ PHPAPI ZEND_DECLARE_MODULE_GLOBALS(mysqlnd) */ static PHP_GINIT_FUNCTION(mysqlnd) { +#if defined(COMPILE_DL_MYSQLND) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif mysqlnd_globals->collect_statistics = TRUE; mysqlnd_globals->collect_memory_statistics = FALSE; mysqlnd_globals->debug = NULL; /* The actual string */ @@ -357,6 +360,9 @@ zend_module_entry mysqlnd_module_entry = { /* {{{ COMPILE_DL_MYSQLND */ #ifdef COMPILE_DL_MYSQLND +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(mysqlnd) #endif /* }}} */ diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 34b5b47808..486cb39a17 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -90,6 +90,9 @@ ZEND_EXTENSION(); zend_accel_globals accel_globals; #else int accel_globals_id; +#if defined(COMPILE_DL_OPCACHE) +ZEND_TSRMLS_CACHE_DEFINE; +#endif #endif /* Points to the structure shared across all PHP processes */ @@ -2232,6 +2235,9 @@ static int zend_accel_init_shm(TSRMLS_D) static void accel_globals_ctor(zend_accel_globals *accel_globals TSRMLS_DC) { +#if defined(COMPILE_DL_OPCACHE) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif memset(accel_globals, 0, sizeof(zend_accel_globals)); zend_hash_init(&accel_globals->function_table, zend_hash_num_elements(CG(function_table)), NULL, ZEND_FUNCTION_DTOR, 1); zend_accel_copy_internal_functions(TSRMLS_C); diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index 619ade025d..119148aa27 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -284,8 +284,11 @@ extern zend_accel_shared_globals *accel_shared_globals; #define ZCSG(element) (accel_shared_globals->element) #ifdef ZTS -# define ZCG(v) TSRMG(accel_globals_id, zend_accel_globals *, v) +# define ZCG(v) ZEND_TSRMG(accel_globals_id, zend_accel_globals *, v) extern int accel_globals_id; +# ifdef COMPILE_DL_OPCACHE +ZEND_TSRMLS_CACHE_EXTERN; +# endif #else # define ZCG(v) (accel_globals.v) extern zend_accel_globals accel_globals; diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4 index 793105b966..be2f0feab7 100644 --- a/ext/opcache/config.m4 +++ b/ext/opcache/config.m4 @@ -385,7 +385,7 @@ fi Optimizer/optimize_temp_vars_5.c \ Optimizer/nop_removal.c \ Optimizer/compact_literals.c, - shared,,,,yes) + shared,,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1,,yes) PHP_ADD_BUILD_DIR([$ext_builddir/Optimizer], 1) fi diff --git a/ext/opcache/config.w32 b/ext/opcache/config.w32 index 9a0713d608..921f0ed9b4 100644 --- a/ext/opcache/config.w32 +++ b/ext/opcache/config.w32 @@ -14,7 +14,7 @@ if (PHP_OPCACHE != "no") { zend_persist.c \ zend_persist_calc.c \ zend_shared_alloc.c \ - shared_alloc_win32.c", true); + shared_alloc_win32.c", true, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_SOURCES(configure_module_dirname + "/Optimizer", "zend_optimizer.c pass1_5.c pass2.c pass3.c optimize_func_calls.c block_pass.c optimize_temp_vars_5.c nop_removal.c compact_literals.c", "opcache", "OptimizerObj"); diff --git a/ext/pcre/config.w32 b/ext/pcre/config.w32 index 594b1cb474..1fe4b687f6 100644 --- a/ext/pcre/config.w32 +++ b/ext/pcre/config.w32 @@ -2,7 +2,7 @@ // vim:ft=javascript EXTENSION("pcre", "php_pcre.c", false /* never shared */, - "-Iext/pcre/pcrelib"); + "-Iext/pcre/pcrelib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_SOURCES("ext/pcre/pcrelib", "pcre_chartables.c pcre_ucd.c pcre_compile.c pcre_config.c pcre_exec.c pcre_fullinfo.c pcre_get.c pcre_globals.c pcre_maketables.c pcre_newline.c pcre_ord2utf8.c pcre_refcount.c pcre_study.c pcre_tables.c pcre_valid_utf8.c pcre_version.c pcre_xclass.c pcre_jit_compile.c", "pcre"); ADD_DEF_FILE("ext\\pcre\\php_pcre.def"); diff --git a/ext/pcre/config0.m4 b/ext/pcre/config0.m4 index bfe2009aa0..7749bb68df 100644 --- a/ext/pcre/config0.m4 +++ b/ext/pcre/config0.m4 @@ -47,7 +47,7 @@ PHP_ARG_WITH(pcre-regex,, AC_DEFINE(HAVE_PCRE, 1, [ ]) PHP_ADD_INCLUDE($PCRE_INCDIR) - PHP_NEW_EXTENSION(pcre, php_pcre.c, no) + PHP_NEW_EXTENSION(pcre, php_pcre.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h]) else AC_MSG_CHECKING([for PCRE library to use]) @@ -60,7 +60,7 @@ PHP_ARG_WITH(pcre-regex,, pcrelib/pcre_tables.c pcrelib/pcre_valid_utf8.c \ pcrelib/pcre_version.c pcrelib/pcre_xclass.c \ pcrelib/pcre_jit_compile.c" - PHP_PCRE_CFLAGS="-DHAVE_CONFIG_H -I@ext_srcdir@/pcrelib" + PHP_PCRE_CFLAGS="-DHAVE_CONFIG_H -I@ext_srcdir@/pcrelib -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" PHP_NEW_EXTENSION(pcre, $pcrelib_sources php_pcre.c, no,,$PHP_PCRE_CFLAGS) PHP_ADD_BUILD_DIR($ext_builddir/pcrelib) PHP_INSTALL_HEADERS([ext/pcre], [php_pcre.h pcrelib/]) diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h index a8523cff9c..5ed39deaea 100644 --- a/ext/pcre/php_pcre.h +++ b/ext/pcre/php_pcre.h @@ -79,7 +79,7 @@ ZEND_BEGIN_MODULE_GLOBALS(pcre) ZEND_END_MODULE_GLOBALS(pcre) #ifdef ZTS -# define PCRE_G(v) TSRMG(pcre_globals_id, zend_pcre_globals *, v) +# define PCRE_G(v) ZEND_TSRMG(pcre_globals_id, zend_pcre_globals *, v) #else # define PCRE_G(v) (pcre_globals.v) #endif diff --git a/ext/pdo_mysql/config.m4 b/ext/pdo_mysql/config.m4 index f237f413be..95ae6ca7ed 100755 --- a/ext/pdo_mysql/config.m4 +++ b/ext/pdo_mysql/config.m4 @@ -144,7 +144,7 @@ if test "$PHP_PDO_MYSQL" != "no"; then fi dnl fix after renaming to pdo_mysql - PHP_NEW_EXTENSION(pdo_mysql, pdo_mysql.c mysql_driver.c mysql_statement.c, $ext_shared,,-I$pdo_cv_inc_path -I) + PHP_NEW_EXTENSION(pdo_mysql, pdo_mysql.c mysql_driver.c mysql_statement.c, $ext_shared,,-I$pdo_cv_inc_path -I -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) ifdef([PHP_ADD_EXTENSION_DEP], [ PHP_ADD_EXTENSION_DEP(pdo_mysql, pdo) diff --git a/ext/pdo_mysql/config.w32 b/ext/pdo_mysql/config.w32 index da085dc569..f150916b2a 100644 --- a/ext/pdo_mysql/config.w32 +++ b/ext/pdo_mysql/config.w32 @@ -12,7 +12,7 @@ if (PHP_PDO_MYSQL != "no") { } else { if (CHECK_LIB("libmysql.lib", "pdo_mysql", PHP_PDO_MYSQL) && CHECK_HEADER_ADD_INCLUDE("mysql.h", "CFLAGS_PDO_MYSQL", PHP_PHP_BUILD + "\\include\\mysql;" + PHP_PDO_MYSQL)) { - EXTENSION("pdo_mysql", "pdo_mysql.c mysql_driver.c mysql_statement.c"); + EXTENSION("pdo_mysql", "pdo_mysql.c mysql_driver.c mysql_statement.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); } else { WARNING("pdo_mysql not enabled; libraries and headers not found"); } diff --git a/ext/pdo_mysql/pdo_mysql.c b/ext/pdo_mysql/pdo_mysql.c index 87ff61f6de..0e997b1dc7 100644 --- a/ext/pdo_mysql/pdo_mysql.c +++ b/ext/pdo_mysql/pdo_mysql.c @@ -32,6 +32,9 @@ #include "php_pdo_mysql_int.h" #ifdef COMPILE_DL_PDO_MYSQL +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(pdo_mysql) #endif @@ -206,6 +209,9 @@ static PHP_RSHUTDOWN_FUNCTION(pdo_mysql) */ static PHP_GINIT_FUNCTION(pdo_mysql) { +#if defined(COMPILE_DL_PDO_MYSQL) && defined(ZTS) +ZEND_TSRMLS_CACHE_UPDATE; +#endif #ifndef PHP_WIN32 pdo_mysql_globals->default_socket = NULL; #endif diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h index c9e091f414..9493fda6f8 100644 --- a/ext/pdo_mysql/php_pdo_mysql_int.h +++ b/ext/pdo_mysql/php_pdo_mysql_int.h @@ -83,7 +83,10 @@ ZEND_END_MODULE_GLOBALS(pdo_mysql) ZEND_EXTERN_MODULE_GLOBALS(pdo_mysql) #ifdef ZTS -#define PDO_MYSQL_G(v) TSRMG(pdo_mysql_globals_id, zend_pdo_mysql_globals *, v) +#define PDO_MYSQL_G(v) ZEND_TSRMG(pdo_mysql_globals_id, zend_pdo_mysql_globals *, v) +# ifdef COMPILE_DL_PDO_MYSQL +ZEND_TSRMLS_CACHE_EXTERN; +# endif #else #define PDO_MYSQL_G(v) (pdo_mysql_globals.v) #endif diff --git a/ext/pgsql/config.m4 b/ext/pgsql/config.m4 index 186469861f..0ec34c4c25 100644 --- a/ext/pgsql/config.m4 +++ b/ext/pgsql/config.m4 @@ -105,7 +105,7 @@ if test "$PHP_PGSQL" != "no"; then PHP_ADD_INCLUDE($PGSQL_INCLUDE) - PHP_NEW_EXTENSION(pgsql, pgsql.c, $ext_shared) + PHP_NEW_EXTENSION(pgsql, pgsql.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) fi diff --git a/ext/pgsql/config.w32 b/ext/pgsql/config.w32 index d38048d90b..5775dfa023 100644 --- a/ext/pgsql/config.w32 +++ b/ext/pgsql/config.w32 @@ -6,7 +6,7 @@ ARG_WITH("pgsql", "PostgreSQL support", "no"); if (PHP_PGSQL != "no") { if (CHECK_LIB("libpq.lib", "pgsql", PHP_PGSQL) && CHECK_HEADER_ADD_INCLUDE("libpq-fe.h", "CFLAGS_PGSQL", PHP_PGSQL + "\\include;" + PHP_PHP_BUILD + "\\include\\pgsql;" + PHP_PHP_BUILD + "\\include\\libpq;" + PHP_PGSQL)) { - EXTENSION("pgsql", "pgsql.c"); + EXTENSION("pgsql", "pgsql.c", PHP_PGSQL_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('HAVE_PGSQL', 1, 'Have PostgreSQL library'); ADD_FLAG("CFLAGS_PGSQL", "/D HAVE_PG_CONFIG_H /D PGSQL_EXPORTS /D HAVE_PQSETNONBLOCKING /D HAVE_PQCMDTUPLES /D HAVE_PQCLIENTENCODING /D HAVE_PQESCAPE /D HAVE_PQPARAMETERSTATUS /D HAVE_PGTRANSACTIONSTATUS /D HAVE_PQEXECPARAMS /D HAVE_PQPREPARE /D HAVE_PQEXECPREPARED /D HAVE_PQRESULTERRORFIELD /D HAVE_PQSENDQUERYPARAMS /D HAVE_PQSENDPREPARE /D HAVE_PQSENDQUERYPREPARED /D HAVE_PQPUTCOPYDATA /D HAVE_PQPUTCOPYEND /D HAVE_PQGETCOPYDATA /D HAVE_PQSETERRORVERBOSITY /D HAVE_PQUNESCAPEBYTEA /D HAVE_PQFTABLE /D HAVE_PQESCAPE_CONN /D HAVE_PQESCAPE_BYTEA_CONN /D HAVE_PQFREEMEM /D HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT /D HAVE_PQPROTOCOLVERSION /D HAVE_PG_LO_CREATE /D HAVE_PG_LO_IMPORT_WITH_OID /D HAVE_PG_LO_TRUNCATE /D HAVE_PG_LO64 /D HAVE_PQESCAPELITERAL /D HAVE_PQOIDVALUE"); } else { diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 119a47f24c..7916afc3fc 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -772,6 +772,9 @@ zend_module_entry pgsql_module_entry = { /* }}} */ #ifdef COMPILE_DL_PGSQL +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(pgsql) #endif @@ -1091,6 +1094,9 @@ PHP_INI_END() */ static PHP_GINIT_FUNCTION(pgsql) { +#if defined(COMPILE_DL_PGSQL) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif memset(pgsql_globals, 0, sizeof(zend_pgsql_globals)); /* Initilize notice message hash at MINIT only */ zend_hash_init_ex(&pgsql_globals->notices, 0, NULL, PHP_PGSQL_NOTICE_PTR_DTOR, 1, 0); diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index 661c02f77f..18f1bbe77f 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -322,7 +322,10 @@ ZEND_END_MODULE_GLOBALS(pgsql) ZEND_EXTERN_MODULE_GLOBALS(pgsql) #ifdef ZTS -# define PGG(v) TSRMG(pgsql_globals_id, zend_pgsql_globals *, v) +# define PGG(v) ZEND_TSRMG(pgsql_globals_id, zend_pgsql_globals *, v) +# ifdef COMPILE_DL_PGSQL +ZEND_TSRMLS_CACHE_EXTERN; +# endif #else # define PGG(v) (pgsql_globals.v) #endif diff --git a/ext/phar/config.m4 b/ext/phar/config.m4 index 614d672eab..8b91caaedc 100644 --- a/ext/phar/config.m4 +++ b/ext/phar/config.m4 @@ -5,7 +5,7 @@ PHP_ARG_ENABLE(phar, for phar archive support, [ --disable-phar Disable phar support], yes) if test "$PHP_PHAR" != "no"; then - PHP_NEW_EXTENSION(phar, util.c tar.c zip.c stream.c func_interceptors.c dirstream.c phar.c phar_object.c phar_path_check.c, $ext_shared) + PHP_NEW_EXTENSION(phar, util.c tar.c zip.c stream.c func_interceptors.c dirstream.c phar.c phar_object.c phar_path_check.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) AC_MSG_CHECKING([for phar openssl support]) if test "$PHP_HASH_SHARED" != "yes"; then if test "$PHP_HASH" != "no"; then diff --git a/ext/phar/config.w32 b/ext/phar/config.w32 index 93504f61fb..6dba20affb 100644 --- a/ext/phar/config.w32 +++ b/ext/phar/config.w32 @@ -9,7 +9,7 @@ if (PHP_PHAR_NATIVE_SSL != "no") { } if (PHP_PHAR != "no") { - EXTENSION("phar", "dirstream.c func_interceptors.c phar.c phar_object.c phar_path_check.c stream.c tar.c util.c zip.c"); + EXTENSION("phar", "dirstream.c func_interceptors.c phar.c phar_object.c phar_path_check.c stream.c tar.c util.c zip.c", PHP_PHAR_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); if (PHP_PHAR_SHARED || (PHP_PHAR_NATIVE_SSL_SHARED && PHP_SNAPSHOT_BUILD == "no")) { ADD_FLAG("CFLAGS_PHAR", "/D COMPILE_DL_PHAR "); } diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 0903f6c952..ec64f09c09 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -3228,6 +3228,9 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv /* }}} */ #ifdef COMPILE_DL_PHAR +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(phar) #endif @@ -3336,6 +3339,9 @@ static void mime_type_dtor(zval *zv) PHP_GINIT_FUNCTION(phar) /* {{{ */ { +#if defined(COMPILE_DL_PHAR) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif phar_mime_type mime; memset(phar_globals, 0, sizeof(zend_phar_globals)); diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index f49143bc8c..7fe647b97d 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -196,8 +196,11 @@ ZEND_EXTERN_MODULE_GLOBALS(phar) #ifdef ZTS # include "TSRM.h" -# define PHAR_G(v) TSRMG(phar_globals_id, zend_phar_globals *, v) -# define PHAR_GLOBALS ((zend_phar_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(phar_globals_id)]) +# ifdef COMPILE_DL_PHAR +ZEND_TSRMLS_CACHE_EXTERN; +# endif +# define PHAR_G(v) ZEND_TSRMG(phar_globals_id, zend_phar_globals *, v) +# define PHAR_GLOBALS ((zend_phar_globals *) (*((void ***) ZEND_TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(phar_globals_id)]) #else # define PHAR_G(v) (phar_globals.v) # define PHAR_GLOBALS (&phar_globals) diff --git a/ext/reflection/config.m4 b/ext/reflection/config.m4 index 702663677b..08f8e1ef5d 100755 --- a/ext/reflection/config.m4 +++ b/ext/reflection/config.m4 @@ -2,4 +2,4 @@ dnl $Id$ dnl config.m4 for extension reflection AC_DEFINE(HAVE_REFLECTION, 1, [Whether Reflection is enabled]) -PHP_NEW_EXTENSION(reflection, php_reflection.c, no) +PHP_NEW_EXTENSION(reflection, php_reflection.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) diff --git a/ext/reflection/config.w32 b/ext/reflection/config.w32 index 724bf7bde4..2eb33c66ee 100755 --- a/ext/reflection/config.w32 +++ b/ext/reflection/config.w32 @@ -1,6 +1,6 @@ // $Id$ // vim:ft=javascript -EXTENSION("reflection", "php_reflection.c", false /* never shared */); +EXTENSION("reflection", "php_reflection.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('HAVE_REFLECTION', 1, 'Reflection support enabled'); -PHP_REFLECTION="yes";
\ No newline at end of file +PHP_REFLECTION="yes"; diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 026680cd6d..3ff63b8d69 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -70,7 +70,7 @@ ZEND_END_MODULE_GLOBALS(reflection) #ifdef ZTS # define REFLECTION_G(v) \ - TSRMG(reflection_globals_id, zend_reflection_globals*, v) + ZEND_TSRMG(reflection_globals_id, zend_reflection_globals*, v) extern int reflection_globals_id; #else # define REFLECTION_G(v) (reflection_globals.v) diff --git a/ext/session/config.m4 b/ext/session/config.m4 index 1c3ba78368..949306c026 100644 --- a/ext/session/config.m4 +++ b/ext/session/config.m4 @@ -11,7 +11,7 @@ PHP_ARG_WITH(mm,for mm support, if test "$PHP_SESSION" != "no"; then PHP_PWRITE_TEST PHP_PREAD_TEST - PHP_NEW_EXTENSION(session, mod_user_class.c session.c mod_files.c mod_mm.c mod_user.c, $ext_shared) + PHP_NEW_EXTENSION(session, mod_user_class.c session.c mod_files.c mod_mm.c mod_user.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_ADD_EXTENSION_DEP(session, hash, true) PHP_ADD_EXTENSION_DEP(session, spl) PHP_SUBST(SESSION_SHARED_LIBADD) diff --git a/ext/session/config.w32 b/ext/session/config.w32 index c8b217aad9..942f595da1 100644 --- a/ext/session/config.w32 +++ b/ext/session/config.w32 @@ -4,7 +4,7 @@ ARG_ENABLE("session", "session support", "yes"); if (PHP_SESSION == "yes") { - EXTENSION("session", "mod_user_class.c session.c mod_files.c mod_mm.c mod_user.c", false /* never shared */); + EXTENSION("session", "mod_user_class.c session.c mod_files.c mod_mm.c mod_user.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE("HAVE_PHP_SESSION", 1, "Session support"); PHP_INSTALL_HEADERS("ext/session/", "mod_mm.h php_session.h mod_files.h mod_user.h"); } diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 9fb6477056..1bd6d561b7 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -189,7 +189,10 @@ extern zend_module_entry session_module_entry; #define phpext_session_ptr &session_module_entry #ifdef ZTS -#define PS(v) TSRMG(ps_globals_id, php_ps_globals *, v) +#define PS(v) ZEND_TSRMG(ps_globals_id, php_ps_globals *, v) +#ifdef COMPILE_DL_SESSION +ZEND_TSRMLS_CACHE_EXTERN; +#endif #else #define PS(v) (ps_globals.v) #endif diff --git a/ext/session/session.c b/ext/session/session.c index 8d112c3a18..12564fa5b9 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -2377,6 +2377,10 @@ static PHP_GINIT_FUNCTION(ps) /* {{{ */ { int i; +#if defined(COMPILE_DL_SESSION) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif + ps_globals->save_path = NULL; ps_globals->session_name = NULL; ps_globals->id = NULL; @@ -2803,6 +2807,9 @@ zend_module_entry session_module_entry = { }; #ifdef COMPILE_DL_SESSION +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(session) #endif diff --git a/ext/soap/config.m4 b/ext/soap/config.m4 index 7fa8c6f0ec..5fcb8bd447 100644 --- a/ext/soap/config.m4 +++ b/ext/soap/config.m4 @@ -17,7 +17,7 @@ if test "$PHP_SOAP" != "no"; then PHP_SETUP_LIBXML(SOAP_SHARED_LIBADD, [ AC_DEFINE(HAVE_SOAP,1,[ ]) - PHP_NEW_EXTENSION(soap, soap.c php_encoding.c php_http.c php_packet_soap.c php_schema.c php_sdl.c php_xml.c, $ext_shared) + PHP_NEW_EXTENSION(soap, soap.c php_encoding.c php_http.c php_packet_soap.c php_schema.c php_sdl.c php_xml.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_SUBST(SOAP_SHARED_LIBADD) ], [ AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) diff --git a/ext/soap/config.w32 b/ext/soap/config.w32 index 7aa73b5838..bb26a90471 100644 --- a/ext/soap/config.w32 +++ b/ext/soap/config.w32 @@ -5,7 +5,7 @@ ARG_ENABLE("soap", "SOAP support", "no"); if (PHP_SOAP != "no") { if (PHP_LIBXML == "yes" && ADD_EXTENSION_DEP('soap', 'libxml')) { - EXTENSION('soap', 'soap.c php_encoding.c php_http.c php_packet_soap.c php_schema.c php_sdl.c php_xml.c'); + EXTENSION('soap', 'soap.c php_encoding.c php_http.c php_packet_soap.c php_schema.c php_sdl.c php_xml.c', null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('HAVE_PHP_SOAP', 1, "SOAP support"); if (!PHP_SOAP_SHARED) { diff --git a/ext/soap/php_soap.h b/ext/soap/php_soap.h index f32555cd93..e636ef39e7 100644 --- a/ext/soap/php_soap.h +++ b/ext/soap/php_soap.h @@ -193,7 +193,10 @@ extern zend_module_entry soap_module_entry; ZEND_EXTERN_MODULE_GLOBALS(soap) #ifdef ZTS -# define SOAP_GLOBAL(v) TSRMG(soap_globals_id, zend_soap_globals *, v) +# define SOAP_GLOBAL(v) ZEND_TSRMG(soap_globals_id, zend_soap_globals *, v) +# ifdef COMPILE_DL_SOAP +ZEND_TSRMLS_CACHE_EXTERN; +# endif #else # define SOAP_GLOBAL(v) (soap_globals.v) #endif diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 0e7d004564..cf409cedf2 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -466,6 +466,9 @@ zend_module_entry soap_module_entry = { }; #ifdef COMPILE_DL_SOAP +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(soap) #endif @@ -602,6 +605,9 @@ PHP_MSHUTDOWN_FUNCTION(soap) PHP_RINIT_FUNCTION(soap) { +#if defined(COMPILE_DL_SOAP) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif SOAP_GLOBAL(typemap) = NULL; SOAP_GLOBAL(use_soap_error_handler) = 0; SOAP_GLOBAL(error_code) = NULL; diff --git a/ext/sockets/config.m4 b/ext/sockets/config.m4 index a5a63dfb61..cea27000cf 100644 --- a/ext/sockets/config.m4 +++ b/ext/sockets/config.m4 @@ -56,6 +56,6 @@ if test "$PHP_SOCKETS" != "no"; then AC_DEFINE(HAVE_AI_V4MAPPED,1,[Whether you have AI_V4MAPPED]) fi - PHP_NEW_EXTENSION([sockets], [sockets.c multicast.c conversions.c sockaddr_conv.c sendrecvmsg.c], [$ext_shared]) + PHP_NEW_EXTENSION([sockets], [sockets.c multicast.c conversions.c sockaddr_conv.c sendrecvmsg.c], [$ext_shared],, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_INSTALL_HEADERS([ext/sockets/], [php_sockets.h]) fi diff --git a/ext/sockets/config.w32 b/ext/sockets/config.w32 index aeaa8ed425..d3455b05dd 100644 --- a/ext/sockets/config.w32 +++ b/ext/sockets/config.w32 @@ -7,7 +7,7 @@ if (PHP_SOCKETS != "no") { if (CHECK_LIB("ws2_32.lib", "sockets", PHP_SOCKETS) && CHECK_LIB("Iphlpapi.lib", "sockets", PHP_SOCKETS) && CHECK_HEADER_ADD_INCLUDE("winsock.h", "CFLAGS_SOCKETS")) { - EXTENSION('sockets', 'sockets.c multicast.c conversions.c sockaddr_conv.c sendrecvmsg.c'); + EXTENSION('sockets', 'sockets.c multicast.c conversions.c sockaddr_conv.c sendrecvmsg.c', PHP_SOCKETS_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('HAVE_SOCKETS', 1); PHP_INSTALL_HEADERS("ext/sockets", "php_sockets.h"); } else { diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index 209b4d1659..98c36cd1ad 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -91,7 +91,7 @@ ZEND_BEGIN_MODULE_GLOBALS(sockets) ZEND_END_MODULE_GLOBALS(sockets) #ifdef ZTS -#define SOCKETS_G(v) TSRMG(sockets_globals_id, zend_sockets_globals *, v) +#define SOCKETS_G(v) ZEND_TSRMG(sockets_globals_id, zend_sockets_globals *, v) #else #define SOCKETS_G(v) (sockets_globals.v) #endif diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 584d98576f..afd67b3bd4 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -370,6 +370,9 @@ zend_module_entry sockets_module_entry = { #ifdef COMPILE_DL_SOCKETS +#ifdef ZTS + ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(sockets) #endif @@ -600,6 +603,9 @@ char *sockets_strerror(int error TSRMLS_DC) /* {{{ */ /* {{{ PHP_GINIT_FUNCTION */ static PHP_GINIT_FUNCTION(sockets) { +#if defined(COMPILE_DL_SOCKETS) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif sockets_globals->last_error = 0; sockets_globals->strerror_buf = NULL; } @@ -609,6 +615,9 @@ static PHP_GINIT_FUNCTION(sockets) */ static PHP_MINIT_FUNCTION(sockets) { +#if defined(COMPILE_DL_SOCKETS) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif le_socket = zend_register_list_destructors_ex(php_destroy_socket, NULL, le_socket_name, module_number); REGISTER_LONG_CONSTANT("AF_UNIX", AF_UNIX, CONST_CS | CONST_PERSISTENT); diff --git a/ext/spl/config.m4 b/ext/spl/config.m4 index a0f0d1a06d..869e542ef4 100755 --- a/ext/spl/config.m4 +++ b/ext/spl/config.m4 @@ -22,6 +22,6 @@ int main(int argc, char **argv) { CPPFLAGS=$old_CPPFLAGS AC_DEFINE_UNQUOTED(HAVE_PACKED_OBJECT_VALUE, $ac_result, [Whether struct _zend_object_value is packed]) AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support]) - PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no) + PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h]) PHP_ADD_EXTENSION_DEP(spl, pcre, true) diff --git a/ext/spl/config.w32 b/ext/spl/config.w32 index 77cbd20346..56c466c220 100644 --- a/ext/spl/config.w32 +++ b/ext/spl/config.w32 @@ -1,7 +1,7 @@ // $Id$ // vim:ft=javascript -EXTENSION("spl", "php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */); +EXTENSION("spl", "php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE('HAVE_SPL', 1); PHP_SPL="yes"; PHP_INSTALL_HEADERS("ext/spl", "php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h"); diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h index 534a03885e..8db6f09e6d 100644 --- a/ext/spl/php_spl.h +++ b/ext/spl/php_spl.h @@ -67,7 +67,7 @@ ZEND_BEGIN_MODULE_GLOBALS(spl) ZEND_END_MODULE_GLOBALS(spl) #ifdef ZTS -# define SPL_G(v) TSRMG(spl_globals_id, zend_spl_globals *, v) +# define SPL_G(v) ZEND_TSRMG(spl_globals_id, zend_spl_globals *, v) extern int spl_globals_id; #else # define SPL_G(v) (spl_globals.v) diff --git a/ext/sqlite3/config.w32 b/ext/sqlite3/config.w32 index 8ddb6b9ac8..60dd2fae52 100644 --- a/ext/sqlite3/config.w32 +++ b/ext/sqlite3/config.w32 @@ -5,7 +5,7 @@ ARG_WITH("sqlite3", "SQLite 3 support", "no"); if (PHP_SQLITE3 != "no") { ADD_FLAG("CFLAGS_SQLITE3", "/D SQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 /D SQLITE_API=__declspec(dllexport) "); - EXTENSION("sqlite3", "sqlite3.c", null, "/I" + configure_module_dirname + "/libsqlite /I" + configure_module_dirname); + EXTENSION("sqlite3", "sqlite3.c", null, "/I" + configure_module_dirname + "/libsqlite /I" + configure_module_dirname + " /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_SOURCES(configure_module_dirname + "/libsqlite", "sqlite3.c", "sqlite3"); diff --git a/ext/sqlite3/config0.m4 b/ext/sqlite3/config0.m4 index 6959a6f916..bbb1133fe4 100644 --- a/ext/sqlite3/config0.m4 +++ b/ext/sqlite3/config0.m4 @@ -8,7 +8,7 @@ PHP_ARG_WITH(sqlite3, whether to enable the SQLite3 extension, if test $PHP_SQLITE3 != "no"; then sqlite3_extra_sources="" - PHP_SQLITE3_CFLAGS="" + PHP_SQLITE3_CFLAGS=" -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 " dnl when running phpize enable_maintainer_zts is not available if test -z "$enable_maintainer_zts"; then diff --git a/ext/sqlite3/php_sqlite3.h b/ext/sqlite3/php_sqlite3.h index 5c7dfcfa5a..8f1c500211 100644 --- a/ext/sqlite3/php_sqlite3.h +++ b/ext/sqlite3/php_sqlite3.h @@ -32,6 +32,9 @@ ZEND_END_MODULE_GLOBALS(sqlite3) #ifdef ZTS # define SQLITE3G(v) TSRMG(sqlite3_globals_id, zend_sqlite3_globals *, v) +# ifdef COMPILE_DL_SQLITE3 +ZEND_TSRMLS_CACHE_EXTERN; +# endif #else # define SQLITE3G(v) (sqlite3_globals.v) #endif diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index af3dec0681..a98b303547 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -2271,6 +2271,9 @@ PHP_MINFO_FUNCTION(sqlite3) */ static PHP_GINIT_FUNCTION(sqlite3) { +#if defined(COMPILE_DL_SQLITE3) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif memset(sqlite3_globals, 0, sizeof(*sqlite3_globals)); } /* }}} */ @@ -2296,6 +2299,9 @@ zend_module_entry sqlite3_module_entry = { /* }}} */ #ifdef COMPILE_DL_SQLITE3 +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(sqlite3) #endif diff --git a/ext/standard/assert.c b/ext/standard/assert.c index fa5ccfc12f..9fa5a1178c 100644 --- a/ext/standard/assert.c +++ b/ext/standard/assert.c @@ -36,7 +36,7 @@ ZEND_END_MODULE_GLOBALS(assert) ZEND_DECLARE_MODULE_GLOBALS(assert) #ifdef ZTS -#define ASSERTG(v) TSRMG(assert_globals_id, zend_assert_globals *, v) +#define ASSERTG(v) ZEND_TSRMG(assert_globals_id, zend_assert_globals *, v) #else #define ASSERTG(v) (assert_globals.v) #endif diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index 5adc9a9a11..c47ee0fb96 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -235,7 +235,7 @@ typedef struct _php_basic_globals { } php_basic_globals; #ifdef ZTS -#define BG(v) TSRMG(basic_globals_id, php_basic_globals *, v) +#define BG(v) ZEND_TSRMG(basic_globals_id, php_basic_globals *, v) PHPAPI extern int basic_globals_id; #else #define BG(v) (basic_globals.v) diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index a76fb136a3..2ea837ff60 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -46,7 +46,7 @@ ZEND_END_MODULE_GLOBALS(browscap) ZEND_DECLARE_MODULE_GLOBALS(browscap) #ifdef ZTS -#define BROWSCAP_G(v) TSRMG(browscap_globals_id, zend_browscap_globals *, v) +#define BROWSCAP_G(v) ZEND_TSRMG(browscap_globals_id, zend_browscap_globals *, v) #else #define BROWSCAP_G(v) (browscap_globals.v) #endif diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index 7a5f0effa0..e2ce61f561 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -605,7 +605,8 @@ PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32. incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \ http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \ var_unserializer.c ftok.c sha1.c user_filters.c uuencode.c \ - filters.c proc_open.c streamsfuncs.c http.c password.c) + filters.c proc_open.c streamsfuncs.c http.c password.c,,, + -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_ADD_MAKEFILE_FRAGMENT PHP_INSTALL_HEADERS([ext/standard/]) diff --git a/ext/standard/config.w32 b/ext/standard/config.w32 index 5f24641b4d..e8b50efc7e 100644 --- a/ext/standard/config.w32 +++ b/ext/standard/config.w32 @@ -20,7 +20,8 @@ EXTENSION("standard", "array.c base64.c basic_functions.c browscap.c \ url_scanner_ex.c ftp_fopen_wrapper.c http_fopen_wrapper.c \ php_fopen_wrapper.c credits.c css.c var_unserializer.c ftok.c sha1.c \ user_filters.c uuencode.c filters.c proc_open.c password.c \ - streamsfuncs.c http.c flock_compat.c", false /* never shared */); + streamsfuncs.c http.c flock_compat.c", false /* never shared */, + '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); PHP_INSTALL_HEADERS("", "ext/standard"); if (PHP_MBREGEX != "no") { CHECK_HEADER_ADD_INCLUDE("oniguruma.h", "CFLAGS_STANDARD", PHP_MBREGEX + ";ext\\mbstring\\oniguruma") diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 6a09ce3af5..b13f47be69 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -56,7 +56,7 @@ typedef struct { } php_dir_globals; #ifdef ZTS -#define DIRG(v) TSRMG(dir_globals_id, php_dir_globals *, v) +#define DIRG(v) ZEND_TSRMG(dir_globals_id, php_dir_globals *, v) int dir_globals_id; #else #define DIRG(v) (dir_globals.v) diff --git a/ext/standard/file.h b/ext/standard/file.h index ec60b86e99..78cab4f62f 100644 --- a/ext/standard/file.h +++ b/ext/standard/file.h @@ -132,7 +132,7 @@ typedef struct { } php_file_globals; #ifdef ZTS -#define FG(v) TSRMG(file_globals_id, php_file_globals *, v) +#define FG(v) ZEND_TSRMG(file_globals_id, php_file_globals *, v) extern PHPAPI int file_globals_id; #else #define FG(v) (file_globals.v) diff --git a/ext/standard/php_array.h b/ext/standard/php_array.h index 31955042eb..dee00e6218 100644 --- a/ext/standard/php_array.h +++ b/ext/standard/php_array.h @@ -131,7 +131,7 @@ ZEND_BEGIN_MODULE_GLOBALS(array) ZEND_END_MODULE_GLOBALS(array) #ifdef ZTS -#define ARRAYG(v) TSRMG(array_globals_id, zend_array_globals *, v) +#define ARRAYG(v) ZEND_TSRMG(array_globals_id, zend_array_globals *, v) #else #define ARRAYG(v) (array_globals.v) #endif diff --git a/ext/standard/php_lcg.h b/ext/standard/php_lcg.h index dcc82e9511..81d251c513 100644 --- a/ext/standard/php_lcg.h +++ b/ext/standard/php_lcg.h @@ -35,7 +35,7 @@ PHP_FUNCTION(lcg_value); PHP_MINIT_FUNCTION(lcg); #ifdef ZTS -#define LCG(v) TSRMG(lcg_globals_id, php_lcg_globals *, v) +#define LCG(v) ZEND_TSRMG(lcg_globals_id, php_lcg_globals *, v) #else #define LCG(v) (lcg_globals.v) #endif diff --git a/ext/tidy/config.m4 b/ext/tidy/config.m4 index 102f6a827e..ff27bd1aaa 100644 --- a/ext/tidy/config.m4 +++ b/ext/tidy/config.m4 @@ -38,7 +38,7 @@ if test "$PHP_TIDY" != "no"; then ],[],[]) - PHP_NEW_EXTENSION(tidy, tidy.c, $ext_shared) + PHP_NEW_EXTENSION(tidy, tidy.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_SUBST(TIDY_SHARED_LIBADD) AC_DEFINE(HAVE_TIDY,1,[ ]) fi diff --git a/ext/tidy/config.w32 b/ext/tidy/config.w32 index 41f217588d..a87a833f92 100644 --- a/ext/tidy/config.w32 +++ b/ext/tidy/config.w32 @@ -12,6 +12,7 @@ if (PHP_TIDY != "no") { )) { EXTENSION("tidy", "tidy.c"); AC_DEFINE('HAVE_TIDY', 1, 'Have TIDY library'); + ADD_FLAG('CFLAGS_TIDY', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); if (!PHP_TIDY_SHARED) { ADD_DEF_FILE("ext\\tidy\\php_tidy.def"); } diff --git a/ext/tidy/php_tidy.h b/ext/tidy/php_tidy.h index cd78f37a17..77de84de9c 100644 --- a/ext/tidy/php_tidy.h +++ b/ext/tidy/php_tidy.h @@ -40,7 +40,10 @@ ZEND_BEGIN_MODULE_GLOBALS(tidy) ZEND_END_MODULE_GLOBALS(tidy) #ifdef ZTS -#define TG(v) TSRMG(tidy_globals_id, zend_tidy_globals *, v) +#define TG(v) ZEND_TSRMG(tidy_globals_id, zend_tidy_globals *, v) +#ifdef COMPILE_DL_TIDY +ZEND_TSRMLS_CACHE_EXTERN; +#endif #else #define TG(v) (tidy_globals.v) #endif diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 23531e9ae3..b809fff6e0 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -467,6 +467,9 @@ zend_module_entry tidy_module_entry = { }; #ifdef COMPILE_DL_TIDY +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(tidy) #endif @@ -1055,6 +1058,10 @@ static PHP_MINIT_FUNCTION(tidy) static PHP_RINIT_FUNCTION(tidy) { +#if defined(COMPILE_DL_TIDY) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif + php_tidy_clean_output_start(ZEND_STRL("ob_tidyhandler") TSRMLS_CC); return SUCCESS; diff --git a/ext/xml/config.m4 b/ext/xml/config.m4 index ebfc0471e0..812032bc6a 100644 --- a/ext/xml/config.m4 +++ b/ext/xml/config.m4 @@ -52,7 +52,7 @@ if test "$PHP_XML" != "no"; then AC_DEFINE(HAVE_LIBEXPAT, 1, [ ]) fi - PHP_NEW_EXTENSION(xml, xml.c $xml_extra_sources, $ext_shared) + PHP_NEW_EXTENSION(xml, xml.c $xml_extra_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_SUBST(XML_SHARED_LIBADD) PHP_INSTALL_HEADERS([ext/xml/]) AC_DEFINE(HAVE_XML, 1, [ ]) diff --git a/ext/xml/config.w32 b/ext/xml/config.w32 index 4ee0bd1602..20b5c8dfe5 100644 --- a/ext/xml/config.w32 +++ b/ext/xml/config.w32 @@ -6,7 +6,7 @@ ARG_WITH("xml", "XML support", "yes"); if (PHP_XML == "yes") { if (PHP_LIBXML == "yes" && ADD_EXTENSION_DEP('xml', 'libxml')) { - EXTENSION("xml", "xml.c compat.c"); + EXTENSION("xml", "xml.c compat.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE("HAVE_XML", 1, "XML support"); if (!PHP_XML_SHARED) { ADD_FLAG("CFLAGS_XML", "/D LIBXML_STATIC "); diff --git a/ext/xml/php_xml.h b/ext/xml/php_xml.h index cdb08f812e..d7f0d6d046 100644 --- a/ext/xml/php_xml.h +++ b/ext/xml/php_xml.h @@ -142,7 +142,10 @@ PHPAPI zend_string *xml_utf8_encode(const char *, size_t, const XML_Char *); #define phpext_xml_ptr xml_module_ptr #ifdef ZTS -#define XML(v) TSRMG(xml_globals_id, zend_xml_globals *, v) +#define XML(v) ZEND_TSRMG(xml_globals_id, zend_xml_globals *, v) +#ifdef COMPILE_DL_XML +ZEND_TSRMLS_CACHE_EXTERN; +#endif #else #define XML(v) (xml_globals.v) #endif diff --git a/ext/xml/xml.c b/ext/xml/xml.c index f1a3442b6d..6959424376 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -62,6 +62,9 @@ ZEND_DECLARE_MODULE_GLOBALS(xml) /* {{{ dynamically loadable module stuff */ #ifdef COMPILE_DL_XML +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(xml) #endif /* COMPILE_DL_XML */ /* }}} */ @@ -290,6 +293,9 @@ static int le_xml_parser; /* {{{ startup, shutdown and info functions */ static PHP_GINIT_FUNCTION(xml) { +#if defined(COMPILE_DL_XML) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif xml_globals->default_encoding = (XML_Char*)"UTF-8"; } diff --git a/ext/zlib/config.w32 b/ext/zlib/config.w32 index 000b1ccabb..1a57aa6110 100644 --- a/ext/zlib/config.w32 +++ b/ext/zlib/config.w32 @@ -7,7 +7,7 @@ if (PHP_ZLIB == "yes") { if (CHECK_LIB("zlib_a.lib;zlib.lib", "zlib", PHP_ZLIB) && CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS", "..\\zlib;" + php_usual_include_suspects)) { - EXTENSION("zlib", "zlib.c zlib_fopen_wrapper.c zlib_filter.c", null, "/D ZLIB_EXPORTS"); + EXTENSION("zlib", "zlib.c zlib_fopen_wrapper.c zlib_filter.c", null, "/D ZLIB_EXPORTS /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE("HAVE_ZLIB", 1, "ZLIB support"); if (!PHP_ZLIB_SHARED) { diff --git a/ext/zlib/config0.m4 b/ext/zlib/config0.m4 index ebf67cc001..ab94c15fe0 100644 --- a/ext/zlib/config0.m4 +++ b/ext/zlib/config0.m4 @@ -9,7 +9,7 @@ PHP_ARG_WITH(zlib-dir,if the location of ZLIB install directory is defined, [ --with-zlib-dir=<DIR> Define the location of zlib install directory], no, no) if test "$PHP_ZLIB" != "no" || test "$PHP_ZLIB_DIR" != "no"; then - PHP_NEW_EXTENSION(zlib, zlib.c zlib_fopen_wrapper.c zlib_filter.c, $ext_shared) + PHP_NEW_EXTENSION(zlib, zlib.c zlib_fopen_wrapper.c zlib_filter.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_SUBST(ZLIB_SHARED_LIBADD) if test "$PHP_ZLIB" != "yes" -a "$PHP_ZLIB" != "no"; then diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index ba829b5888..e5c2f37016 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -68,7 +68,7 @@ extern zend_module_entry php_zlib_module_entry; #ifdef ZTS # include "TSRM.h" -# define ZLIBG(v) TSRMG(zlib_globals_id, zend_zlib_globals *, v) +# define ZLIBG(v) ZEND_TSRMG(zlib_globals_id, zend_zlib_globals *, v) #else # define ZLIBG(v) (zlib_globals.v) #endif diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index c3548eae53..ffde50ba0b 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -496,7 +496,6 @@ static PHP_FUNCTION(ob_gzhandler) ZLIBG(ob_gzhandler) = php_zlib_output_handler_context_init(TSRMLS_C); } - TSRMLS_SET_CTX(ctx.tsrm_ls); ctx.op = flags; ctx.in.data = in_str; ctx.in.used = in_len; @@ -736,6 +735,9 @@ PHP_ZLIB_DECODE_FUNC(gzuncompress, PHP_ZLIB_ENCODING_DEFLATE); /* }}} */ #ifdef COMPILE_DL_ZLIB +#ifdef ZTS +ZEND_TSRMLS_CACHE_DEFINE; +#endif ZEND_GET_MODULE(php_zlib) #endif @@ -1020,6 +1022,9 @@ static PHP_MINFO_FUNCTION(zlib) /* {{{ ZEND_MODULE_GLOBALS_CTOR */ static PHP_GINIT_FUNCTION(zlib) { +#if defined(COMPILE_DL_ZLIB) && defined(ZTS) + ZEND_TSRMLS_CACHE_UPDATE; +#endif zlib_globals->ob_gzhandler = NULL; zlib_globals->handler_registered = 0; } diff --git a/main/SAPI.c b/main/SAPI.c index b1be4443d2..b2768965a0 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -64,6 +64,9 @@ static void _type_dtor(zval *zv) static void sapi_globals_ctor(sapi_globals_struct *sapi_globals TSRMLS_DC) { +#ifdef ZTS + ZEND_TSRMLS_CACHE_UPDATE; +#endif memset(sapi_globals, 0, sizeof(*sapi_globals)); zend_hash_init_ex(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1, 0); php_setup_sapi_content_types(TSRMLS_C); diff --git a/main/SAPI.h b/main/SAPI.h index 79661371d9..c4eb86dea8 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -142,7 +142,7 @@ typedef struct _sapi_globals_struct { BEGIN_EXTERN_C() #ifdef ZTS -# define SG(v) TSRMG(sapi_globals_id, sapi_globals_struct *, v) +# define SG(v) ZEND_TSRMG(sapi_globals_id, sapi_globals_struct *, v) SAPI_API extern int sapi_globals_id; #else # define SG(v) (sapi_globals.v) diff --git a/main/output.c b/main/output.c index c8b41ba1eb..7811316358 100644 --- a/main/output.c +++ b/main/output.c @@ -81,6 +81,7 @@ static int php_output_handler_devnull_func(void **handler_context, php_output_co * Initialize the module globals on MINIT */ static inline void php_output_init_globals(zend_output_globals *G) { + ZEND_TSRMLS_CACHE_UPDATE; memset(G, 0, sizeof(*G)); } /* }}} */ @@ -160,7 +161,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 ***) ZEND_TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(output_globals_id)], 0, sizeof(zend_output_globals)); #else memset(&output_globals, 0, sizeof(zend_output_globals)); #endif @@ -784,7 +785,6 @@ static inline php_output_context *php_output_context_init(php_output_context *co } memset(context, 0, sizeof(php_output_context)); - TSRMLS_SET_CTX(context->tsrm_ls); context->op = op; return context; diff --git a/main/php_globals.h b/main/php_globals.h index a60efe69de..76933d8f07 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -26,7 +26,7 @@ typedef struct _php_core_globals php_core_globals; #ifdef ZTS -# define PG(v) TSRMG(core_globals_id, php_core_globals *, v) +# define PG(v) ZEND_TSRMG(core_globals_id, php_core_globals *, v) extern PHPAPI int core_globals_id; #else # define PG(v) (core_globals.v) diff --git a/main/php_output.h b/main/php_output.h index 535b09b46c..bf756de5ce 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -102,12 +102,10 @@ 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) +/* 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, size_t output_len, char **handled_output, size_t *handled_output_len, int mode TSRMLS_DC); @@ -155,7 +153,7 @@ PHPAPI ZEND_EXTERN_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 diff --git a/sapi/apache2handler/config.m4 b/sapi/apache2handler/config.m4 index 59e17393dd..2e64b215e5 100644 --- a/sapi/apache2handler/config.m4 +++ b/sapi/apache2handler/config.m4 @@ -56,7 +56,7 @@ if test "$PHP_APXS2" != "no"; then esac done - APACHE_CFLAGS="$APACHE_CPPFLAGS -I$APXS_INCLUDEDIR $APR_CFLAGS $APU_CFLAGS" + APACHE_CFLAGS="$APACHE_CPPFLAGS -I$APXS_INCLUDEDIR $APR_CFLAGS $APU_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" # Test that we're trying to configure with apache 2.x PHP_AP_EXTRACT_VERSION($APXS_HTTPD) diff --git a/sapi/apache2handler/config.w32 b/sapi/apache2handler/config.w32 index d15dcfaf03..8ea1305d4f 100644 --- a/sapi/apache2handler/config.w32 +++ b/sapi/apache2handler/config.w32 @@ -13,7 +13,7 @@ if (PHP_APACHE2HANDLER != "no") { ) { SAPI('apache2handler', 'mod_php7.c sapi_apache2.c apache_config.c php_functions.c', 'php' + PHP_VERSION + 'apache2.dll', - '/D PHP_APACHE2_EXPORTS /I win32'); + '/D PHP_APACHE2_EXPORTS /I win32 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); } else { WARNING("Could not find apache2 libraries/headers"); } @@ -31,7 +31,7 @@ if (PHP_APACHE2_2HANDLER != "no") { ) { SAPI('apache2_2handler', 'mod_php7.c sapi_apache2.c apache_config.c php_functions.c', 'php' + PHP_VERSION + 'apache2_2.dll', - '/D PHP_APACHE2_EXPORTS /I win32', + '/D PHP_APACHE2_EXPORTS /I win32 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1', 'sapi\\apache2_2handler'); } else { WARNING("Could not find apache2.2 libraries/headers"); @@ -49,7 +49,7 @@ if (PHP_APACHE2_4HANDLER != "no") { ) { SAPI('apache2_4handler', 'mod_php7.c sapi_apache2.c apache_config.c php_functions.c', 'php' + PHP_VERSION + 'apache2_4.dll', - '/D PHP_APACHE2_EXPORTS /I win32', + '/D PHP_APACHE2_EXPORTS /I win32 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1', 'sapi\\apache2handler'); } else { WARNING("Could not find apache 2.4 libraries/headers"); diff --git a/sapi/apache2handler/php_apache.h b/sapi/apache2handler/php_apache.h index f6f4f7a7c9..da20072b14 100644 --- a/sapi/apache2handler/php_apache.h +++ b/sapi/apache2handler/php_apache.h @@ -79,7 +79,8 @@ extern zend_module_entry apache2_module_entry; #ifdef ZTS extern int php_apache2_info_id; -#define AP2(v) TSRMG(php_apache2_info_id, php_apache2_info_struct *, v) +#define AP2(v) ZEND_TSRMG(php_apache2_info_id, php_apache2_info_struct *, v) +ZEND_TSRMLS_CACHE_EXTERN; #else extern php_apache2_info_struct php_apache2_info; #define AP2(v) (php_apache2_info.v) diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index fe200304fd..3b93c74f7a 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -71,6 +71,9 @@ /* A way to specify the location of the php.ini dir in an apache directive */ char *apache2_php_ini_path_override = NULL; +#if defined(PHP_WIN32) && defined(ZTS) +ZEND_TSRMLS_CACHE_DEFINE; +#endif static size_t php_apache_sapi_ub_write(const char *str, size_t str_length TSRMLS_DC) @@ -451,6 +454,8 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp } #ifdef ZTS tsrm_startup(1, 1, 0, NULL); + (void)ts_resource(0); + ZEND_TSRMLS_CACHE_UPDATE; #endif sapi_startup(&apache2_sapi_module); apache2_sapi_module.startup(&apache2_sapi_module); @@ -540,7 +545,11 @@ static int php_handler(request_rec *r) apr_bucket *bucket; apr_status_t rv; request_rec * volatile parent_req = NULL; - TSRMLS_FETCH(); +#ifdef ZTS + /* initial resource fetch */ + void ***tsrm_ls = ts_resource(0); + ZEND_TSRMLS_CACHE_UPDATE; +#endif #define PHPAP_INI_OFF php_apache_ini_dtor(r, parent_req TSRMLS_CC); diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 1bef17c257..94f35a6c83 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -198,7 +198,10 @@ static void user_config_cache_entry_dtor(zval *el) #ifdef ZTS static int php_cgi_globals_id; -#define CGIG(v) TSRMG(php_cgi_globals_id, php_cgi_globals_struct *, v) +#define CGIG(v) ZEND_TSRMG(php_cgi_globals_id, php_cgi_globals_struct *, v) +#if defined(PHP_WIN32) +ZEND_TSRMLS_CACHE_DEFINE; +#endif #else static php_cgi_globals_struct php_cgi_globals; #define CGIG(v) (php_cgi_globals.v) @@ -1482,6 +1485,9 @@ PHP_INI_END() */ static void php_cgi_globals_ctor(php_cgi_globals_struct *php_cgi_globals TSRMLS_DC) { +#ifdef ZTS + ZEND_TSRMLS_CACHE_UPDATE; +#endif php_cgi_globals->rfc2616_headers = 0; php_cgi_globals->nph = 0; php_cgi_globals->check_shebang_line = 1; @@ -1809,6 +1815,7 @@ int main(int argc, char *argv[]) #ifdef ZTS tsrm_startup(1, 1, 0, NULL); tsrm_ls = ts_resource(0); + ZEND_TSRMLS_CACHE_UPDATE; #endif sapi_startup(&cgi_sapi_module); diff --git a/sapi/cgi/config.w32 b/sapi/cgi/config.w32 index 55a2fba48f..daf4f05687 100644 --- a/sapi/cgi/config.w32 +++ b/sapi/cgi/config.w32 @@ -5,6 +5,6 @@ ARG_ENABLE('cgi', 'Build CGI version of PHP', 'yes'); if (PHP_CGI == "yes") { ADD_FLAG("LDFLAGS_CGI", "/stack:67108864"); - SAPI('cgi', 'cgi_main.c fastcgi.c', 'php-cgi.exe'); + SAPI('cgi', 'cgi_main.c fastcgi.c', 'php-cgi.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); ADD_FLAG('LIBS_CGI', 'ws2_32.lib kernel32.lib advapi32.lib'); } diff --git a/sapi/cgi/config9.m4 b/sapi/cgi/config9.m4 index 49e61c83c3..a005f8e0ad 100644 --- a/sapi/cgi/config9.m4 +++ b/sapi/cgi/config9.m4 @@ -50,7 +50,7 @@ if test "$PHP_CGI" != "no"; then esac dnl Select SAPI - PHP_SELECT_SAPI(cgi, program, cgi_main.c fastcgi.c,, '$(SAPI_CGI_PATH)') + PHP_SELECT_SAPI(cgi, program, cgi_main.c fastcgi.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, '$(SAPI_CGI_PATH)') case $host_alias in *aix*) diff --git a/sapi/cli/config.m4 b/sapi/cli/config.m4 index 090574a007..c5819cd8b4 100644 --- a/sapi/cli/config.m4 +++ b/sapi/cli/config.m4 @@ -31,7 +31,7 @@ if test "$PHP_CLI" != "no"; then SAPI_CLI_PATH=sapi/cli/php dnl Select SAPI - PHP_SELECT_SAPI(cli, program, php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c,, '$(SAPI_CLI_PATH)') + PHP_SELECT_SAPI(cli, program, php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, '$(SAPI_CLI_PATH)') case $host_alias in *aix*) diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32 index 438c9e6d62..664394c8a6 100644 --- a/sapi/cli/config.w32 +++ b/sapi/cli/config.w32 @@ -6,7 +6,7 @@ ARG_ENABLE('crt-debug', 'Enable CRT memory dumps for debugging sent to STDERR', ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no'); if (PHP_CLI == "yes") { - SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c php_cli_process_title.c ps_title.c', 'php.exe'); + SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c php_cli_process_title.c ps_title.c', 'php.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); ADD_FLAG("LIBS_CLI", "ws2_32.lib"); if (PHP_CRT_DEBUG == "yes") { ADD_FLAG("CFLAGS_CLI", "/D PHP_WIN32_DEBUG_HEAP"); @@ -15,7 +15,7 @@ if (PHP_CLI == "yes") { } if (PHP_CLI_WIN32 == "yes") { - SAPI('cli_win32', 'cli_win32.c php_cli_process_title.c ps_title.c', 'php-win.exe'); + SAPI('cli_win32', 'cli_win32.c php_cli_process_title.c ps_title.c', 'php-win.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:67108864"); } diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index ef45ef6ef9..723decf065 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -99,6 +99,10 @@ PHPAPI extern char *php_ini_opened_path; PHPAPI extern char *php_ini_scanned_path; PHPAPI extern char *php_ini_scanned_files; +#if defined(PHP_WIN32) && defined(ZTS) +ZEND_TSRMLS_CACHE_DEFINE; +#endif + #ifndef O_BINARY #define O_BINARY 0 #endif @@ -1236,6 +1240,7 @@ int main(int argc, char *argv[]) #ifdef ZTS tsrm_startup(1, 1, 0, NULL); tsrm_ls = ts_resource(0); + ZEND_TSRMLS_CACHE_UPDATE; #endif #ifdef PHP_WIN32 diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index a0a9052f8a..f024b09980 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -1209,11 +1209,8 @@ static void php_cli_server_logf(const char *format TSRMLS_DC, ...) /* {{{ */ { char *buf = NULL; va_list ap; -#ifdef ZTS - va_start(ap, tsrm_ls); -#else + va_start(ap, format); -#endif vspprintf(&buf, 0, format, ap); va_end(ap); @@ -1352,6 +1349,9 @@ out: static int php_cli_server_request_ctor(php_cli_server_request *req) /* {{{ */ { +#ifdef ZTS +ZEND_TSRMLS_CACHE_UPDATE; +#endif req->protocol_version = 0; req->request_uri = NULL; req->request_uri_len = 0; @@ -2384,9 +2384,6 @@ static int php_cli_server_send_event(php_cli_server *server, php_cli_server_clie /* }}} */ typedef struct php_cli_server_do_event_for_each_fd_callback_params { -#ifdef ZTS - void ***tsrm_ls; -#endif php_cli_server *server; int(*rhandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC); int(*whandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC); @@ -2395,9 +2392,6 @@ typedef struct php_cli_server_do_event_for_each_fd_callback_params { static int php_cli_server_do_event_for_each_fd_callback(void *_params, php_socket_t fd, int event) /* {{{ */ { php_cli_server_do_event_for_each_fd_callback_params *params = _params; -#ifdef ZTS - void ***tsrm_ls = params->tsrm_ls; -#endif php_cli_server *server = params->server; if (server->server_sock == fd) { php_cli_server_client *client = NULL; @@ -2449,9 +2443,6 @@ static int php_cli_server_do_event_for_each_fd_callback(void *_params, php_socke static void php_cli_server_do_event_for_each_fd(php_cli_server *server, int(*rhandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC), int(*whandler)(php_cli_server*, php_cli_server_client* TSRMLS_DC) TSRMLS_DC) /* {{{ */ { php_cli_server_do_event_for_each_fd_callback_params params = { -#ifdef ZTS - tsrm_ls, -#endif server, rhandler, whandler diff --git a/sapi/cli/php_cli_server.h b/sapi/cli/php_cli_server.h index 476ee2919c..9881b0c6a2 100644 --- a/sapi/cli/php_cli_server.h +++ b/sapi/cli/php_cli_server.h @@ -32,7 +32,8 @@ ZEND_BEGIN_MODULE_GLOBALS(cli_server) ZEND_END_MODULE_GLOBALS(cli_server) #ifdef ZTS -#define CLI_SERVER_G(v) TSRMG(cli_server_globals_id, zend_cli_server_globals *, v) +#define CLI_SERVER_G(v) ZEND_TSRMG(cli_server_globals_id, zend_cli_server_globals *, v) +ZEND_TSRMLS_CACHE_EXTERN; #else #define CLI_SERVER_G(v) (cli_server_globals.v) #endif diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 574d8e274b..6b06cfead0 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -132,6 +132,8 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \ zend_float.c zend_string.c zend_generators.c zend_virtual_cwd.c zend_ast.c \ zend_inheritance.c"); +ADD_FLAG("CFLAGS_BD_ZEND", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); + /* XXX inspect this for other toolsets */ if (VS_TOOLSET && VCVERS == 1200) { AC_DEFINE('ZEND_DVAL_TO_LVAL_CAST_OK', 1); @@ -141,6 +143,7 @@ ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \ php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \ strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c network.c \ php_open_temporary_file.c output.c internal_functions.c php_sprintf.c"); +ADD_FLAG("CFLAGS_BD_MAIN", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_SOURCES("win32", "inet.c fnmatch.c sockets.c"); // Newer versions have it @@ -153,10 +156,13 @@ if (VS_TOOLSET && VCVERS >= 1400 || !VS_TOOLSET) { ADD_SOURCES("main/streams", "streams.c cast.c memory.c filter.c plain_wrapper.c \ userspace.c transports.c xp_socket.c mmap.c glob_wrapper.c"); +ADD_FLAG("CFLAGS_BD_MAIN_STREAMS", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_SOURCES("win32", "glob.c readdir.c \ registry.c select.c sendmail.c time.c winutil.c wsyslog.c globals.c"); +ADD_FLAG("CFLAGS_BD_WIN32", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); + PHP_INSTALL_HEADERS("", "Zend/ TSRM/ main/ main/streams/ win32/"); STDOUT.WriteBlankLines(1); diff --git a/win32/php_win32_globals.h b/win32/php_win32_globals.h index 42f5ec9411..4029117b8f 100644 --- a/win32/php_win32_globals.h +++ b/win32/php_win32_globals.h @@ -26,7 +26,7 @@ typedef struct _php_win32_core_globals php_win32_core_globals; #ifdef ZTS -# define PW32G(v) TSRMG(php_win32_core_globals_id, php_win32_core_globals*, v) +# define PW32G(v) ZEND_TSRMG(php_win32_core_globals_id, php_win32_core_globals*, v) extern PHPAPI int php_win32_core_globals_id; #else # define PW32G(v) (the_php_win32_core_globals.v) |