Skip to content

Commit

Permalink
Fixed bug #81634 (ZEND_ENABLE_STATIC_TSRMLS_CACHE produces extensions…
Browse files Browse the repository at this point in the history
…with the STATIC_TLS flag)
  • Loading branch information
dstogov committed Nov 24, 2021
1 parent a2c0ffb commit 72f8dbb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions TSRM/TSRM.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ TSRM_API const char *tsrm_api_name(void);
#define TSRMG_BULK_STATIC(id, type) ((type) (*((void ***) TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(id)])
#define TSRMG_FAST_STATIC(offset, type, element) (TSRMG_FAST_BULK_STATIC(offset, type)->element)
#define TSRMG_FAST_BULK_STATIC(offset, type) ((type) (((char*) TSRMLS_CACHE)+(offset)))
#define TSRMLS_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR;
#define TSRMLS_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL;
#define TSRMLS_MAIN_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR;
#define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL;
#define TSRMLS_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE;
#define TSRMLS_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE = NULL;
#define TSRMLS_CACHE_UPDATE() TSRMLS_CACHE = tsrm_get_ls_cache()
#define TSRMLS_CACHE _tsrm_ls_cache

Expand All @@ -182,6 +184,8 @@ TSRM_API const char *tsrm_api_name(void);
#define tsrm_env_unlock()

#define TSRMG_STATIC(id, type, element)
#define TSRMLS_MAIN_CACHE_EXTERN()
#define TSRMLS_MAIN_CACHE_DEFINE()
#define TSRMLS_CACHE_EXTERN()
#define TSRMLS_CACHE_DEFINE()
#define TSRMLS_CACHE_UPDATE()
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static HashTable *global_class_table = NULL;
static HashTable *global_constants_table = NULL;
static HashTable *global_auto_globals_table = NULL;
static HashTable *global_persistent_list = NULL;
ZEND_TSRMLS_CACHE_DEFINE()
TSRMLS_MAIN_CACHE_DEFINE()
# define GLOBAL_FUNCTION_TABLE global_function_table
# define GLOBAL_CLASS_TABLE global_class_table
# define GLOBAL_CONSTANTS_TABLE global_constants_table
Expand Down
4 changes: 4 additions & 0 deletions Zend/zend.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@
#define ZEND_TSRMLS_CACHE
#endif

#ifndef ZEND_COMPILE_DL_EXT
TSRMLS_MAIN_CACHE_EXTERN()
#else
ZEND_TSRMLS_CACHE_EXTERN()
#endif

struct _zend_serialize_data;
struct _zend_unserialize_data;
Expand Down
2 changes: 1 addition & 1 deletion build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ dnl ---------------------------------------------- Static module
if test "$3" = "shared" || test "$3" = "yes"; then
dnl ---------------------------------------------- Shared module
[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]=yes
PHP_ADD_SOURCES_X($ext_dir,$2,$ac_extra,shared_objects_$1,yes)
PHP_ADD_SOURCES_X($ext_dir,$2,$ac_extra -DZEND_COMPILE_DL_EXT=1,shared_objects_$1,yes)
PHP_SHARED_MODULE($1,shared_objects_$1, $ext_builddir, $6, $7)
AC_DEFINE_UNQUOTED([COMPILE_DL_]translit($1,a-z_-,A-Z__), 1, Whether to build $1 as dynamic module)
fi
Expand Down
2 changes: 1 addition & 1 deletion win32/build/confutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)

if (shared) {
STDOUT.WriteLine("Enabling extension " + extname_for_printing + " [shared]");
cflags = "/D COMPILE_DL_" + EXT + " /D " + EXT + "_EXPORTS=1 " + cflags;
cflags = "/D ZEND_COMPILE_DL_EXT=1 /D COMPILE_DL_" + EXT + " /D " + EXT + "_EXPORTS=1 " + cflags;
ADD_FLAG("CFLAGS_PHP", "/D COMPILE_DL_" + EXT);
} else {
STDOUT.WriteLine("Enabling extension " + extname_for_printing);
Expand Down

0 comments on commit 72f8dbb

Please sign in to comment.