summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/dba/config.m42
-rw-r--r--ext/dba/config.w322
-rw-r--r--ext/dba/dba.c12
-rw-r--r--ext/imap/config.m42
-rw-r--r--ext/imap/config.w322
-rw-r--r--ext/imap/php_imap.c6
-rw-r--r--ext/imap/php_imap.h9
-rw-r--r--ext/ldap/config.m42
-rw-r--r--ext/ldap/config.w322
-rw-r--r--ext/ldap/ldap.c6
-rw-r--r--ext/ldap/php_ldap.h9
-rw-r--r--ext/pcntl/config.m42
-rw-r--r--ext/pcntl/pcntl.c6
-rw-r--r--ext/pcntl/php_pcntl.h9
-rw-r--r--ext/pdo_dblib/config.m42
-rw-r--r--ext/pdo_dblib/config.w322
-rw-r--r--ext/pdo_dblib/pdo_dblib.c6
-rw-r--r--ext/pdo_dblib/php_pdo_dblib_int.h9
-rw-r--r--ext/posix/config.m42
-rw-r--r--ext/posix/php_posix.h9
-rw-r--r--ext/posix/posix.c6
-rw-r--r--ext/recode/config.m42
-rw-r--r--ext/recode/recode.c12
-rw-r--r--ext/sqlite3/php_sqlite3.h10
24 files changed, 84 insertions, 47 deletions
diff --git a/ext/dba/config.m4 b/ext/dba/config.m4
index 19a916b0df..825cb2dc04 100644
--- a/ext/dba/config.m4
+++ b/ext/dba/config.m4
@@ -700,7 +700,7 @@ if test "$HAVE_DBA" = "1"; then
AC_MSG_RESULT([yes])
fi
AC_DEFINE(HAVE_DBA, 1, [ ])
- PHP_NEW_EXTENSION(dba, dba.c dba_cdb.c dba_dbm.c dba_gdbm.c dba_ndbm.c dba_db1.c dba_db2.c dba_db3.c dba_db4.c dba_flatfile.c dba_inifile.c dba_qdbm.c dba_tcadb.c dba_lmdb.c $cdb_sources $flat_sources $ini_sources, $ext_shared)
+ PHP_NEW_EXTENSION(dba, dba.c dba_cdb.c dba_dbm.c dba_gdbm.c dba_ndbm.c dba_db1.c dba_db2.c dba_db3.c dba_db4.c dba_flatfile.c dba_inifile.c dba_qdbm.c dba_tcadb.c dba_lmdb.c $cdb_sources $flat_sources $ini_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_ADD_BUILD_DIR($ext_builddir/libinifile)
PHP_ADD_BUILD_DIR($ext_builddir/libcdb)
PHP_ADD_BUILD_DIR($ext_builddir/libflatfile)
diff --git a/ext/dba/config.w32 b/ext/dba/config.w32
index 16317c941d..6391076de8 100644
--- a/ext/dba/config.w32
+++ b/ext/dba/config.w32
@@ -6,7 +6,7 @@ ARG_WITH("db", "DBA: Berkeley DB support", "no");
ARG_WITH("lmdb", "DBA: Lightning memory-mapped database support", "no");
if (PHP_DBA != "no") {
- EXTENSION("dba", "dba.c dba_cdb.c dba_db1.c dba_db2.c dba_db3.c dba_dbm.c dba_flatfile.c dba_gdbm.c dba_ndbm.c dba_inifile.c");
+ EXTENSION("dba", "dba.c dba_cdb.c dba_db1.c dba_db2.c dba_db3.c dba_dbm.c dba_flatfile.c dba_gdbm.c dba_ndbm.c dba_inifile.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
ADD_SOURCES("ext/dba/libcdb", "cdb.c cdb_make.c uint32.c", "dba");
ADD_SOURCES("ext/dba/libflatfile", "flatfile.c", "dba");
ADD_SOURCES("ext/dba/libinifile", "inifile.c", "dba");
diff --git a/ext/dba/dba.c b/ext/dba/dba.c
index 5e163066f3..ede12f0bd6 100644
--- a/ext/dba/dba.c
+++ b/ext/dba/dba.c
@@ -160,11 +160,7 @@ ZEND_END_MODULE_GLOBALS(dba)
ZEND_DECLARE_MODULE_GLOBALS(dba)
-#ifdef ZTS
-#define DBA_G(v) TSRMG(dba_globals_id, zend_dba_globals *, v)
-#else
-#define DBA_G(v) (dba_globals.v)
-#endif
+#define DBA_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(dba, v)
static PHP_GINIT_FUNCTION(dba);
@@ -186,6 +182,9 @@ zend_module_entry dba_module_entry = {
};
#ifdef COMPILE_DL_DBA
+#ifdef ZTS
+ZEND_TSRMLS_CACHE_DEFINE()
+#endif
ZEND_GET_MODULE(dba)
#endif
@@ -515,6 +514,9 @@ PHP_INI_END()
*/
static PHP_GINIT_FUNCTION(dba)
{
+#if defined(COMPILE_DL_DBA) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
dba_globals->default_handler = "";
dba_globals->default_hptr = NULL;
}
diff --git a/ext/imap/config.m4 b/ext/imap/config.m4
index 65edbb1401..4eeda854b7 100644
--- a/ext/imap/config.m4
+++ b/ext/imap/config.m4
@@ -112,7 +112,7 @@ PHP_ARG_WITH([imap-ssl],
if test "$PHP_IMAP" != "no"; then
PHP_SUBST(IMAP_SHARED_LIBADD)
- PHP_NEW_EXTENSION(imap, php_imap.c, $ext_shared)
+ PHP_NEW_EXTENSION(imap, php_imap.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
AC_DEFINE(HAVE_IMAP,1,[ ])
for i in $PHP_IMAP /usr/local /usr; do
diff --git a/ext/imap/config.w32 b/ext/imap/config.w32
index 0f79659b77..594113b5d3 100644
--- a/ext/imap/config.w32
+++ b/ext/imap/config.w32
@@ -13,7 +13,7 @@ if (PHP_IMAP == "yes") {
CHECK_LIB("ws2_32.lib", "imap");
CHECK_LIB("Secur32.lib", "imap");
CHECK_LIB("crypt32.lib", "imap");
- EXTENSION("imap", "php_imap.c", true);
+ EXTENSION("imap", "php_imap.c", true, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
ADD_FLAG("CFLAGS_IMAP", "/D HAVE_IMAP2000=1 /D HAVE_IMAP2004=1 /D HAVE_IMAP2007a=1 /D HAVE_IMAP2007b=1 /D HAVE_IMAP_SSL=1");
AC_DEFINE('HAVE_IMAP', 1, 'Have IMAP support', true);
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index 5802fa68c5..86a4296a98 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -592,6 +592,9 @@ zend_module_entry imap_module_entry = {
/* }}} */
#ifdef COMPILE_DL_IMAP
+#ifdef ZTS
+ZEND_TSRMLS_CACHE_DEFINE()
+#endif
ZEND_GET_MODULE(imap)
#endif
@@ -808,6 +811,9 @@ void mail_getacl(MAILSTREAM *stream, char *mailbox, ACLLIST *alist)
*/
static PHP_GINIT_FUNCTION(imap)
{
+#if defined(COMPILE_DL_IMAP) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
imap_globals->imap_user = NIL;
imap_globals->imap_password = NIL;
diff --git a/ext/imap/php_imap.h b/ext/imap/php_imap.h
index 74f461d1ca..c23799976c 100644
--- a/ext/imap/php_imap.h
+++ b/ext/imap/php_imap.h
@@ -232,12 +232,13 @@ ZEND_BEGIN_MODULE_GLOBALS(imap)
zend_bool enable_rsh;
ZEND_END_MODULE_GLOBALS(imap)
-#ifdef ZTS
-# define IMAPG(v) TSRMG(imap_globals_id, zend_imap_globals *, v)
-#else
-# define IMAPG(v) (imap_globals.v)
+#if defined(ZTS) && defined(COMPILE_DL_IMAP)
+ZEND_TSRMLS_CACHE_EXTERN()
#endif
+ZEND_EXTERN_MODULE_GLOBALS(imap)
+#define IMAPG(v) ZEND_MODULE_GLOBALS_ACCESSOR(imap, v)
+
#else
#define imap_module_ptr NULL
diff --git a/ext/ldap/config.m4 b/ext/ldap/config.m4
index 15cef2afff..8b94c06225 100644
--- a/ext/ldap/config.m4
+++ b/ext/ldap/config.m4
@@ -96,7 +96,7 @@ PHP_ARG_WITH([ldap-sasl],
if test "$PHP_LDAP" != "no"; then
- PHP_NEW_EXTENSION(ldap, ldap.c, $ext_shared,,-DLDAP_DEPRECATED=1)
+ PHP_NEW_EXTENSION(ldap, ldap.c, $ext_shared,,-DLDAP_DEPRECATED=1 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
if test "$PHP_LDAP" = "yes"; then
for i in /usr/local /usr; do
diff --git a/ext/ldap/config.w32 b/ext/ldap/config.w32
index a16a4fcd65..49f740bd65 100644
--- a/ext/ldap/config.w32
+++ b/ext/ldap/config.w32
@@ -10,7 +10,7 @@ if (PHP_LDAP != "no") {
CHECK_LIB("oldap32_a.lib", "ldap", PHP_LDAP) &&
CHECK_LIB("olber32_a.lib", "ldap", PHP_LDAP)&&
CHECK_LIB("libsasl.lib", "ldap", PHP_LDAP)) {
- EXTENSION('ldap', 'ldap.c');
+ EXTENSION('ldap', 'ldap.c', null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
AC_DEFINE('HAVE_LDAP_PARSE_RESULT', 1);
AC_DEFINE('HAVE_LDAP_PARSE_REFERENCE', 1);
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index f58b09acaa..f191fb8345 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -96,6 +96,9 @@ static PHP_GINIT_FUNCTION(ldap);
static int le_link, le_result, le_result_entry;
#ifdef COMPILE_DL_LDAP
+#ifdef ZTS
+ZEND_TSRMLS_CACHE_DEFINE()
+#endif
ZEND_GET_MODULE(ldap)
#endif
@@ -661,6 +664,9 @@ PHP_INI_END()
*/
static PHP_GINIT_FUNCTION(ldap)
{
+#if defined(COMPILE_DL_LDAP) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
ldap_globals->num_links = 0;
}
/* }}} */
diff --git a/ext/ldap/php_ldap.h b/ext/ldap/php_ldap.h
index 10b1d59b5f..f777fe9a5f 100644
--- a/ext/ldap/php_ldap.h
+++ b/ext/ldap/php_ldap.h
@@ -43,12 +43,13 @@ ZEND_BEGIN_MODULE_GLOBALS(ldap)
zend_long max_links;
ZEND_END_MODULE_GLOBALS(ldap)
-#ifdef ZTS
-# define LDAPG(v) TSRMG(ldap_globals_id, zend_ldap_globals *, v)
-#else
-# define LDAPG(v) (ldap_globals.v)
+#if defined(ZTS) && defined(COMPILE_DL_LDAP)
+ZEND_TSRMLS_CACHE_EXTERN()
#endif
+ZEND_EXTERN_MODULE_GLOBALS(ldap)
+#define LDAPG(v) ZEND_MODULE_GLOBALS_ACCESSOR(ldap, v)
+
#define phpext_ldap_ptr ldap_module_ptr
/* Constants for ldap_modify_batch */
diff --git a/ext/pcntl/config.m4 b/ext/pcntl/config.m4
index 1c83a1b671..c9672de0fb 100644
--- a/ext/pcntl/config.m4
+++ b/ext/pcntl/config.m4
@@ -26,5 +26,5 @@ if test "$PHP_PCNTL" != "no"; then
AC_MSG_RESULT([no])
])
- PHP_NEW_EXTENSION(pcntl, pcntl.c php_signal.c, $ext_shared, cli, $PCNTL_CFLAGS)
+ PHP_NEW_EXTENSION(pcntl, pcntl.c php_signal.c, $ext_shared, cli, $PCNTL_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
fi
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 1546e094f3..0176ef89e9 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -238,6 +238,9 @@ zend_module_entry pcntl_module_entry = {
};
#ifdef COMPILE_DL_PCNTL
+#ifdef ZTS
+ZEND_TSRMLS_CACHE_DEFINE()
+#endif
ZEND_GET_MODULE(pcntl)
#endif
@@ -576,6 +579,9 @@ static void php_pcntl_register_errno_constants(INIT_FUNC_ARGS)
static PHP_GINIT_FUNCTION(pcntl)
{
+#if defined(COMPILE_DL_PCNTL) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
memset(pcntl_globals, 0, sizeof(*pcntl_globals));
}
diff --git a/ext/pcntl/php_pcntl.h b/ext/pcntl/php_pcntl.h
index 3a91233754..90ce2aea96 100644
--- a/ext/pcntl/php_pcntl.h
+++ b/ext/pcntl/php_pcntl.h
@@ -91,12 +91,13 @@ ZEND_BEGIN_MODULE_GLOBALS(pcntl)
zend_bool async_signals;
ZEND_END_MODULE_GLOBALS(pcntl)
-#ifdef ZTS
-#define PCNTL_G(v) TSRMG(pcntl_globals_id, zend_pcntl_globals *, v)
-#else
-#define PCNTL_G(v) (pcntl_globals.v)
+#if defined(ZTS) && defined(COMPILE_DL_PCNTL)
+ZEND_TSRMLS_CACHE_EXTERN()
#endif
+ZEND_EXTERN_MODULE_GLOBALS(pcntl)
+#define PCNTL_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(pcntl, v)
+
#define REGISTER_PCNTL_ERRNO_CONSTANT(name) REGISTER_LONG_CONSTANT("PCNTL_" #name, name, CONST_CS | CONST_PERSISTENT)
#endif /* PHP_PCNTL_H */
diff --git a/ext/pdo_dblib/config.m4 b/ext/pdo_dblib/config.m4
index de770d4e58..7f6bd50e32 100644
--- a/ext/pdo_dblib/config.m4
+++ b/ext/pdo_dblib/config.m4
@@ -71,7 +71,7 @@ if test "$PHP_PDO_DBLIB" != "no"; then
])
PDO_DBLIB_DEFS="-DPDO_DBLIB_FLAVOUR=\\\"freetds\\\""
- PHP_NEW_EXTENSION(pdo_dblib, pdo_dblib.c dblib_driver.c dblib_stmt.c, $ext_shared,,-I$pdo_cv_inc_path $PDO_DBLIB_DEFS)
+ PHP_NEW_EXTENSION(pdo_dblib, pdo_dblib.c dblib_driver.c dblib_stmt.c, $ext_shared,,-I$pdo_cv_inc_path $PDO_DBLIB_DEFS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
AC_CHECK_LIB(dnet_stub, dnet_addr,
[ PHP_ADD_LIBRARY_WITH_PATH(dnet_stub,,PDO_DBLIB_SHARED_LIBADD)
AC_DEFINE(HAVE_LIBDNET_STUB,1,[ ])
diff --git a/ext/pdo_dblib/config.w32 b/ext/pdo_dblib/config.w32
index 9ceed49205..4b1c76130f 100644
--- a/ext/pdo_dblib/config.w32
+++ b/ext/pdo_dblib/config.w32
@@ -10,7 +10,7 @@ if (PHP_PDO_DBLIB != "no") {
CHECK_HEADER_ADD_INCLUDE("sybfront.h", "CFLAGS_PDO_DBLIB",
PHP_PDO_DBLIB, null, null, true))
{
- EXTENSION("pdo_dblib", "pdo_dblib.c dblib_driver.c dblib_stmt.c");
+ EXTENSION("pdo_dblib", "pdo_dblib.c dblib_driver.c dblib_stmt.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
ADD_FLAG('CFLAGS_PDO_DBLIB', "/D PDO_DBLIB_FLAVOUR=\\\"freetds\\\"");
ADD_EXTENSION_DEP('pdo_dblib', 'pdo');
} else {
diff --git a/ext/pdo_dblib/pdo_dblib.c b/ext/pdo_dblib/pdo_dblib.c
index 8ba7d6e413..0272a12585 100644
--- a/ext/pdo_dblib/pdo_dblib.c
+++ b/ext/pdo_dblib/pdo_dblib.c
@@ -71,6 +71,9 @@ zend_module_entry pdo_dblib_module_entry = {
};
#if defined(COMPILE_DL_PDO_DBLIB) || defined(COMPILE_DL_PDO_MSSQL)
+#ifdef ZTS
+ZEND_TSRMLS_CACHE_DEFINE()
+#endif
#if PDO_DBLIB_IS_MSSQL
ZEND_GET_MODULE(pdo_mssql)
#else
@@ -166,6 +169,9 @@ void pdo_dblib_err_dtor(pdo_dblib_err *err)
static PHP_GINIT_FUNCTION(dblib)
{
+#if defined(ZTS) && (defined(COMPILE_DL_PDO_DBLIB) || defined(COMPILE_DL_PDO_MSSQL))
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
memset(dblib_globals, 0, sizeof(*dblib_globals));
dblib_globals->err.sqlstate = dblib_globals->sqlstate;
}
diff --git a/ext/pdo_dblib/php_pdo_dblib_int.h b/ext/pdo_dblib/php_pdo_dblib_int.h
index 5cf4d30769..52ee3aafd9 100644
--- a/ext/pdo_dblib/php_pdo_dblib_int.h
+++ b/ext/pdo_dblib/php_pdo_dblib_int.h
@@ -145,13 +145,14 @@ ZEND_BEGIN_MODULE_GLOBALS(dblib)
char sqlstate[6];
ZEND_END_MODULE_GLOBALS(dblib)
-#ifdef ZTS
-# define DBLIB_G(v) TSRMG(dblib_globals_id, zend_dblib_globals *, v)
-#else
-# define DBLIB_G(v) (dblib_globals.v)
+#if defined(ZTS) && (defined(COMPILE_DL_PDO_DBLIB) || defined(COMPILE_DL_PDO_MSSQL))
+ZEND_TSRMLS_CACHE_EXTERN()
#endif
ZEND_EXTERN_MODULE_GLOBALS(dblib)
+#define DBLIB_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(dblib, v)
+
+ZEND_EXTERN_MODULE_GLOBALS(dblib)
enum {
PDO_DBLIB_ATTR_CONNECTION_TIMEOUT = PDO_ATTR_DRIVER_SPECIFIC,
diff --git a/ext/posix/config.m4 b/ext/posix/config.m4
index f56f6c60cd..ea67485597 100644
--- a/ext/posix/config.m4
+++ b/ext/posix/config.m4
@@ -8,7 +8,7 @@ PHP_ARG_ENABLE([posix],
if test "$PHP_POSIX" = "yes"; then
AC_DEFINE(HAVE_POSIX, 1, [whether to include POSIX-like functions])
- PHP_NEW_EXTENSION(posix, posix.c, $ext_shared)
+ PHP_NEW_EXTENSION(posix, posix.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
AC_CHECK_HEADERS([sys/mkdev.h sys/sysmacros.h])
diff --git a/ext/posix/php_posix.h b/ext/posix/php_posix.h
index 7fff314be2..17d8b038c2 100644
--- a/ext/posix/php_posix.h
+++ b/ext/posix/php_posix.h
@@ -125,12 +125,13 @@ ZEND_BEGIN_MODULE_GLOBALS(posix)
int last_error;
ZEND_END_MODULE_GLOBALS(posix)
-#ifdef ZTS
-# define POSIX_G(v) TSRMG(posix_globals_id, zend_posix_globals *, v)
-#else
-# define POSIX_G(v) (posix_globals.v)
+#if defined(ZTS) && defined(COMPILE_DL_POSIX)
+ZEND_TSRMLS_CACHE_EXTERN()
#endif
+ZEND_EXTERN_MODULE_GLOBALS(posix)
+#define POSIX_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(posix, v)
+
#else
#define posix_module_ptr NULL
diff --git a/ext/posix/posix.c b/ext/posix/posix.c
index 3e72304394..e95064d0fa 100644
--- a/ext/posix/posix.c
+++ b/ext/posix/posix.c
@@ -324,6 +324,9 @@ static PHP_MINFO_FUNCTION(posix)
static PHP_GINIT_FUNCTION(posix) /* {{{ */
{
+#if defined(COMPILE_DL_POSIX) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
posix_globals->last_error = 0;
}
/* }}} */
@@ -427,6 +430,9 @@ zend_module_entry posix_module_entry = {
/* }}} */
#ifdef COMPILE_DL_POSIX
+#ifdef ZTS
+ZEND_TSRMLS_CACHE_DEFINE()
+#endif
ZEND_GET_MODULE(posix)
#endif
diff --git a/ext/recode/config.m4 b/ext/recode/config.m4
index 8507577607..537da2ead2 100644
--- a/ext/recode/config.m4
+++ b/ext/recode/config.m4
@@ -59,5 +59,5 @@ recode_format_table();
PHP_ADD_INCLUDE($RECODE_DIR/$RECODE_INC)
PHP_SUBST(RECODE_SHARED_LIBADD)
AC_CHECK_HEADERS(stdbool.h)
- PHP_NEW_EXTENSION(recode, recode.c, $ext_shared)
+ PHP_NEW_EXTENSION(recode, recode.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
fi
diff --git a/ext/recode/recode.c b/ext/recode/recode.c
index 5330a6e20a..74a1f1eded 100644
--- a/ext/recode/recode.c
+++ b/ext/recode/recode.c
@@ -55,11 +55,7 @@ ZEND_BEGIN_MODULE_GLOBALS(recode)
RECODE_OUTER outer;
ZEND_END_MODULE_GLOBALS(recode)
-#ifdef ZTS
-# define ReSG(v) TSRMG(recode_globals_id, zend_recode_globals *, v)
-#else
-# define ReSG(v) (recode_globals.v)
-#endif
+#define ReSG(v) ZEND_MODULE_GLOBALS_ACCESSOR(recode, v)
ZEND_DECLARE_MODULE_GLOBALS(recode)
static PHP_GINIT_FUNCTION(recode);
@@ -103,11 +99,17 @@ zend_module_entry recode_module_entry = {
};
#ifdef COMPILE_DL_RECODE
+#ifdef ZTS
+ZEND_TSRMLS_CACHE_DEFINE()
+#endif
ZEND_GET_MODULE(recode)
#endif
static PHP_GINIT_FUNCTION(recode)
{
+#if defined(COMPILE_DL_RECODE) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
recode_globals->outer = NULL;
}
diff --git a/ext/sqlite3/php_sqlite3.h b/ext/sqlite3/php_sqlite3.h
index 411c4eb0ba..ca09e341ab 100644
--- a/ext/sqlite3/php_sqlite3.h
+++ b/ext/sqlite3/php_sqlite3.h
@@ -29,15 +29,13 @@ ZEND_BEGIN_MODULE_GLOBALS(sqlite3)
int dbconfig_defensive;
ZEND_END_MODULE_GLOBALS(sqlite3)
-#ifdef ZTS
-# define SQLITE3G(v) TSRMG(sqlite3_globals_id, zend_sqlite3_globals *, v)
-# ifdef COMPILE_DL_SQLITE3
+#if defined(ZTS) && defined(COMPILE_DL_SQLITE3)
ZEND_TSRMLS_CACHE_EXTERN()
-# endif
-#else
-# define SQLITE3G(v) (sqlite3_globals.v)
#endif
+ZEND_EXTERN_MODULE_GLOBALS(sqlite3)
+#define SQLITE3G(v) ZEND_MODULE_GLOBALS_ACCESSOR(sqlite3, v)
+
#define PHP_SQLITE3_ASSOC 1<<0
#define PHP_SQLITE3_NUM 1<<1
#define PHP_SQLITE3_BOTH (PHP_SQLITE3_ASSOC|PHP_SQLITE3_NUM)