Skip to content

Commit 4e66cce

Browse files
committed
switch to the unified globals accessor where appropriate
1 parent 0615aa8 commit 4e66cce

25 files changed

+57
-152
lines changed

ext/bcmath/php_bcmath.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,11 @@ ZEND_BEGIN_MODULE_GLOBALS(bcmath)
5151
zend_long bc_precision;
5252
ZEND_END_MODULE_GLOBALS(bcmath)
5353

54-
#ifdef ZTS
55-
# define BCG(v) ZEND_TSRMG(bcmath_globals_id, zend_bcmath_globals *, v)
56-
# ifdef COMPILE_DL_BCMATH
54+
#if defined(ZTS) && defined(COMPILE_DL_BCMATH)
5755
ZEND_TSRMLS_CACHE_EXTERN();
58-
# endif
59-
#else
60-
# define BCG(v) (bcmath_globals.v)
6156
#endif
6257

6358
ZEND_EXTERN_MODULE_GLOBALS(bcmath)
59+
#define BCG(v) ZEND_MODULE_GLOBALS_ACCESSOR(bcmath, v)
6460

6561
#endif /* PHP_BCMATH_H */

ext/com_dotnet/php_com_dotnet.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,12 @@ ZEND_BEGIN_MODULE_GLOBALS(com_dotnet)
5555
zend_bool rshutdown_started;
5656
ZEND_END_MODULE_GLOBALS(com_dotnet)
5757

58-
#ifdef ZTS
59-
# define COMG(v) ZEND_TSRMG(com_dotnet_globals_id, zend_com_dotnet_globals *, v)
60-
# ifdef COMPILE_DL_COM_DOTNET
58+
#if defined(ZTS) && defined(COMPILE_DL_COM_DOTNET)
6159
ZEND_TSRMLS_CACHE_EXTERN();
62-
# endif
63-
#else
64-
# define COMG(v) (com_dotnet_globals.v)
6560
#endif
6661

6762
extern ZEND_DECLARE_MODULE_GLOBALS(com_dotnet);
63+
#define COMG(v) ZEND_MODULE_GLOBALS_ACCESSOR(com_dotnet, v)
6864

6965
#endif /* PHP_COM_DOTNET_H */
7066

ext/exif/exif.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,11 @@ ZEND_BEGIN_MODULE_GLOBALS(exif)
152152
ZEND_END_MODULE_GLOBALS(exif)
153153

154154
ZEND_DECLARE_MODULE_GLOBALS(exif)
155+
#define EXIF_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(exif, v)
155156

156-
#ifdef ZTS
157-
#define EXIF_G(v) ZEND_TSRMG(exif_globals_id, zend_exif_globals *, v)
158-
#ifdef COMPILE_DL_EXIF
157+
#if defined(ZTS) && defined(COMPILE_DL_EXIF)
159158
ZEND_TSRMLS_CACHE_DEFINE();
160159
#endif
161-
#else
162-
#define EXIF_G(v) (exif_globals.v)
163-
#endif
164160

165161
/* {{{ PHP_INI
166162
*/

ext/filter/php_filter.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ ZEND_BEGIN_MODULE_GLOBALS(filter)
6565
zend_long default_filter_flags;
6666
ZEND_END_MODULE_GLOBALS(filter)
6767

68-
#ifdef ZTS
69-
#define IF_G(v) ZEND_TSRMG(filter_globals_id, zend_filter_globals *, v)
68+
#if defined(COMPILE_DL_FILTER) && defined(ZTS)
7069
ZEND_TSRMLS_CACHE_EXTERN();
71-
#else
72-
#define IF_G(v) (filter_globals.v)
7370
#endif
7471

72+
#define IF_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(filter, v)
7573

7674
#define PHP_INPUT_FILTER_PARAM_DECL zval *value, zend_long flags, zval *option_array, char *charset
7775
void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL);

ext/gmp/php_gmp.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,11 @@ ZEND_BEGIN_MODULE_GLOBALS(gmp)
9595
gmp_randstate_t rand_state;
9696
ZEND_END_MODULE_GLOBALS(gmp)
9797

