Skip to content

anonymous /__thread-tls.patch

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
__thread-tls.patch
Index: acinclude.m4
===================================================================
RCS file: /repository/php-src/acinclude.m4,v
retrieving revision 1.332.2.14.2.26.2.9
diff -u -p -r1.332.2.14.2.26.2.9 acinclude.m4
--- acinclude.m4 24 Jul 2008 14:17:54 -0000 1.332.2.14.2.26.2.9
+++ acinclude.m4 17 Aug 2008 00:29:46 -0000
@@ -2703,7 +2703,7 @@ AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
enable-libtool-lock | with-pic | with-tags | enable-shared | enable-static | enable-fast-install | with-gnu-ld[)];;
# Allow certain TSRM options
- with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads[)];;
+ with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads | with-tsrm-__thread-tls | with-tsrm-full-__thread-tls [)];;
# Allow certain Zend options
with-zend-vm | enable-maintainer-zts | enable-inline-optimization[)];;
Index: configure.in
===================================================================
RCS file: /repository/php-src/configure.in,v
retrieving revision 1.579.2.52.2.77.2.29
diff -u -p -r1.579.2.52.2.77.2.29 configure.in
--- configure.in 1 Aug 2008 00:46:20 -0000 1.579.2.52.2.77.2.29
+++ configure.in 17 Aug 2008 00:29:46 -0000
@@ -1088,6 +1088,7 @@ PHP_CONFIGURE_PART(Configuring TSRM)
TSRM_BASIC_CHECKS
if test "$PHP_THREAD_SAFETY" = "yes"; then
TSRM_THREADS_CHECKS
+ TSRM___THREAD_CHECKS
fi
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LDFLAGS"
Index: TSRM/TSRM.c
===================================================================
RCS file: /repository/TSRM/TSRM.c,v
retrieving revision 1.68.2.3.2.1.2.2
diff -u -p -r1.68.2.3.2.1.2.2 TSRM.c
--- TSRM/TSRM.c 7 Feb 2008 09:06:45 -0000 1.68.2.3.2.1.2.2
+++ TSRM/TSRM.c 17 Aug 2008 00:29:46 -0000
@@ -32,6 +32,7 @@ struct _tsrm_tls_entry {
typedef struct {
size_t size;
+ ts_allocate_bind bind;
ts_allocate_ctor ctor;
ts_allocate_dtor dtor;
int done;
@@ -61,6 +62,33 @@ int tsrm_error(int level, const char *fo
static int tsrm_error_level;
static FILE *tsrm_error_file;
+#define TSRMG_MALLOC(size) malloc(size)
+#define TSRMG_FREE(tsrmg) free(tsrmg)
+
+#ifdef HAVE___THREAD
+TSRM_API __thread void ***tsrm_ls_cache = 0;
+#endif
+
+#ifdef PASS_TSRMLS
+# define CALL_TSRMG_CTOR(ctor, globale, storage) (ctor)((globale), (storage))
+# define CALL_TSRMG_DTOR(ctor, globale, storage) (ctor)((globale), (storage))
+# define CALL_NEW_THREAD_BEGIN_HANDLER(thread_id, storage) tsrm_new_thread_begin_handler((thread_id), (storage))
+# define CALL_NEW_THREAD_END_HANDLER(thread_id, storage) tsrm_new_thread_end_handler((thread_id), (storage))
+#else
+# define CALL_TSRMG_CTOR(ctor, globale, storage) (ctor)((globale))
+# define CALL_TSRMG_DTOR(ctor, globale, storage) (ctor)((globale))
+# define CALL_NEW_THREAD_BEGIN_HANDLER(thread_id, storage) tsrm_new_thread_begin_handler((thread_id))
+# define CALL_NEW_THREAD_END_HANDLER(thread_id, storage) tsrm_new_thread_end_handler((thread_id))
+#endif
+
+#ifdef USE_FULL___THREAD
+# undef TSRMG_MALLOC
+# define TSRMG_MALLOC(size) NULL
+# undef TSRMG_FREE
+# define TSRMG_FREE(tsrmg)
+#endif
+
+
#if TSRM_DEBUG
#define TSRM_ERROR(args) tsrm_error args
#define TSRM_SAFE_RETURN_RSRC(array, offset, range) \
@@ -177,9 +205,9 @@ TSRM_API void tsrm_shutdown(void)
for (j=0; j<p->count; j++) {
if (p->storage[j]) {
if (resource_types_table && !resource_types_table[j].done && resource_types_table[j].dtor) {
- resource_types_table[j].dtor(p->storage[j], &p->storage);
+ CALL_TSRMG_CTOR(resource_types_table[j].dtor, p->storage[j], &p->storage);
}
- free(p->storage[j]);
+ TSRMG_FREE(p->storage[j]);
}
}
free(p->storage);
@@ -212,7 +240,7 @@ TSRM_API void tsrm_shutdown(void)
/* allocates a new thread-safe-resource id */
-TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
+TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate_bind bind, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
{
int i;
@@ -236,6 +264,7 @@ TSRM_API ts_rsrc_id ts_allocate_id(ts_rs
resource_types_table_size = id_count;
}
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].size = size;
+ resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].bind = bind;
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].ctor = ctor;
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].dtor = dtor;
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].done = 0;
@@ -250,9 +279,12 @@ TSRM_API ts_rsrc_id ts_allocate_id(ts_rs
p->storage = (void *) realloc(p->storage, sizeof(void *)*id_count);
for (j=p->count; j<id_count; j++) {
- p->storage[j] = (void *) malloc(resource_types_table[j].size);
+ p->storage[j] = (void *) TSRMG_MALLOC(resource_types_table[j].size);
+ if (resource_types_table[j].bind) {
+ resource_types_table[j].bind(&p->storage[j]);
+ }
if (resource_types_table[j].ctor) {
- resource_types_table[j].ctor(p->storage[j], &p->storage);
+ CALL_TSRMG_CTOR(resource_types_table[j].ctor, p->storage[j], &p->storage);
}
}
p->count = id_count;
@@ -282,22 +314,25 @@ static void allocate_new_resource(tsrm_t
tsrm_tls_set(*thread_resources_ptr);
if (tsrm_new_thread_begin_handler) {
- tsrm_new_thread_begin_handler(thread_id, &((*thread_resources_ptr)->storage));
+ CALL_NEW_THREAD_BEGIN_HANDLER(thread_id, &((*thread_resources_ptr)->storage));
}
for (i=0; i<id_count; i++) {
if (resource_types_table[i].done) {
(*thread_resources_ptr)->storage[i] = NULL;
} else
{
- (*thread_resources_ptr)->storage[i] = (void *) malloc(resource_types_table[i].size);
+ (*thread_resources_ptr)->storage[i] = (void *) TSRMG_MALLOC(resource_types_table[i].size);
+ if (resource_types_table[i].bind) {
+ resource_types_table[i].bind(&((*thread_resources_ptr)->storage[i]));
+ }
if (resource_types_table[i].ctor) {
- resource_types_table[i].ctor((*thread_resources_ptr)->storage[i], &(*thread_resources_ptr)->storage);
+ CALL_TSRMG_CTOR(resource_types_table[i].ctor, (*thread_resources_ptr)->storage[i], &(*thread_resources_ptr)->storage);
}
}
}
if (tsrm_new_thread_end_handler) {
- tsrm_new_thread_end_handler(thread_id, &((*thread_resources_ptr)->storage));
+ CALL_NEW_THREAD_END_HANDLER(thread_id, &((*thread_resources_ptr)->storage));
}
tsrm_mutex_unlock(tsmm_mutex);
@@ -390,11 +425,11 @@ void tsrm_free_interpreter_context(void
for (i=0; i<thread_resources->count; i++) {
if (resource_types_table[i].dtor) {
- resource_types_table[i].dtor(thread_resources->storage[i], &thread_resources->storage);
+ CALL_TSRMG_DTOR(resource_types_table[i].dtor, thread_resources->storage[i], &thread_resources->storage);
}
}
for (i=0; i<thread_resources->count; i++) {
- free(thread_resources->storage[i]);
+ TSRMG_FREE(thread_resources->storage[i]);
}
free(thread_resources->storage);
free(thread_resources);
@@ -455,11 +490,11 @@ void ts_free_thread(void)
if (thread_resources->thread_id == thread_id) {
for (i=0; i<thread_resources->count; i++) {
if (resource_types_table[i].dtor) {
- resource_types_table[i].dtor(thread_resources->storage[i], &thread_resources->storage);
+ CALL_TSRMG_DTOR(resource_types_table[i].dtor, thread_resources->storage[i], &thread_resources->storage);
}
}
for (i=0; i<thread_resources->count; i++) {
- free(thread_resources->storage[i]);
+ TSRMG_FREE(thread_resources->storage[i]);
}
free(thread_resources->storage);
if (last) {
@@ -497,11 +532,11 @@ void ts_free_worker_threads(void)
if (thread_resources->thread_id != thread_id) {
for (i=0; i<thread_resources->count; i++) {
if (resource_types_table[i].dtor) {
- resource_types_table[i].dtor(thread_resources->storage[i], &thread_resources->storage);
+ CALL_TSRMG_DTOR(resource_types_table[i].dtor, thread_resources->storage[i], &thread_resources->storage);
}
}
for (i=0; i<thread_resources->count; i++) {
- free(thread_resources->storage[i]);
+ TSRMG_FREE(thread_resources->storage[i]);
}
free(thread_resources->storage);
if (last) {
@@ -543,9 +578,9 @@ void ts_free_id(ts_rsrc_id id)
while (p) {
if (p->count > j && p->storage[j]) {
if (resource_types_table && resource_types_table[j].dtor) {
- resource_types_table[j].dtor(p->storage[j], &p->storage);
+ CALL_TSRMG_DTOR(resource_types_table[j].dtor, p->storage[j], &p->storage);
}
- free(p->storage[j]);
+ TSRMG_FREE(p->storage[j]);
p->storage[j] = NULL;
}
p = p->next;
Index: TSRM/TSRM.h
===================================================================
RCS file: /repository/TSRM/TSRM.h,v
retrieving revision 1.50.2.2.2.4.2.2
diff -u -p -r1.50.2.2.2.4.2.2 TSRM.h
--- TSRM/TSRM.h 30 Jan 2008 09:41:11 -0000 1.50.2.2.2.4.2.2
+++ TSRM/TSRM.h 17 Aug 2008 00:29:46 -0000
@@ -90,21 +90,92 @@ typedef struct {
# define MUTEX_T beos_ben *
#endif
-typedef void (*ts_allocate_ctor)(void *, void ***);
-typedef void (*ts_allocate_dtor)(void *, void ***);
-
#define THREAD_HASH_OF(thr,ts) (unsigned long)thr%(unsigned long)ts
#ifdef __cplusplus
extern "C" {
#endif
+#ifdef USE___THREAD
+
+TSRM_API extern __thread void ***tsrm_ls_cache;
+
+#ifdef USE_FULL___THREAD
+# define TSRMG_PTR
+# define TSRMG_BIND(id) *ptr = &id##_cache
+# define TSRMG(id, type, element) (id##_cache.element)
+#else
+# define TSRMG_PTR *
+# define TSRMG_BIND(id) id##_cache = *ptr
+# define TSRMG(id, type, element) (id##_cache->element)
+#endif
+
+#define TSRMG_DH(type, id) \
+ TSRM_API extern ts_rsrc_id id; \
+ TSRM_API extern __thread type TSRMG_PTR id##_cache; \
+ TSRMG_BF(id);
+
+#define TSRMG_D(type, id) \
+ TSRM_API ts_rsrc_id id; \
+ TSRM_API __thread type TSRMG_PTR id##_cache; \
+ TSRMG_BF(id) { \
+ TSRMG_BIND(id); \
+ }
+#define TSRMG_BFN(id) tsrmg_bf_##id
+#define TSRMG_BF(id) TSRM_API void TSRMG_BFN(id)(void **ptr)
+
+#define TSRMG_ALLOCATE(id, size, ctor, dtor) \
+ TSRMG_ALLOCATE_EX(id, size, TSRMG_BFN(id), ctor, dtor);
+
+#define TSRMLS_INIT() ts_resource_ex(0, NULL);
+#define TSRMLS_FETCH()
+#define TSRMLS_FETCH_FROM_CTX(ctx)
+#define TSRMLS_SET_CTX(ctx)
+#define TSRMLS_D void
+#define TSRMLS_DC
+#define TSRMLS_C
+#define TSRMLS_CC
+
+#else /* USE___THREAD */
+
+#define TSRMG_DH(type, id) \
+ TSRM_API extern ts_rsrc_id id;
+
+#define TSRMG_D(type, id) \
+ TSRM_API ts_rsrc_id id;
+
+#define TSRMLS_INIT() TSRMLS_FETCH()
+#define TSRMLS_FETCH() void ***tsrm_ls = (void ***) ts_resource_ex(0, NULL);
+#define TSRMG(id, type, element) (((type) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(id)])->element)
+#define TSRMG_ALLOCATE(id, size, ctor, dtor) \
+ TSRMG_ALLOCATE_EX(id, size, NULL, ctor, dtor);
+
+#define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = (void ***) ctx
+#define TSRMLS_SET_CTX(ctx) ctx = (void ***) tsrm_ls
+#define TSRMLS_D void ***tsrm_ls
+#define TSRMLS_DC , TSRMLS_D
+#define TSRMLS_C tsrm_ls
+#define TSRMLS_CC , TSRMLS_C
+#define PASS_TSRMLS 1
+
+#endif /* USE___THREAD */
+
+#define TSRMG_ALLOCATE_EX(id, size, bind, ctor, dtor) \
+ ts_allocate_id(&(id), (size), (bind), (ctor), (dtor));
+
+#define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1)
+#define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1)
+
+typedef void (*ts_allocate_ctor)(void * TSRMLS_DC);
+typedef void (*ts_allocate_dtor)(void * TSRMLS_DC);
+typedef void (*ts_allocate_bind)(void **);
+
/* startup/shutdown */
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename);
TSRM_API void tsrm_shutdown(void);
/* allocates a new thread-safe-resource id */
-TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor);
+TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate_bind bind, ts_allocate_ctor ctor, ts_allocate_dtor dtor);
/* fetches the requested resource for the current thread */
TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id);
@@ -125,8 +196,8 @@ TSRM_API void ts_free_id(ts_rsrc_id id);
#define TSRM_ERROR_LEVEL_CORE 2
#define TSRM_ERROR_LEVEL_INFO 3
-typedef void (*tsrm_thread_begin_func_t)(THREAD_T thread_id, void ***tsrm_ls);
-typedef void (*tsrm_thread_end_func_t)(THREAD_T thread_id, void ***tsrm_ls);
+typedef void (*tsrm_thread_begin_func_t)(THREAD_T thread_id TSRMLS_DC);
+typedef void (*tsrm_thread_end_func_t)(THREAD_T thread_id TSRMLS_DC);
TSRM_API int tsrm_error(int level, const char *format, ...);
@@ -148,24 +219,13 @@ TSRM_API void *tsrm_new_interpreter_cont
TSRM_API void *tsrm_set_interpreter_context(void *new_ctx);
TSRM_API void tsrm_free_interpreter_context(void *context);
-#define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1)
-#define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1)
-
-#define TSRMLS_FETCH() void ***tsrm_ls = (void ***) ts_resource_ex(0, NULL)
-#define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = (void ***) ctx
-#define TSRMLS_SET_CTX(ctx) ctx = (void ***) tsrm_ls
-#define TSRMG(id, type, element) (((type) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(id)])->element)
-#define TSRMLS_D void ***tsrm_ls
-#define TSRMLS_DC , TSRMLS_D
-#define TSRMLS_C tsrm_ls
-#define TSRMLS_CC , TSRMLS_C
-
#ifdef __cplusplus
}
#endif
#else /* non ZTS */
+#define TSRMLS_INIT()
#define TSRMLS_FETCH()
#define TSRMLS_FETCH_FROM_CTX(ctx)
#define TSRMLS_SET_CTX(ctx)
Index: TSRM/configure.in
===================================================================
RCS file: /repository/TSRM/configure.in,v
retrieving revision 1.17
diff -u -p -r1.17 configure.in
--- TSRM/configure.in 8 Aug 2001 10:26:21 -0000 1.17
+++ TSRM/configure.in 17 Aug 2008 00:29:46 -0000
@@ -11,6 +11,7 @@ sinclude(tsrm.m4)
TSRM_BASIC_CHECKS
TSRM_THREADS_CHECKS
+TSRM___THREADS_CHECKS
AM_PROG_LIBTOOL
if test "$enable_debug" != "yes"; then
Index: TSRM/tsrm.m4
===================================================================
RCS file: /repository/TSRM/tsrm.m4,v
retrieving revision 1.17.4.1
diff -u -p -r1.17.4.1 tsrm.m4
--- TSRM/tsrm.m4 22 Aug 2006 13:01:44 -0000 1.17.4.1
+++ TSRM/tsrm.m4 17 Aug 2008 00:29:46 -0000
@@ -21,6 +21,57 @@ AC_DEFUN([TSRM_CHECK_GCC_ARG],[
fi
])
+AC_DEFUN([TSRM___THREAD_CHECKS],[
+
+ AC_ARG_WITH(tsrm-__thread-tls,
+ [ --with-tsrm-__thread-tls
+ Use __thread TLS],[
+ USE___THREAD=yes
+ ],[
+ USE___THREAD=no
+ ])
+
+ AC_ARG_WITH(tsrm-full-__thread-tls,
+ [ --with-tsrm-full-__thread-tls
+ Use full __thread TLS],[
+ USE_FULL___THREAD=yes
+ ],[
+ USE_FULL___THREAD=no
+ ])
+
+ if test $USE___THREAD = yes || test $USE_FULL___THREAD = yes; then
+ AC_MSG_CHECKING(for __thread specifier)
+ AC_TRY_RUN([
+ __thread int foo = 42;
+ int main() {
+ return foo - 42;
+ }
+ ],[
+ AC_DEFINE(HAVE___THREAD, 1, [Wether the __thread specifier is supported])
+ AC_MSG_RESULT(yes)
+ HAVE___THREAD=yes
+ ],[
+ AC_MSG_RESULT(no)
+ HAVE___THREAD=no
+ ])
+
+ AC_MSG_CHECKING(wether to enable __thread TLS)
+ if ! test $HAVE___THREAD = yes; then
+ AC_MSG_ERROR([__thread TLS not available])
+ fi
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(USE___THREAD, 1, [wether to use __thread TLS])
+
+ AC_MSG_CHECKING(Wether to enable full __thread TLS)
+ if test $USE_FULL___THREAD = yes; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(USE_FULL___THREAD, 1, [Wether to use full __thread TLS])
+ else
+ AC_MSG_RESULT(no)
+ fi
+ fi
+])
+
AC_DEFUN([TSRM_BASIC_CHECKS],[
AC_REQUIRE([AC_PROG_CC])dnl
Index: TSRM/tsrm_virtual_cwd.c
===================================================================
RCS file: /repository/TSRM/tsrm_virtual_cwd.c,v
retrieving revision 1.74.2.9.2.35.2.10
diff -u -p -r1.74.2.9.2.35.2.10 tsrm_virtual_cwd.c
--- TSRM/tsrm_virtual_cwd.c 15 Aug 2008 15:00:11 -0000 1.74.2.9.2.35.2.10
+++ TSRM/tsrm_virtual_cwd.c 17 Aug 2008 00:29:46 -0000
@@ -55,7 +55,7 @@ MUTEX_T cwd_mutex;
#endif
#ifdef ZTS
-ts_rsrc_id cwd_globals_id;
+TSRMG_D(virtual_cwd_globals, cwd_globals_id);
#else
virtual_cwd_globals cwd_globals;
#endif
@@ -311,7 +311,7 @@ CWD_API void virtual_cwd_startup(void) /
main_cwd_state.cwd = strdup(cwd);
#ifdef ZTS
- ts_allocate_id(&cwd_globals_id, sizeof(virtual_cwd_globals), (ts_allocate_ctor) cwd_globals_ctor, (ts_allocate_dtor) cwd_globals_dtor);
+ TSRMG_ALLOCATE(cwd_globals_id, sizeof(virtual_cwd_globals), (ts_allocate_ctor) cwd_globals_ctor, (ts_allocate_dtor) cwd_globals_dtor);
#else
cwd_globals_ctor(&cwd_globals TSRMLS_CC);
#endif
Index: TSRM/tsrm_virtual_cwd.h
===================================================================
RCS file: /repository/TSRM/tsrm_virtual_cwd.h,v
retrieving revision 1.48.2.5.2.8.2.5
diff -u -p -r1.48.2.5.2.8.2.5 tsrm_virtual_cwd.h
--- TSRM/tsrm_virtual_cwd.h 12 Aug 2008 08:01:24 -0000 1.48.2.5.2.8.2.5
+++ TSRM/tsrm_virtual_cwd.h 17 Aug 2008 00:29:46 -0000
@@ -222,7 +222,7 @@ typedef struct _virtual_cwd_globals {
} virtual_cwd_globals;
#ifdef ZTS
-extern ts_rsrc_id cwd_globals_id;
+TSRMG_DH(virtual_cwd_globals, cwd_globals_id);
# define CWDG(v) TSRMG(cwd_globals_id, virtual_cwd_globals *, v)
#else
extern virtual_cwd_globals cwd_globals;
Index: TSRM/tsrm_win32.c
===================================================================
RCS file: /repository/TSRM/tsrm_win32.c,v
retrieving revision 1.27.2.1.2.7.2.2
diff -u -p -r1.27.2.1.2.7.2.2 tsrm_win32.c
--- TSRM/tsrm_win32.c 29 May 2008 11:31:02 -0000 1.27.2.1.2.7.2.2
+++ TSRM/tsrm_win32.c 17 Aug 2008 00:29:46 -0000
@@ -71,7 +71,7 @@ static void tsrm_win32_dtor(tsrm_win32_g
TSRM_API void tsrm_win32_startup(void)
{
#ifdef ZTS
- ts_allocate_id(&win32_globals_id, sizeof(tsrm_win32_globals), (ts_allocate_ctor)tsrm_win32_ctor, (ts_allocate_ctor)tsrm_win32_dtor);
+ TSRMG_ALLOCATE(win32_globals_id, sizeof(tsrm_win32_globals), (ts_allocate_ctor)tsrm_win32_ctor, (ts_allocate_dtor)tsrm_win32_dtor);
#else
tsrm_win32_ctor(&win32_globals TSRMLS_CC);
#endif
Index: Zend/zend.c
===================================================================
RCS file: /repository/ZendEngine2/zend.c,v
retrieving revision 1.308.2.12.2.35.2.23
diff -u -p -r1.308.2.12.2.35.2.23 zend.c
--- Zend/zend.c 15 Aug 2008 19:47:23 -0000 1.308.2.12.2.35.2.23
+++ Zend/zend.c 17 Aug 2008 00:29:47 -0000
@@ -98,8 +98,8 @@ ZEND_INI_END()
#ifdef ZTS
-ZEND_API int compiler_globals_id;
-ZEND_API int executor_globals_id;
+TSRMG_D(zend_compiler_globals, compiler_globals_id);
+TSRMG_D(zend_executor_globals, executor_globals_id);
static HashTable *global_function_table = NULL;
static HashTable *global_class_table = NULL;
static HashTable *global_constants_table = NULL;
@@ -606,8 +606,8 @@ int zend_startup(zend_utility_functions
#ifdef ZTS
zend_compiler_globals *compiler_globals;
zend_executor_globals *executor_globals;
- extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
- extern ZEND_API ts_rsrc_id language_scanner_globals_id;
+ TSRMG_DH(zend_ini_scanner_globals, ini_scanner_globals_id);
+ TSRMG_DH(zend_php_scanner_globals, language_scanner_globals_id);
#else
extern zend_ini_scanner_globals ini_scanner_globals;
extern zend_php_scanner_globals language_scanner_globals;
@@ -673,10 +673,10 @@ int zend_startup(zend_utility_functions
Z_TYPE(zval_used_for_init) = IS_NULL;
#ifdef ZTS
- ts_allocate_id(&compiler_globals_id, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
- ts_allocate_id(&executor_globals_id, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
- ts_allocate_id(&language_scanner_globals_id, sizeof(zend_php_scanner_globals), (ts_allocate_ctor) php_scanner_globals_ctor, NULL);
- ts_allocate_id(&ini_scanner_globals_id, sizeof(zend_ini_scanner_globals), (ts_allocate_ctor) ini_scanner_globals_ctor, NULL);
+ TSRMG_ALLOCATE(compiler_globals_id, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
+ TSRMG_ALLOCATE(executor_globals_id, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
+ TSRMG_ALLOCATE(language_scanner_globals_id, sizeof(zend_php_scanner_globals), (ts_allocate_ctor) php_scanner_globals_ctor, NULL);
+ TSRMG_ALLOCATE(ini_scanner_globals_id, sizeof(zend_ini_scanner_globals), (ts_allocate_ctor) ini_scanner_globals_ctor, NULL);
compiler_globals = ts_resource(compiler_globals_id);
executor_globals = ts_resource(executor_globals_id);
@@ -750,9 +750,9 @@ void zend_post_startup(TSRMLS_D) /* {{{
zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
free(compiler_globals->function_table);
free(compiler_globals->class_table);
- compiler_globals_ctor(compiler_globals, tsrm_ls);
+ compiler_globals_ctor(compiler_globals TSRMLS_CC);
free(EG(zend_constants));
- executor_globals_ctor(executor_globals, tsrm_ls);
+ executor_globals_ctor(executor_globals TSRMLS_CC);
global_persistent_list = &EG(persistent_list);
zend_copy_ini_directives(TSRMLS_C);
#endif
Index: Zend/zend_API.c
===================================================================
RCS file: /repository/ZendEngine2/zend_API.c,v
retrieving revision 1.296.2.27.2.34.2.52
diff -u -p -r1.296.2.27.2.34.2.52 zend_API.c
--- Zend/zend_API.c 14 Aug 2008 21:36:56 -0000 1.296.2.27.2.34.2.52
+++ Zend/zend_API.c 17 Aug 2008 00:29:47 -0000
@@ -1574,7 +1574,7 @@ ZEND_API int zend_startup_module_ex(zend
/* Initialize module globals */
if (module->globals_size) {
#ifdef ZTS
- ts_allocate_id(module->globals_id_ptr, module->globals_size, (ts_allocate_ctor) module->globals_ctor, (ts_allocate_dtor) module->globals_dtor);
+ TSRMG_ALLOCATE_EX((*module->globals_id_ptr), module->globals_size, module->globals_bind, module->globals_ctor, module->globals_dtor);
#else
if (module->globals_ctor) {
module->globals_ctor(module->globals_ptr TSRMLS_CC);
Index: Zend/zend_API.h
===================================================================
RCS file: /repository/ZendEngine2/zend_API.h,v
retrieving revision 1.207.2.8.2.8.2.18
diff -u -p -r1.207.2.8.2.8.2.18 zend_API.h
--- Zend/zend_API.h 12 Aug 2008 21:45:52 -0000 1.207.2.8.2.8.2.18
+++ Zend/zend_API.h 17 Aug 2008 00:29:47 -0000
@@ -140,11 +140,11 @@ typedef struct _zend_fcall_info_cache {
#ifdef ZTS
#define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
- ts_rsrc_id module_name##_globals_id;
+ TSRMG_D(zend_##module_name##_globals, module_name##_globals_id);
#define ZEND_EXTERN_MODULE_GLOBALS(module_name) \
- extern ts_rsrc_id module_name##_globals_id;
+ TSRMG_DH(zend_##module_name##_globals, module_name##_globals_id);
#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
- ts_allocate_id(&module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
+ TSRMG_ALLOCATE(module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
#else
Index: Zend/zend_alloc.c
===================================================================
RCS file: /repository/ZendEngine2/zend_alloc.c,v
retrieving revision 1.144.2.3.2.43.2.16
diff -u -p -r1.144.2.3.2.43.2.16 zend_alloc.c
--- Zend/zend_alloc.c 15 Aug 2008 19:47:23 -0000 1.144.2.3.2.43.2.16
+++ Zend/zend_alloc.c 17 Aug 2008 00:29:48 -0000
@@ -2265,7 +2265,7 @@ typedef struct _zend_alloc_globals {
} zend_alloc_globals;
#ifdef ZTS
-static int alloc_globals_id;
+TSRMG_D(zend_alloc_globals, alloc_globals_id);
# define AG(v) TSRMG(alloc_globals_id, zend_alloc_globals *, v)
#else
# define AG(v) (alloc_globals.v)
@@ -2521,7 +2521,7 @@ static void alloc_globals_dtor(zend_allo
ZEND_API void start_memory_manager(TSRMLS_D)
{
#ifdef ZTS
- ts_allocate_id(&alloc_globals_id, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor);
+ TSRMG_ALLOCATE(alloc_globals_id, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor);
#else
alloc_globals_ctor(&alloc_globals);
#endif
Index: Zend/zend_compile.c
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.c,v
retrieving revision 1.647.2.27.2.41.2.82
diff -u -p -r1.647.2.27.2.41.2.82 zend_compile.c
--- Zend/zend_compile.c 12 Aug 2008 17:20:24 -0000 1.647.2.27.2.41.2.82
+++ Zend/zend_compile.c 17 Aug 2008 00:29:48 -0000
@@ -2197,7 +2197,7 @@ void zend_do_return(znode *expr, int do_
start_op_number = get_next_op_number(CG(active_op_array));
-#ifdef ZTS
+#ifdef PASS_TSRMLS
zend_stack_apply_with_argument(&CG(switch_cond_stack), ZEND_STACK_APPLY_TOPDOWN, (int (*)(void *element, void *)) generate_free_switch_expr TSRMLS_CC);
zend_stack_apply_with_argument(&CG(foreach_copy_stack), ZEND_STACK_APPLY_TOPDOWN, (int (*)(void *element, void *)) generate_free_foreach_copy TSRMLS_CC);
#else
Index: Zend/zend_gc.c
===================================================================
RCS file: /repository/ZendEngine2/zend_gc.c,v
retrieving revision 1.1.2.16
diff -u -p -r1.1.2.16 zend_gc.c
--- Zend/zend_gc.c 15 Aug 2008 19:47:24 -0000 1.1.2.16
+++ Zend/zend_gc.c 17 Aug 2008 00:29:48 -0000
@@ -25,7 +25,7 @@
#define GC_ROOT_BUFFER_MAX_ENTRIES 10000
#ifdef ZTS
-ZEND_API int gc_globals_id;
+TSRMG_D(zend_gc_globals, gc_globals_id);
#else
ZEND_API zend_gc_globals gc_globals;
#endif
@@ -78,7 +78,7 @@ static void gc_globals_ctor_ex(zend_gc_g
ZEND_API void gc_globals_ctor(TSRMLS_D)
{
#ifdef ZTS
- ts_allocate_id(&gc_globals_id, sizeof(zend_gc_globals), (ts_allocate_ctor) gc_globals_ctor_ex, (ts_allocate_dtor) root_buffer_dtor);
+ TSRMG_ALLOCATE(gc_globals_id, sizeof(zend_gc_globals), (ts_allocate_ctor) gc_globals_ctor_ex, (ts_allocate_dtor) root_buffer_dtor);
#else
gc_globals_ctor_ex(&gc_globals);
#endif
Index: Zend/zend_gc.h
===================================================================
RCS file: /repository/ZendEngine2/zend_gc.h,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 zend_gc.h
--- Zend/zend_gc.h 15 Aug 2008 19:47:24 -0000 1.1.2.8
+++ Zend/zend_gc.h 17 Aug 2008 00:29:48 -0000
@@ -130,7 +130,7 @@ typedef struct _zend_gc_globals {
#ifdef ZTS
BEGIN_EXTERN_C()
-ZEND_API extern int gc_globals_id;
+TSRMG_DH(zend_gc_globals, gc_globals_id);
END_EXTERN_C()
#define GC_G(v) TSRMG(gc_globals_id, zend_gc_globals *, v)
#else
Index: Zend/zend_globals.h
===================================================================
RCS file: /repository/ZendEngine2/zend_globals.h,v
retrieving revision 1.141.2.3.2.7.2.19
diff -u -p -r1.141.2.3.2.7.2.19 zend_globals.h
--- Zend/zend_globals.h 14 Aug 2008 10:24:51 -0000 1.141.2.3.2.7.2.19
+++ Zend/zend_globals.h 17 Aug 2008 00:29:48 -0000
@@ -45,8 +45,8 @@
#ifdef ZTS
BEGIN_EXTERN_C()
-ZEND_API extern int compiler_globals_id;
-ZEND_API extern int executor_globals_id;
+TSRMG_DH(zend_compiler_globals, compiler_globals_id);
+TSRMG_DH(zend_executor_globals, executor_globals_id);
END_EXTERN_C()
#endif
Index: Zend/zend_globals_macros.h
===================================================================
RCS file: /repository/ZendEngine2/zend_globals_macros.h,v
retrieving revision 1.22.2.1.2.4.2.2
diff -u -p -r1.22.2.1.2.4.2.2 zend_globals_macros.h
--- Zend/zend_globals_macros.h 16 Mar 2008 21:05:33 -0000 1.22.2.1.2.4.2.2
+++ Zend/zend_globals_macros.h 17 Aug 2008 00:29:48 -0000
@@ -32,10 +32,13 @@ BEGIN_EXTERN_C()
/* Compiler */
#ifdef ZTS
# define CG(v) TSRMG(compiler_globals_id, zend_compiler_globals *, v)
-int zendparse(void *compiler_globals);
#else
# define CG(v) (compiler_globals.v)
extern ZEND_API struct _zend_compiler_globals compiler_globals;
+#endif
+#ifdef PASS_TSRMLS
+int zendparse(void *compiler_globals);
+#else
int zendparse(void);
#endif
@@ -51,7 +54,7 @@ extern ZEND_API zend_executor_globals ex
/* Language Scanner */
#ifdef ZTS
# define LANG_SCNG(v) TSRMG(language_scanner_globals_id, zend_php_scanner_globals *, v)
-extern ZEND_API ts_rsrc_id language_scanner_globals_id;
+TSRMG_DH(zend_php_scanner_globals, language_scanner_globals_id);
#else
# define LANG_SCNG(v) (language_scanner_globals.v)
extern ZEND_API zend_php_scanner_globals language_scanner_globals;
@@ -61,7 +64,7 @@ extern ZEND_API zend_php_scanner_globals
/* INI Scanner */
#ifdef ZTS
# define INI_SCNG(v) TSRMG(ini_scanner_globals_id, zend_ini_scanner_globals *, v)
-extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
+TSRMG_DH(zend_ini_scanner_globals, ini_scanner_globals_id);
#else
# define INI_SCNG(v) (ini_scanner_globals.v)
extern ZEND_API zend_ini_scanner_globals ini_scanner_globals;
Index: Zend/zend_ini_parser.y
===================================================================
RCS file: /repository/ZendEngine2/zend_ini_parser.y,v
retrieving revision 1.41.2.2.2.2.2.5
diff -u -p -r1.41.2.2.2.2.2.5 zend_ini_parser.y
--- Zend/zend_ini_parser.y 16 Mar 2008 21:05:33 -0000 1.41.2.2.2.2.2.5
+++ Zend/zend_ini_parser.y 17 Aug 2008 00:29:48 -0000
@@ -32,7 +32,7 @@
#define YYERROR_VERBOSE
#define YYSTYPE zval
-#ifdef ZTS
+#ifdef PASS_TSRMLS
#define YYPARSE_PARAM tsrm_ls
#define YYLEX_PARAM tsrm_ls
int ini_parse(void *arg);
Index: Zend/zend_ini_scanner.l
===================================================================
RCS file: /repository/ZendEngine2/zend_ini_scanner.l,v
retrieving revision 1.41.2.2.2.2.2.8
diff -u -p -r1.41.2.2.2.2.2.8 zend_ini_scanner.l
--- Zend/zend_ini_scanner.l 7 Aug 2008 12:22:00 -0000 1.41.2.2.2.2.2.8
+++ Zend/zend_ini_scanner.l 17 Aug 2008 00:29:49 -0000
@@ -96,7 +96,7 @@
/* Globals Macros */
#define SCNG INI_SCNG
#ifdef ZTS
-ZEND_API ts_rsrc_id ini_scanner_globals_id;
+TSRMG_D(zend_ini_scanner_globals, ini_scanner_globals_id);
#else
ZEND_API zend_ini_scanner_globals ini_scanner_globals;
#endif
Index: Zend/zend_language_parser.y
===================================================================
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.160.2.4.2.8.2.25
diff -u -p -r1.160.2.4.2.8.2.25 zend_language_parser.y
--- Zend/zend_language_parser.y 12 Aug 2008 10:23:02 -0000 1.160.2.4.2.8.2.25
+++ Zend/zend_language_parser.y 17 Aug 2008 00:29:49 -0000
@@ -38,7 +38,7 @@
#define YYERROR_VERBOSE
#define YYSTYPE znode
-#ifdef ZTS
+#ifdef PASS_TSRMLS
# define YYPARSE_PARAM tsrm_ls
# define YYLEX_PARAM tsrm_ls
#endif
Index: Zend/zend_modules.h
===================================================================
RCS file: /repository/ZendEngine2/zend_modules.h,v
retrieving revision 1.67.2.3.2.4.2.6
diff -u -p -r1.67.2.3.2.4.2.6 zend_modules.h
--- Zend/zend_modules.h 12 Aug 2008 17:20:24 -0000 1.67.2.3.2.4.2.6
+++ Zend/zend_modules.h 17 Aug 2008 00:29:49 -0000
@@ -50,7 +50,11 @@
#define NO_MODULE_GLOBALS 0, NULL, NULL, NULL
#ifdef ZTS
-# define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals_id
+# ifdef USE___THREAD
+# define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals_id, TSRMG_BFN(module_name##_globals_id)
+# else
+# define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals_id, NULL
+# endif
#else
# define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals
#endif
@@ -85,6 +89,7 @@ struct _zend_module_entry {
size_t globals_size;
#ifdef ZTS
ts_rsrc_id* globals_id_ptr;
+ ts_allocate_bind globals_bind;
#else
void* globals_ptr;
#endif
Index: ext/standard/basic_functions.c
===================================================================
RCS file: /repository/php-src/ext/standard/basic_functions.c,v
retrieving revision 1.725.2.31.2.64.2.52
diff -u -p -r1.725.2.31.2.64.2.52 basic_functions.c
--- ext/standard/basic_functions.c 16 Aug 2008 11:11:46 -0000 1.725.2.31.2.64.2.52
+++ ext/standard/basic_functions.c 17 Aug 2008 00:29:51 -0000
@@ -105,7 +105,7 @@ typedef struct yy_buffer_state *YY_BUFFE
#include "php_ticks.h"
#ifdef ZTS
-PHPAPI int basic_globals_id;
+TSRMG_D(php_basic_globals, basic_globals_id);
#else
PHPAPI php_basic_globals basic_globals;
#endif
@@ -3980,9 +3980,9 @@ PHPAPI double php_get_inf(void) /* {{{ *
PHP_MINIT_FUNCTION(basic) /* {{{ */
{
#ifdef ZTS
- ts_allocate_id(&basic_globals_id, sizeof(php_basic_globals), (ts_allocate_ctor) basic_globals_ctor, (ts_allocate_dtor) basic_globals_dtor);
+ TSRMG_ALLOCATE(basic_globals_id, sizeof(php_basic_globals), (ts_allocate_ctor) basic_globals_ctor, (ts_allocate_dtor) basic_globals_dtor);
#ifdef PHP_WIN32
- ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor)php_win32_core_globals_ctor, (ts_allocate_dtor)php_win32_core_globals_dtor );
+ TSRMG_ALLOCATE(php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor)php_win32_core_globals_ctor, (ts_allocate_dtor)php_win32_core_globals_dtor);
#endif
#else
basic_globals_ctor(&basic_globals TSRMLS_CC);
Index: ext/standard/basic_functions.h
===================================================================
RCS file: /repository/php-src/ext/standard/basic_functions.h,v
retrieving revision 1.139.2.4.2.6.2.9
diff -u -p -r1.139.2.4.2.6.2.9 basic_functions.h
--- ext/standard/basic_functions.h 15 Apr 2008 08:44:21 -0000 1.139.2.4.2.6.2.9
+++ ext/standard/basic_functions.h 17 Aug 2008 00:29:51 -0000
@@ -228,7 +228,7 @@ typedef struct _php_basic_globals {
#ifdef ZTS
#define BG(v) TSRMG(basic_globals_id, php_basic_globals *, v)
-PHPAPI extern int basic_globals_id;
+TSRMG_DH(php_basic_globals, basic_globals_id);
#else
#define BG(v) (basic_globals.v)
PHPAPI extern php_basic_globals basic_globals;
Index: ext/standard/dir.c
===================================================================
RCS file: /repository/php-src/ext/standard/dir.c,v
retrieving revision 1.147.2.3.2.12.2.11
diff -u -p -r1.147.2.3.2.12.2.11 dir.c
--- ext/standard/dir.c 11 Aug 2008 23:14:36 -0000 1.147.2.3.2.12.2.11
+++ ext/standard/dir.c 17 Aug 2008 00:29:51 -0000
@@ -57,7 +57,7 @@ typedef struct {
#ifdef ZTS
#define DIRG(v) TSRMG(dir_globals_id, php_dir_globals *, v)
-int dir_globals_id;
+TSRMG_D(php_dir_globals, dir_globals_id);
#else
#define DIRG(v) (dir_globals.v)
php_dir_globals dir_globals;
@@ -131,7 +131,7 @@ PHP_MINIT_FUNCTION(dir)
dir_class_entry_ptr = zend_register_internal_class(&dir_class_entry TSRMLS_CC);
#ifdef ZTS
- ts_allocate_id(&dir_globals_id, sizeof(php_dir_globals), NULL, NULL);
+ TSRMG_ALLOCATE(dir_globals_id, sizeof(php_dir_globals), NULL, NULL);
#endif
dirsep_str[0] = DEFAULT_SLASH;
Index: ext/standard/file.c
===================================================================
RCS file: /repository/php-src/ext/standard/file.c,v
retrieving revision 1.409.2.6.2.28.2.21
diff -u -p -r1.409.2.6.2.28.2.21 file.c
--- ext/standard/file.c 12 Aug 2008 19:38:54 -0000 1.409.2.6.2.28.2.21
+++ ext/standard/file.c 17 Aug 2008 00:29:52 -0000
@@ -111,7 +111,7 @@ extern int fclose(FILE *);
#include "zend_API.h"
#ifdef ZTS
-int file_globals_id;
+TSRMG_D(php_file_globals, file_globals_id);
#else
php_file_globals file_globals;
#endif
@@ -183,7 +183,7 @@ PHP_MINIT_FUNCTION(file)
le_stream_context = zend_register_list_destructors_ex(file_context_dtor, NULL, "stream-context", module_number);
#ifdef ZTS
- ts_allocate_id(&file_globals_id, sizeof(php_file_globals), (ts_allocate_ctor) file_globals_ctor, (ts_allocate_dtor) file_globals_dtor);
+ TSRMG_ALLOCATE(file_globals_id, sizeof(php_file_globals), (ts_allocate_ctor) file_globals_ctor, (ts_allocate_dtor) file_globals_dtor);
#else
file_globals_ctor(&file_globals TSRMLS_CC);
#endif
Index: ext/standard/file.h
===================================================================
RCS file: /repository/php-src/ext/standard/file.h,v
retrieving revision 1.94.2.2.2.5.2.2
diff -u -p -r1.94.2.2.2.5.2.2 file.h
--- ext/standard/file.h 31 Dec 2007 07:17:14 -0000 1.94.2.2.2.5.2.2
+++ ext/standard/file.h 17 Aug 2008 00:29:52 -0000
@@ -126,7 +126,7 @@ typedef struct {
#ifdef ZTS
#define FG(v) TSRMG(file_globals_id, php_file_globals *, v)
-extern PHPAPI int file_globals_id;
+TSRMG_DH(php_file_globals, file_globals_id);
#else
#define FG(v) (file_globals.v)
extern PHPAPI php_file_globals file_globals;
Index: ext/standard/lcg.c
===================================================================
RCS file: /repository/php-src/ext/standard/lcg.c,v
retrieving revision 1.41.2.1.2.2.2.2
diff -u -p -r1.41.2.1.2.2.2.2 lcg.c
--- ext/standard/lcg.c 31 Dec 2007 07:17:15 -0000 1.41.2.1.2.2.2.2
+++ ext/standard/lcg.c 17 Aug 2008 00:29:52 -0000
@@ -32,7 +32,7 @@
#endif
#ifdef ZTS
-int lcg_globals_id;
+TSRMG_D(php_lcg_globals, lcg_globals_id);
#else
static php_lcg_globals lcg_globals;
#endif
@@ -101,7 +101,7 @@ static void lcg_init_globals(php_lcg_glo
PHP_MINIT_FUNCTION(lcg) /* {{{ */
{
#ifdef ZTS
- ts_allocate_id(&lcg_globals_id, sizeof(php_lcg_globals), (ts_allocate_ctor) lcg_init_globals, NULL);
+ TSRMG_ALLOCATE(lcg_globals_id, sizeof(php_lcg_globals), (ts_allocate_ctor) lcg_init_globals, NULL);
#else
lcg_init_globals(&lcg_globals);
#endif
Index: main/SAPI.c
===================================================================
RCS file: /repository/php-src/main/SAPI.c,v
retrieving revision 1.202.2.7.2.15.2.4
diff -u -p -r1.202.2.7.2.15.2.4 SAPI.c
--- main/SAPI.c 18 Mar 2008 21:42:50 -0000 1.202.2.7.2.15.2.4
+++ main/SAPI.c 17 Aug 2008 00:29:52 -0000
@@ -53,7 +53,7 @@
#include "php_content_types.h"
#ifdef ZTS
-SAPI_API int sapi_globals_id;
+TSRMG_D(sapi_globals_struct, sapi_globals_id);
#else
sapi_globals_struct sapi_globals;
#endif
@@ -80,7 +80,7 @@ SAPI_API void sapi_startup(sapi_module_s
sapi_module = *sf;
#ifdef ZTS
- ts_allocate_id(&sapi_globals_id, sizeof(sapi_globals_struct), (ts_allocate_ctor) sapi_globals_ctor, (ts_allocate_dtor) sapi_globals_dtor);
+ TSRMG_ALLOCATE(sapi_globals_id, sizeof(sapi_globals_struct), (ts_allocate_ctor) sapi_globals_ctor, (ts_allocate_dtor) sapi_globals_dtor);
#else
sapi_globals_ctor(&sapi_globals);
#endif
Index: main/SAPI.h
===================================================================
RCS file: /repository/php-src/main/SAPI.h,v
retrieving revision 1.114.2.1.2.3.2.3
diff -u -p -r1.114.2.1.2.3.2.3 SAPI.h
--- main/SAPI.h 18 Mar 2008 21:42:50 -0000 1.114.2.1.2.3.2.3
+++ main/SAPI.h 17 Aug 2008 00:29:52 -0000
@@ -137,7 +137,7 @@ typedef struct _sapi_globals_struct {
BEGIN_EXTERN_C()
#ifdef ZTS
# define SG(v) TSRMG(sapi_globals_id, sapi_globals_struct *, v)
-SAPI_API extern int sapi_globals_id;
+TSRMG_DH(sapi_globals_struct, sapi_globals_id);
#else
# define SG(v) (sapi_globals.v)
extern SAPI_API sapi_globals_struct sapi_globals;
Index: main/main.c
===================================================================
RCS file: /repository/php-src/main/main.c,v
retrieving revision 1.640.2.23.2.57.2.29
diff -u -p -r1.640.2.23.2.57.2.29 main.c
--- main/main.c 15 Aug 2008 19:47:33 -0000 1.640.2.23.2.57.2.29
+++ main/main.c 17 Aug 2008 00:29:52 -0000
@@ -94,7 +94,7 @@
#ifndef ZTS
php_core_globals core_globals;
#else
-PHPAPI int core_globals_id;
+TSRMG_D(php_core_globals, core_globals_id);
#endif
#define SAFE_FILENAME(f) ((f)?(f):"-")
@@ -1655,8 +1655,6 @@ int php_module_startup(sapi_module_struc
char *php_os;
#ifdef ZTS
zend_executor_globals *executor_globals;
- void ***tsrm_ls;
-
php_core_globals *core_globals;
#endif
#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
@@ -1689,7 +1687,7 @@ int php_module_startup(sapi_module_struc
#endif
#ifdef ZTS
- tsrm_ls = ts_resource(0);
+ TSRMLS_INIT();
#endif
module_shutdown = 0;
@@ -1723,10 +1721,10 @@ int php_module_startup(sapi_module_struc
#ifdef ZTS
executor_globals = ts_resource(executor_globals_id);
- ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor);
+ TSRMG_ALLOCATE(core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor);
core_globals = ts_resource(core_globals_id);
#ifdef PHP_WIN32
- ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor) php_win32_core_globals_ctor, (ts_allocate_dtor) php_win32_core_globals_dtor);
+ TSRMG_ALLOCATE(php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor) php_win32_core_globals_ctor, (ts_allocate_dtor) php_win32_core_globals_dtor);
#endif
#endif
gc_globals_ctor(TSRMLS_C);
Index: main/output.c
===================================================================
RCS file: /repository/php-src/main/output.c,v
retrieving revision 1.167.2.3.2.4.2.7
diff -u -p -r1.167.2.3.2.4.2.7 output.c
--- main/output.c 2 Aug 2008 04:46:07 -0000 1.167.2.3.2.4.2.7
+++ main/output.c 17 Aug 2008 00:29:52 -0000
@@ -41,7 +41,7 @@ static void php_ob_prepend(const char *t
#endif
#ifdef ZTS
-int output_globals_id;
+TSRMG_D(php_output_globals, output_globals_id);
#else
php_output_globals output_globals;
#endif
@@ -70,8 +70,9 @@ static void php_output_init_globals(php_
Start output layer */
PHPAPI void php_output_startup(void)
{
+ TSRMLS_FETCH();
#ifdef ZTS
- ts_allocate_id(&output_globals_id, sizeof(php_output_globals), (ts_allocate_ctor) php_output_init_globals, NULL);
+ TSRMG_ALLOCATE(output_globals_id, sizeof(php_output_globals), (ts_allocate_ctor) php_output_init_globals, NULL);
#else
php_output_init_globals(&output_globals TSRMLS_CC);
#endif
Index: main/php.h
===================================================================
RCS file: /repository/php-src/main/php.h,v
retrieving revision 1.221.2.4.2.8.2.9
diff -u -p -r1.221.2.4.2.8.2.9 php.h
--- main/php.h 13 Aug 2008 22:40:39 -0000 1.221.2.4.2.8.2.9
+++ main/php.h 17 Aug 2008 00:29:52 -0000
@@ -289,7 +289,7 @@ static inline ZEND_ATTRIBUTE_DEPRECATED
PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC) PHP_ATTRIBUTE_FORMAT(printf, 4, 0);
-#ifdef ZTS
+#ifdef PASS_TSRMLS
#define PHP_ATTR_FMT_OFFSET 1
#else
#define PHP_ATTR_FMT_OFFSET 0
Index: main/php_globals.h
===================================================================
RCS file: /repository/php-src/main/php_globals.h,v
retrieving revision 1.98.2.1.2.7.2.5
diff -u -p -r1.98.2.1.2.7.2.5 php_globals.h
--- main/php_globals.h 18 Mar 2008 21:42:50 -0000 1.98.2.1.2.7.2.5
+++ main/php_globals.h 17 Aug 2008 00:29:52 -0000
@@ -27,7 +27,7 @@ typedef struct _php_core_globals php_cor
#ifdef ZTS
# define PG(v) TSRMG(core_globals_id, php_core_globals *, v)
-extern PHPAPI int core_globals_id;
+TSRMG_DH(php_core_globals, core_globals_id);
#else
# define PG(v) (core_globals.v)
extern ZEND_API struct _php_core_globals core_globals;
Index: main/php_output.h
===================================================================
RCS file: /repository/php-src/main/php_output.h,v
retrieving revision 1.53.2.1.2.1.2.1
diff -u -p -r1.53.2.1.2.1.2.1 php_output.h
--- main/php_output.h 31 Dec 2007 07:17:17 -0000 1.53.2.1.2.1.2.1
+++ main/php_output.h 17 Aug 2008 00:29:53 -0000
@@ -94,7 +94,7 @@ typedef struct _php_output_globals {
#ifdef ZTS
#define OG(v) TSRMG(output_globals_id, php_output_globals *, v)
-ZEND_API extern int output_globals_id;
+TSRMG_DH(php_output_globals, output_globals_id);
#else
#define OG(v) (output_globals.v)
ZEND_API extern php_output_globals output_globals;
Index: sapi/apache/php_apache.c
===================================================================
RCS file: /repository/php-src/sapi/apache/php_apache.c,v
retrieving revision 1.89.2.4.2.6.2.5
diff -u -p -r1.89.2.4.2.6.2.5 php_apache.c
--- sapi/apache/php_apache.c 20 Jul 2008 14:28:41 -0000 1.89.2.4.2.6.2.5
+++ sapi/apache/php_apache.c 17 Aug 2008 00:29:53 -0000
@@ -139,7 +139,7 @@ static void php_apache_globals_ctor(php_
static PHP_MINIT_FUNCTION(apache)
{
#ifdef ZTS
- ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL);
+ TSRMG_ALLOCATE(php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL);
#else
php_apache_globals_ctor(&php_apache_info TSRMLS_CC);
#endif
Index: sapi/apache2handler/php_apache.h
===================================================================
RCS file: /repository/php-src/sapi/apache2handler/php_apache.h,v
retrieving revision 1.8.2.1.2.2.2.2
diff -u -p -r1.8.2.1.2.2.2.2 php_apache.h
--- sapi/apache2handler/php_apache.h 30 Jan 2008 09:41:12 -0000 1.8.2.1.2.2.2.2
+++ sapi/apache2handler/php_apache.h 17 Aug 2008 00:29:53 -0000
@@ -75,7 +75,7 @@ typedef struct {
extern zend_module_entry apache2_module_entry;
#ifdef ZTS
-extern int php_apache2_info_id;
+TSRMG_DH(php_apache2_info_struct, php_apache2_info_id);
#define AP2(v) TSRMG(php_apache2_info_id, php_apache2_info_struct *, v)
#else
extern php_apache2_info_struct php_apache2_info;
Index: sapi/apache2handler/php_functions.c
===================================================================
RCS file: /repository/php-src/sapi/apache2handler/php_functions.c,v
retrieving revision 1.18.2.6.2.5.2.4
diff -u -p -r1.18.2.6.2.5.2.4 php_functions.c
--- sapi/apache2handler/php_functions.c 16 Jul 2008 11:59:15 -0000 1.18.2.6.2.5.2.4
+++ sapi/apache2handler/php_functions.c 17 Aug 2008 00:29:53 -0000
@@ -49,7 +49,7 @@
#include "php_apache.h"
#ifdef ZTS
-int php_apache2_info_id;
+TSRMG_D(php_apache2_info_struct, php_apache2_info_id);
#else
php_apache2_info_struct php_apache2_info;
#endif
@@ -548,7 +548,7 @@ PHP_INI_END()
static PHP_MINIT_FUNCTION(apache)
{
#ifdef ZTS
- ts_allocate_id(&php_apache2_info_id, sizeof(php_apache2_info_struct), (ts_allocate_ctor) NULL, NULL);
+ TSRMG_ALLOCATE(php_apache2_info_id, sizeof(php_apache2_info_struct), NULL, NULL);
#endif
REGISTER_INI_ENTRIES();
return SUCCESS;
Index: sapi/apache2handler/sapi_apache2.c
===================================================================
RCS file: /repository/php-src/sapi/apache2handler/sapi_apache2.c,v
retrieving revision 1.57.2.10.2.15.2.3
diff -u -p -r1.57.2.10.2.15.2.3 sapi_apache2.c
--- sapi/apache2handler/sapi_apache2.c 18 Mar 2008 22:23:20 -0000 1.57.2.10.2.15.2.3
+++ sapi/apache2handler/sapi_apache2.c 17 Aug 2008 00:29:53 -0000
@@ -504,7 +504,7 @@ static int php_handler(request_rec *r)
apr_bucket *bucket;
apr_status_t rv;
request_rec * volatile parent_req = NULL;
- TSRMLS_FETCH();
+ TSRMLS_INIT();
#define PHPAP_INI_OFF php_apache_ini_dtor(r, parent_req TSRMLS_CC);
Index: sapi/apache_hooks/php_apache.c
===================================================================
RCS file: /repository/php-src/sapi/apache_hooks/php_apache.c,v
retrieving revision 1.19.2.3.2.5.2.4
diff -u -p -r1.19.2.3.2.5.2.4 php_apache.c
--- sapi/apache_hooks/php_apache.c 20 Jul 2008 14:28:41 -0000 1.19.2.3.2.5.2.4
+++ sapi/apache_hooks/php_apache.c 17 Aug 2008 00:29:53 -0000
@@ -1436,7 +1436,7 @@ static PHP_MINIT_FUNCTION(apache)
zend_class_entry ce;
#ifdef ZTS
- ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL);
+ TSRMG_ALLOCATE(php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL);
#else
php_apache_globals_ctor(&php_apache_info TSRMLS_CC);
#endif
Index: sapi/cgi/cgi_main.c
===================================================================
RCS file: /repository/php-src/sapi/cgi/cgi_main.c,v
retrieving revision 1.267.2.15.2.50.2.24
diff -u -p -r1.267.2.15.2.50.2.24 cgi_main.c
--- sapi/cgi/cgi_main.c 15 Aug 2008 07:30:50 -0000 1.267.2.15.2.50.2.24
+++ sapi/cgi/cgi_main.c 17 Aug 2008 00:29:53 -0000
@@ -183,7 +183,7 @@ static void user_config_cache_entry_dtor
/* }}} */
#ifdef ZTS
-static int php_cgi_globals_id;
+TSRMG_D(php_cgi_globals_struct, php_cgi_globals_id);
#define CGIG(v) TSRMG(php_cgi_globals_id, php_cgi_globals_struct *, v)
#else
static php_cgi_globals_struct php_cgi_globals;
@@ -1317,7 +1317,7 @@ static void php_cgi_globals_ctor(php_cgi
static PHP_MINIT_FUNCTION(cgi)
{
#ifdef ZTS
- ts_allocate_id(&php_cgi_globals_id, sizeof(php_cgi_globals_struct), (ts_allocate_ctor) php_cgi_globals_ctor, NULL);
+ TSRMG_ALLOCATE(php_cgi_globals_id, sizeof(php_cgi_globals_struct), (ts_allocate_ctor) php_cgi_globals_ctor, NULL);
#else
php_cgi_globals_ctor(&php_cgi_globals TSRMLS_CC);
#endif
@@ -1377,10 +1377,6 @@ int main(int argc, char *argv[])
int ini_entries_len = 0;
/* end of temporary locals */
-#ifdef ZTS
- void ***tsrm_ls;
-#endif
-
int max_requests = 500;
int requests = 0;
int fastcgi = fcgi_is_fastcgi();
@@ -1422,7 +1418,7 @@ int main(int argc, char *argv[])
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
- tsrm_ls = ts_resource(0);
+ TSRMLS_INIT();
#endif
sapi_startup(&cgi_sapi_module);
Index: sapi/cli/php_cli.c
===================================================================
RCS file: /repository/php-src/sapi/cli/php_cli.c,v
retrieving revision 1.129.2.13.2.22.2.15
diff -u -p -r1.129.2.13.2.22.2.15 php_cli.c
--- sapi/cli/php_cli.c 14 Aug 2008 09:46:26 -0000 1.129.2.13.2.22.2.15
+++ sapi/cli/php_cli.c 17 Aug 2008 00:29:53 -0000
@@ -603,9 +603,6 @@ int main(int argc, char *argv[])
const char *param_error=NULL;
int hide_argv = 0;
/* end of temporary locals */
-#ifdef ZTS
- void ***tsrm_ls;
-#endif
#ifdef PHP_CLI_WIN32_NO_CONSOLE
int argc = __argc;
char **argv = __argv;
@@ -641,7 +638,7 @@ int main(int argc, char *argv[])
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
- tsrm_ls = ts_resource(0);
+ TSRMLS_INIT();
#endif
cli_sapi_module.ini_defaults = sapi_cli_ini_defaults;
Index: sapi/embed/php_embed.c
===================================================================
RCS file: /repository/php-src/sapi/embed/php_embed.c,v
retrieving revision 1.11.2.1.2.5.2.3
diff -u -p -r1.11.2.1.2.5.2.3 php_embed.c
--- sapi/embed/php_embed.c 25 Mar 2008 22:05:22 -0000 1.11.2.1.2.5.2.3
+++ sapi/embed/php_embed.c 17 Aug 2008 00:29:53 -0000
@@ -143,9 +143,6 @@ sapi_module_struct php_embed_module = {
int php_embed_init(int argc, char **argv PTSRMLS_DC)
{
zend_llist global_vars;
-#ifdef ZTS
- void ***tsrm_ls = NULL;
-#endif
#ifdef HAVE_SIGNAL_H
#if defined(SIGPIPE) && defined(SIG_IGN)
@@ -160,8 +157,8 @@ int php_embed_init(int argc, char **argv
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
- tsrm_ls = ts_resource(0);
- *ptsrm_ls = tsrm_ls;
+ TSRMLS_INIT();
+ *ptsrm_ls = ts_resource_ex(0, NULL);
#endif
sapi_startup(&php_embed_module);
Index: sapi/embed/php_embed.h
===================================================================
RCS file: /repository/php-src/sapi/embed/php_embed.h,v
retrieving revision 1.6.2.2.2.1.2.1
diff -u -p -r1.6.2.2.2.1.2.1 php_embed.h
--- sapi/embed/php_embed.h 31 Dec 2007 07:17:18 -0000 1.6.2.2.2.1.2.1
+++ sapi/embed/php_embed.h 17 Aug 2008 00:29:53 -0000
@@ -27,7 +27,7 @@
#include <main/php_ini.h>
#include <zend_ini.h>
-#ifdef ZTS
+#ifdef PASS_TSRMLS
#define PTSRMLS_D void ****ptsrm_ls
#define PTSRMLS_DC , PTSRMLS_D
#define PTSRMLS_C &tsrm_ls
Index: sapi/litespeed/lsapi_main.c
===================================================================
RCS file: /repository/php-src/sapi/litespeed/lsapi_main.c,v
retrieving revision 1.7.2.2
diff -u -p -r1.7.2.2 lsapi_main.c
--- sapi/litespeed/lsapi_main.c 5 Aug 2008 22:37:32 -0000 1.7.2.2
+++ sapi/litespeed/lsapi_main.c 17 Aug 2008 00:29:53 -0000
@@ -80,7 +80,6 @@ zend_compiler_globals *compiler_globa
zend_executor_globals *executor_globals;
php_core_globals *core_globals;
sapi_globals_struct *sapi_globals;
-void ***tsrm_ls;
#endif
zend_module_entry litespeed_module_entry;
@@ -706,6 +705,7 @@ int main( int argc, char * argv[] )
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
+ TSRMLS_INIT();
#endif
if (argc > 1 ) {
@@ -724,7 +724,6 @@ int main( int argc, char * argv[] )
executor_globals = ts_resource(executor_globals_id);
core_globals = ts_resource(core_globals_id);
sapi_globals = ts_resource(sapi_globals_id);
- tsrm_ls = ts_resource(0);
SG(request_info).path_translated = NULL;
#endif
Index: sapi/milter/php_milter.c
===================================================================
RCS file: /repository/php-src/sapi/milter/php_milter.c,v
retrieving revision 1.14.2.2.2.3.2.6
diff -u -p -r1.14.2.2.2.3.2.6 php_milter.c
--- sapi/milter/php_milter.c 13 Aug 2008 00:53:28 -0000 1.14.2.2.2.3.2.6
+++ sapi/milter/php_milter.c 17 Aug 2008 00:29:53 -0000
@@ -1000,8 +1000,6 @@ int main(int argc, char *argv[])
char *param_error=NULL;
/* end of temporary locals */
- void ***tsrm_ls;
-
#ifdef HAVE_SIGNAL_H
#if defined(SIGPIPE) && defined(SIG_IGN)
signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so
@@ -1015,6 +1013,7 @@ int main(int argc, char *argv[])
tsrm_startup(1, 1, 0, NULL);
+ TSRMLS_INIT();
sapi_startup(&milter_sapi_module);
while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) {
@@ -1032,8 +1031,6 @@ int main(int argc, char *argv[])
milter_sapi_module.executable_location = argv[0];
- tsrm_ls = ts_resource(0);
-
sapi_module.startup(&milter_sapi_module);
zend_first_try {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.