summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
Diffstat (limited to 'sapi')
-rw-r--r--sapi/apache2handler/config.m42
-rw-r--r--sapi/apache2handler/config.w326
-rw-r--r--sapi/apache2handler/php_apache.h3
-rw-r--r--sapi/apache2handler/sapi_apache2.c11
-rw-r--r--sapi/cgi/cgi_main.c9
-rw-r--r--sapi/cgi/config.w322
-rw-r--r--sapi/cgi/config9.m42
-rw-r--r--sapi/cli/config.m42
-rw-r--r--sapi/cli/config.w324
-rw-r--r--sapi/cli/php_cli.c5
-rw-r--r--sapi/cli/php_cli_server.c17
-rw-r--r--sapi/cli/php_cli_server.h3
12 files changed, 40 insertions, 26 deletions
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