98-
#ifdef ZTS
99-
#define GMPG(v) ZEND_TSRMG(gmp_globals_id, zend_gmp_globals *, v)
100-
#ifdef COMPILE_DL_GMP
98+
#define GMPG(v) ZEND_MODULE_GLOBALS_ACCESSOR(gmp, v)
99+
100+
#if defined(ZTS) && defined(COMPILE_DL_GMP)
101101
ZEND_TSRMLS_CACHE_EXTERN();
102102
#endif
103-
#else
104-
#define GMPG(v) (gmp_globals.v)
105-
#endif
106103

107104
#else
108105

ext/iconv/php_iconv.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,10 @@ ZEND_BEGIN_MODULE_GLOBALS(iconv)
7575
char *output_encoding;
7676
ZEND_END_MODULE_GLOBALS(iconv)
7777

78-
#ifdef ZTS
79-
# define ICONVG(v) ZEND_TSRMG(iconv_globals_id, zend_iconv_globals *, v)
80-
# ifdef COMPILE_DL_ICONV
78+
#define ICONVG(v) ZEND_MODULE_GLOBALS_ACCESSOR(iconv, v)
79+
80+
#ifdef defined(ZTS) && defined(COMPILE_DL_ICONV)
8181
ZEND_TSRMLS_CACHE_EXTERN();
82-
# endif
83-
#else
84-
# define ICONVG(v) (iconv_globals.v)
8582
#endif
8683

8784
#ifdef HAVE_IBM_ICONV

ext/interbase/php_ibase_includes.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,10 @@ enum php_interbase_option {
127127
PHP_IBASE_NOWAIT = 256
128128
};
129129

130-
#ifdef ZTS
131-
#else
132-
#endif
130+
#define IBG(v) ZEND_MODULE_GLOBALS_ACCESSOR(ibase, v)
133131

134-
#ifdef ZTS
135-
# define IBG(v) ZEND_TSRMG(ibase_globals_id, zend_ibase_globals *, v)
136-
# ifdef COMPILE_DL_INTERBASE
132+
#if defined(ZTS) && defined(COMPILE_DL_INTERBASE)
137133
ZEND_TSRMLS_CACHE_EXTERN();
138-
# endif
139-
#else
140-
#define IBG(v) (ibase_globals.v)
141134
#endif
142135

143136
#define BLOB_ID_LEN 18

ext/intl/php_intl.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,13 @@ ZEND_BEGIN_MODULE_GLOBALS(intl)
5555
zend_bool use_exceptions;
5656
ZEND_END_MODULE_GLOBALS(intl)
5757

58-
/* Macro to access request-wide global variables. */
59-
#ifdef ZTS
60-
#define INTL_G(v) ZEND_TSRMG(intl_globals_id, zend_intl_globals *, v)
61-
#ifdef COMPILE_DL_INTL
58+
#if defined(ZTS) && defined(COMPILE_DL_INTL)
6259
ZEND_TSRMLS_CACHE_EXTERN();
6360
#endif
64-
#else
65-
#define INTL_G(v) (intl_globals.v)
66-
#endif
6761

6862
ZEND_EXTERN_MODULE_GLOBALS(intl)
63+
/* Macro to access request-wide global variables. */
64+
#define INTL_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(intl, v)
6965

7066
PHP_MINIT_FUNCTION(intl);
7167
PHP_MSHUTDOWN_FUNCTION(intl);

ext/json/php_json.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,10 @@ ZEND_BEGIN_MODULE_GLOBALS(json)
8282
ZEND_END_MODULE_GLOBALS(json)
8383

8484
ZEND_EXTERN_MODULE_GLOBALS(json);
85+
#define JSON_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(json, v)
8586

