Skip to content

Commit e1fcb9e

Browse files
committed
integrated the static tsrmls cache into ext/skel
1 parent 9c354ba commit e1fcb9e

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

ext/ext_skel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ if test "\$PHP_$EXTNAME" != "no"; then
166166
dnl
167167
dnl PHP_SUBST(${EXTNAME}_SHARED_LIBADD)
168168
169-
PHP_NEW_EXTENSION($extname, $extname.c, \$ext_shared)
169+
PHP_NEW_EXTENSION($extname, $extname.c, \$ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
170170
fi
171171
eof
172172

@@ -182,7 +182,7 @@ cat >config.w32 <<eof
182182
// ARG_ENABLE("$extname", "enable $extname support", "no");
183183
184184
if (PHP_$EXTNAME != "no") {
185-
EXTENSION("$extname", "$extname.c");
185+
EXTENSION("$extname", "$extname.c", PHP_EXTNAME_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
186186
}
187187
188188
eof

ext/skeleton/php_skeleton.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,16 @@ ZEND_BEGIN_MODULE_GLOBALS(extname)
3030
ZEND_END_MODULE_GLOBALS(extname)
3131
*/
3232

33-
/* In every utility function you add that needs to use variables
34-
in php_extname_globals, call TSRMLS_FETCH(); after declaring other
35-
variables used by that function, or better yet, pass in
36-
after the last function argument and declare your utility function
37-
with after the last declared argument. Always refer to
38-
the globals in your function as EXTNAME_G(variable). You are
39-
encouraged to rename these macros something shorter, see
33+
/* Always refer to the globals in your function as EXTNAME_G(variable).
34+
You are encouraged to rename these macros something shorter, see
4035
examples in any other php module directory.
4136
*/
4237

4338
#ifdef ZTS
44-
#define EXTNAME_G(v) TSRMG(extname_globals_id, zend_extname_globals *, v)
39+
#define EXTNAME_G(v) ZEND_TSRMG(extname_globals_id, zend_extname_globals *, v)
40+
#ifdef COMPILE_DL_EXTNAME
41+
ZEND_TSRMLS_CACHE_EXTERN;
42+
#endif
4543
#else
4644
#define EXTNAME_G(v) (extname_globals.v)
4745
#endif

ext/skeleton/skeleton.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ PHP_MSHUTDOWN_FUNCTION(extname)
9595
*/
9696
PHP_RINIT_FUNCTION(extname)
9797
{
98+
#if defined(COMPILE_DL_EXTNAME) && defined(ZTS)
99+
ZEND_TSRMLS_CACHE_UPDATE;
100+
#endif
98101
return SUCCESS;
99102
}
100103
/* }}} */
@@ -150,6 +153,9 @@ zend_module_entry extname_module_entry = {
150153
/* }}} */
151154

152155
#ifdef COMPILE_DL_EXTNAME
156+
#ifdef ZTS
157+
ZEND_TSRMLS_CACHE_DEFINE;
158+
#endif
153159
ZEND_GET_MODULE(extname)
154160
#endif
155161

0 commit comments

Comments
 (0)