Skip to content

Commit c359e40

Browse files
committed
More ext_skel cleanup
1 parent d0095ba commit c359e40

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

ext/skeleton/php_skeleton.h

+12-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ extern zend_module_entry extname_module_entry;
1212
#define PHP_EXTNAME_API
1313
#endif
1414

15+
#ifdef ZTS
16+
#include "TSRM.h"
17+
#endif
18+
1519
PHP_MINIT_FUNCTION(extname);
1620
PHP_MSHUTDOWN_FUNCTION(extname);
1721
PHP_RINIT_FUNCTION(extname);
@@ -31,15 +35,18 @@ ZEND_BEGIN_MODULE_GLOBALS(extname)
3135
ZEND_END_MODULE_GLOBALS(extname)
3236
*/
3337

34-
/* In every function that needs to use variables in php_extname_globals,
35-
do call EXTNAME_LS_FETCH(); after declaring other variables used by
36-
that function, and always refer to them as EXTNAME_G(variable).
37-
You are encouraged to rename these macros something shorter, see
38+
/* In every utility function you add that needs to use variables
39+
in php_extname_globals, call TSRM_FETCH(); after declaring other
40+
variables used by that function, or better yet, pass in TSRMG_CC
41+
after the last function argument and declare your utility function
42+
with TSRMG_DC after the last declared argument. Always refer to
43+
the globals in your function as EXTNAME_G(variable). You are
44+
encouraged to rename these macros something shorter, see
3845
examples in any other php module directory.
3946
*/
4047

4148
#ifdef ZTS
42-
#define EXTNAME_G(v) TSRMG(extname_globals_id, zend_##extname_globals *, v)
49+
#define EXTNAME_G(v) TSRMG(extname_globals_id, zend_extname_globals *, v)
4350
#else
4451
#define EXTNAME_G(v) (extname_globals.v)
4552
#endif

ext/skeleton/skeleton.c

+19
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,25 @@ PHP_INI_END()
5555
*/
5656
/* }}} */
5757

58+
/* {{{ php_extname_init_globals
59+
*/
60+
/* Uncomment this function if you have INI entries
61+
static void php_extname_init_globals(zend_extname_globals *extname_globals)
62+
{
63+
extname_globals->value = 0;
64+
extname_globals->string = NULL;
65+
}
66+
*/
67+
/* }}} */
68+
5869
/* {{{ PHP_MINIT_FUNCTION
5970
*/
6071
PHP_MINIT_FUNCTION(extname)
6172
{
73+
/* If you have INI entries, uncomment these lines
74+
ZEND_INIT_MODULE_GLOBALS(extname, php_extname_init_globals, NULL);
75+
REGISTER_INI_ENTRIES();
76+
*/
6277
return SUCCESS;
6378
}
6479
/* }}} */
@@ -67,6 +82,9 @@ PHP_MINIT_FUNCTION(extname)
6782
*/
6883
PHP_MSHUTDOWN_FUNCTION(extname)
6984
{
85+
/* uncomment this line if you have INI entries
86+
UNREGISTER_INI_ENTRIES();
87+
*/
7088
return SUCCESS;
7189
}
7290
/* }}} */
@@ -103,6 +121,7 @@ PHP_MINFO_FUNCTION(extname)
103121
}
104122
/* }}} */
105123

124+
106125
/* Remove the following function when you have succesfully modified config.m4
107126
so that your module can be compiled into PHP, it exists only for testing
108127
purposes. */

0 commit comments

Comments
 (0)