86-
#ifdef ZTS
87-
# define JSON_G(v) ZEND_TSRMG(json_globals_id, zend_json_globals *, v)
88-
# ifdef COMPILE_DL_JSON
89-
ZEND_TSRMLS_CACHE_EXTERN;
90-
# endif
91-
#else
92-
# define JSON_G(v) (json_globals.v)
87+
#if defined(ZTS) && defined(COMPILE_DL_JSON)
88+
ZEND_TSRMLS_CACHE_EXTERN();
9389
#endif
9490

9591
/* json_decode() options */

ext/libxml/php_libxml.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,11 @@ PHP_LIBXML_API zend_bool php_libxml_disable_entity_loader(zend_bool disable);
115115
PHP_LIBXML_API void php_libxml_initialize(void);
116116
PHP_LIBXML_API void php_libxml_shutdown(void);
117117

118-
#ifdef ZTS
119-
#define LIBXML(v) ZEND_TSRMG(libxml_globals_id, zend_libxml_globals *, v)
120-
#ifdef COMPILE_DL_LIBXML
118+
#define LIBXML(v) ZEND_MODULE_GLOBALS_ACCESSOR(libxml, v)
119+
120+
#if defined(ZTS) && defined(COMPILE_DL_LIBXML)
121121
ZEND_TSRMLS_CACHE_EXTERN();
122122
#endif
123-
#else
124-
#define LIBXML(v) (libxml_globals.v)
125-
#endif
126123

127124
#else /* HAVE_LIBXML */
128125
#define libxml_module_ptr NULL

ext/mbstring/mbstring.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,10 @@ struct mb_overload_def {
202202
char *save_func;
203203
};
204204

205-
#ifdef ZTS
206-
#define MBSTRG(v) ZEND_TSRMG(mbstring_globals_id, zend_mbstring_globals *, v)
205+
#define MBSTRG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mbstring, v)
206+
207+
#if defined(ZTS) && defined(COMPILE_DL_MBSTRING)
207208
ZEND_TSRMLS_CACHE_EXTERN();
208-
#else
209-
#define MBSTRG(v) (mbstring_globals.v)
210209
#endif
211210

212211
#else /* HAVE_MBSTRING */

ext/mysqli/php_mysqli_structs.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,11 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqli)
342342
zend_bool rollback_on_cached_plink;
343343
ZEND_END_MODULE_GLOBALS(mysqli)
344344

345+
#define MyG(v) ZEND_MODULE_GLOBALS_ACCESSOR(mysqli, v)
345346

346-
#ifdef ZTS
347-
#define MyG(v) ZEND_TSRMG(mysqli_globals_id, zend_mysqli_globals *, v)
348-
#ifdef COMPILE_DL_MYSQLI
347+
#if defined(ZTS) && defined(COMPILE_DL_MYSQLI)
349348
ZEND_TSRMLS_CACHE_EXTERN();
350349
#endif
351-
#else
352-
#define MyG(v) (mysqli_globals.v)
353-
#endif
354350

355351
#define my_estrdup(x) (x) ? estrdup(x) : NULL
356352
#define my_efree(x) if (x) efree(x)

ext/mysqlnd/mysqlnd.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,11 @@ ZEND_BEGIN_MODULE_GLOBALS(mysqlnd)
281281
ZEND_END_MODULE_GLOBALS(mysqlnd)
282282

283283
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(mysqlnd)
284+
#define MYSQLND_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(mysqlnd, v)
284285

285-
#ifdef ZTS
286-
#define MYSQLND_G(v) ZEND_TSRMG(mysqlnd_globals_id, zend_mysqlnd_globals *, v)
287-
#ifdef COMPILE_DL_MYSQLND
286+
#if defined(ZTS) && defined(COMPILE_DL_MYSQLND)
288287
ZEND_TSRMLS_CACHE_EXTERN();
289288
#endif
290-
#else
291-
#define MYSQLND_G(v) (mysqlnd_globals.v)
292-
#endif
293289

294290

295291
PHPAPI void mysqlnd_minfo_print_hash(zval *values);

ext/odbc/php_odbc_includes.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,11 @@ void odbc_sql_error(ODBC_SQL_ERROR_PARAMS);
296296
#endif
297297
#define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY)
298298

