Skip to content

Commit aac7b1d

Browse files
committed
converted ext/sqlite and ext/pdo_mysql to use static tsrmls cache
1 parent 073c79b commit aac7b1d

File tree

8 files changed

+23
-5
lines changed

8 files changed

+23
-5
lines changed

ext/pdo_mysql/config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ if test "$PHP_PDO_MYSQL" != "no"; then
144144
fi
145145

146146
dnl fix after renaming to pdo_mysql
147-
PHP_NEW_EXTENSION(pdo_mysql, pdo_mysql.c mysql_driver.c mysql_statement.c, $ext_shared,,-I$pdo_cv_inc_path -I)
147+
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)
148148
ifdef([PHP_ADD_EXTENSION_DEP],
149149
[
150150
PHP_ADD_EXTENSION_DEP(pdo_mysql, pdo)

ext/pdo_mysql/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (PHP_PDO_MYSQL != "no") {
1212
} else {
1313
if (CHECK_LIB("libmysql.lib", "pdo_mysql", PHP_PDO_MYSQL) &&
1414
CHECK_HEADER_ADD_INCLUDE("mysql.h", "CFLAGS_PDO_MYSQL", PHP_PHP_BUILD + "\\include\\mysql;" + PHP_PDO_MYSQL)) {
15-
EXTENSION("pdo_mysql", "pdo_mysql.c mysql_driver.c mysql_statement.c");
15+
EXTENSION("pdo_mysql", "pdo_mysql.c mysql_driver.c mysql_statement.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
1616
} else {
1717
WARNING("pdo_mysql not enabled; libraries and headers not found");
1818
}

ext/pdo_mysql/pdo_mysql.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include "php_pdo_mysql_int.h"
3333

3434
#ifdef COMPILE_DL_PDO_MYSQL
35+
#ifdef ZTS
36+
ZEND_TSRMLS_CACHE_DEFINE;
37+
#endif
3538
ZEND_GET_MODULE(pdo_mysql)
3639
#endif
3740

@@ -206,6 +209,9 @@ static PHP_RSHUTDOWN_FUNCTION(pdo_mysql)
206209
*/
207210
static PHP_GINIT_FUNCTION(pdo_mysql)
208211
{
212+
#if defined(COMPILE_DL_PDO_MYSQL) && defined(ZTS)
213+
ZEND_TSRMLS_CACHE_UPDATE;
214+
#endif
209215
#ifndef PHP_WIN32
210216
pdo_mysql_globals->default_socket = NULL;
211217
#endif

ext/pdo_mysql/php_pdo_mysql_int.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ ZEND_END_MODULE_GLOBALS(pdo_mysql)
8383
ZEND_EXTERN_MODULE_GLOBALS(pdo_mysql)
8484

8585
#ifdef ZTS
86-
#define PDO_MYSQL_G(v) TSRMG(pdo_mysql_globals_id, zend_pdo_mysql_globals *, v)
86+
#define PDO_MYSQL_G(v) ZEND_TSRMG(pdo_mysql_globals_id, zend_pdo_mysql_globals *, v)
87+
# ifdef COMPILE_DL_PDO_MYSQL
88+
ZEND_TSRMLS_CACHE_EXTERN;
89+
# endif
8790
#else
8891
#define PDO_MYSQL_G(v) (pdo_mysql_globals.v)
8992
#endif

ext/sqlite3/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG_WITH("sqlite3", "SQLite 3 support", "no");
55

66
if (PHP_SQLITE3 != "no") {
77
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) ");
8-
EXTENSION("sqlite3", "sqlite3.c", null, "/I" + configure_module_dirname + "/libsqlite /I" + configure_module_dirname);
8+
EXTENSION("sqlite3", "sqlite3.c", null, "/I" + configure_module_dirname + "/libsqlite /I" + configure_module_dirname + " /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
99

1010
ADD_SOURCES(configure_module_dirname + "/libsqlite", "sqlite3.c", "sqlite3");
1111

ext/sqlite3/config0.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PHP_ARG_WITH(sqlite3, whether to enable the SQLite3 extension,
88

99
if test $PHP_SQLITE3 != "no"; then
1010
sqlite3_extra_sources=""
11-
PHP_SQLITE3_CFLAGS=""
11+
PHP_SQLITE3_CFLAGS=" -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 "
1212

1313
dnl when running phpize enable_maintainer_zts is not available
1414
if test -z "$enable_maintainer_zts"; then

ext/sqlite3/php_sqlite3.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ ZEND_END_MODULE_GLOBALS(sqlite3)
3232

3333
#ifdef ZTS
3434
# define SQLITE3G(v) TSRMG(sqlite3_globals_id, zend_sqlite3_globals *, v)
35+
# ifdef COMPILE_DL_SQLITE3
36+
ZEND_TSRMLS_CACHE_EXTERN;
37+
# endif
3538
#else
3639
# define SQLITE3G(v) (sqlite3_globals.v)
3740
#endif

ext/sqlite3/sqlite3.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,9 @@ PHP_MINFO_FUNCTION(sqlite3)
22712271
*/
22722272
static PHP_GINIT_FUNCTION(sqlite3)
22732273
{
2274+
#if defined(COMPILE_DL_SQLITE3) && defined(ZTS)
2275+
ZEND_TSRMLS_CACHE_UPDATE;
2276+
#endif
22742277
memset(sqlite3_globals, 0, sizeof(*sqlite3_globals));
22752278
}
22762279
/* }}} */
@@ -2296,6 +2299,9 @@ zend_module_entry sqlite3_module_entry = {
22962299
/* }}} */
22972300

22982301
#ifdef COMPILE_DL_SQLITE3
2302+
#ifdef ZTS
2303+
ZEND_TSRMLS_CACHE_DEFINE;
2304+
#endif
22992305
ZEND_GET_MODULE(sqlite3)
23002306
#endif
23012307

0 commit comments

Comments
 (0)