299-
#ifdef ZTS
300-
# define ODBCG(v) ZEND_TSRMG(odbc_globals_id, zend_odbc_globals *, v)
301-
# ifdef COMPILE_DL_ODBC
299+
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(odbc)
300+
#define ODBCG(v) ZEND_MODULE_GLOBALS_ACCESSOR(odbc, v)
301+
302+
#if defined(ZTS) && defined(COMPILE_DL_ODBC)
302303
ZEND_TSRMLS_CACHE_EXTERN();
303-
# endif
304-
#else
305-
# define ODBCG(v) (odbc_globals.v)
306-
extern ZEND_API zend_odbc_globals odbc_globals;
307304
#endif
308305

309306
#endif /* HAVE_UODBC */

ext/pdo_mysql/php_pdo_mysql_int.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,10 @@ ZEND_BEGIN_MODULE_GLOBALS(pdo_mysql)
8686
ZEND_END_MODULE_GLOBALS(pdo_mysql)
8787

8888
ZEND_EXTERN_MODULE_GLOBALS(pdo_mysql)
89+
#define PDO_MYSQL_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(pdo_mysql, v)
8990

90-
#ifdef ZTS
91-
#define PDO_MYSQL_G(v) ZEND_TSRMG(pdo_mysql_globals_id, zend_pdo_mysql_globals *, v)
92-
# ifdef COMPILE_DL_PDO_MYSQL
91+
#if defined(ZTS) && defined(COMPILE_DL_PDO_MYSQL)
9392
ZEND_TSRMLS_CACHE_EXTERN();
94-
# endif
95-
#else
96-
#define PDO_MYSQL_G(v) (pdo_mysql_globals.v)
9793
#endif
9894

9995

ext/pgsql/php_pgsql.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,10 @@ ZEND_BEGIN_MODULE_GLOBALS(pgsql)
323323
ZEND_END_MODULE_GLOBALS(pgsql)
324324

325325
ZEND_EXTERN_MODULE_GLOBALS(pgsql)
326+
# define PGG(v) ZEND_MODULE_GLOBALS_ACCESSOR(pgsql, v)
326327

327-
#ifdef ZTS
328-
# define PGG(v) ZEND_TSRMG(pgsql_globals_id, zend_pgsql_globals *, v)
329-
# ifdef COMPILE_DL_PGSQL
328+
#if defined(ZTS) && defined(COMPILE_DL_PGSQL)
330329
ZEND_TSRMLS_CACHE_EXTERN();
331-
# endif
332-
#else
333-
# define PGG(v) (pgsql_globals.v)
334330
#endif
335331

336332
#endif

ext/phar/phar_internal.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,10 @@ ZEND_BEGIN_MODULE_GLOBALS(phar)
195195
ZEND_END_MODULE_GLOBALS(phar)
196196

197197
ZEND_EXTERN_MODULE_GLOBALS(phar)
198+
#define PHAR_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(phar, v)
198199

199-
#ifdef ZTS
200-
# include "TSRM.h"
201-
# ifdef COMPILE_DL_PHAR
200+
#if defined(ZTS) && defined(COMPILE_DL_PHAR)
202201
ZEND_TSRMLS_CACHE_EXTERN();
203-
# endif
204-
# define PHAR_G(v) ZEND_TSRMG(phar_globals_id, zend_phar_globals *, v)
205-
#else
206-
# define PHAR_G(v) (phar_globals.v)
207202
#endif
208203

209204
#ifndef php_uint16

ext/skeleton/php_skeleton.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,11 @@ ZEND_END_MODULE_GLOBALS(extname)
3434
You are encouraged to rename these macros something shorter, see
3535
examples in any other php module directory.
3636
*/
37+
#define EXTNAME_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(extname, v)
3738

38-
#ifdef ZTS
39-
#define EXTNAME_G(v) ZEND_TSRMG(extname_globals_id, zend_extname_globals *, v)
40-
#ifdef COMPILE_DL_EXTNAME
39+
#if defined(ZTS) && defined(COMPILE_DL_EXTNAME)
4140
ZEND_TSRMLS_CACHE_EXTERN();
4241
#endif
43-
#else
44-
#define EXTNAME_G(v) (extname_globals.v)
45-
#endif
4642

4743
#endif /* PHP_EXTNAME_H */
4844

ext/soap/php_soap.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,10 @@ extern zend_module_entry soap_module_entry;
189189
#define phpext_soap_ptr soap_module_ptr
190190

191191
ZEND_EXTERN_MODULE_GLOBALS(soap)
192+
#define SOAP_GLOBAL(v) ZEND_MODULE_GLOBALS_ACCESSOR(soap, v)
192193

193-
#ifdef ZTS
194-
# define SOAP_GLOBAL(v) ZEND_TSRMG(soap_globals_id, zend_soap_globals *, v)
195-
# ifdef COMPILE_DL_SOAP
194+
#if defined(ZTS) && defined(COMPILE_DL_SOAP)
196195
ZEND_TSRMLS_CACHE_EXTERN();
197-
# endif
198-
#else
199-
# define SOAP_GLOBAL(v) (soap_globals.v)
200196
#endif
201197

202198
extern zend_class_entry* soap_var_class_entry;

ext/sockets/php_sockets.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,8 @@ ZEND_BEGIN_MODULE_GLOBALS(sockets)
9292
char *strerror_buf;
9393
ZEND_END_MODULE_GLOBALS(sockets)
9494

95-
#ifdef ZTS
96-
#define SOCKETS_G(v) ZEND_TSRMG(sockets_globals_id, zend_sockets_globals *, v)
97-
#else
98-
#define SOCKETS_G(v) (sockets_globals.v)
99-
#endif
100-
10195
ZEND_EXTERN_MODULE_GLOBALS(sockets);
96+
#define SOCKETS_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(sockets, v)
10297

10398
enum sockopt_return {
10499
SOCKOPT_ERROR,

ext/standard/assert.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ ZEND_DECLARE_MODULE_GLOBALS(assert)
3939

4040
static zend_class_entry *assertion_error_ce;
4141

42-
#ifdef ZTS
43-
#define ASSERTG(v) ZEND_TSRMG(assert_globals_id, zend_assert_globals *, v)
44-
#else
45-
#define ASSERTG(v) (assert_globals.v)
46-
#endif
42+
#define ASSERTG(v) ZEND_MODULE_GLOBALS_ACCESSOR(assert, v)
4743

4844
#define SAFE_STRING(s) ((s)?(s):"")
4945

ext/standard/php_array.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,6 @@ ZEND_BEGIN_MODULE_GLOBALS(array)
129129
int (*compare_func)(zval *result, zval *op1, zval *op2);
130130
ZEND_END_MODULE_GLOBALS(array)
131131

132-
#ifdef ZTS
133-
#define ARRAYG(v) ZEND_TSRMG(array_globals_id, zend_array_globals *, v)
134-
#else
135-
#define ARRAYG(v) (array_globals.v)
136-
#endif
132+
#define ARRAYG(v) ZEND_MODULE_GLOBALS_ACCESSOR(array, v)
137133

138134
#endif /* PHP_ARRAY_H */

ext/tidy/php_tidy.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,11 @@ ZEND_BEGIN_MODULE_GLOBALS(tidy)
4242
zend_bool clean_output;
4343
ZEND_END_MODULE_GLOBALS(tidy)
4444

45-
#ifdef ZTS
46-
#define TG(v) ZEND_TSRMG(tidy_globals_id, zend_tidy_globals *, v)
47-
#ifdef COMPILE_DL_TIDY
45+
#define TG(v) ZEND_MODULE_GLOBALS_ACCESSOR(tidy, v)
46+
47+
#if defined(ZTS) && defined(COMPILE_DL_TIDY)
4848
ZEND_TSRMLS_CACHE_EXTERN();
4949
#endif
50-
#else
51-
#define TG(v) (tidy_globals.v)
52-
#endif
5350

5451
#endif
5552

0 commit comments

Comments
 (0)