summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/Makefile.am6
-rw-r--r--TSRM/TSRM.c280
-rw-r--r--TSRM/TSRM.h55
-rw-r--r--TSRM/acinclude.m43
-rw-r--r--TSRM/build.mk40
-rwxr-xr-xTSRM/buildconf33
-rw-r--r--TSRM/config.w322
-rw-r--r--TSRM/configure.ac35
-rw-r--r--TSRM/m4/ax_func_which_gethostbyname_r.m4196
-rw-r--r--TSRM/readdir.h3
-rw-r--r--TSRM/threads.m443
-rw-r--r--TSRM/tsrm.m481
-rw-r--r--TSRM/tsrm_config.w32.h23
-rw-r--r--TSRM/tsrm_config_common.h80
-rw-r--r--TSRM/tsrm_strtok_r.c72
-rw-r--r--TSRM/tsrm_strtok_r.h8
-rw-r--r--TSRM/tsrm_win32.c26
-rw-r--r--TSRM/tsrm_win32.h11
18 files changed, 252 insertions, 745 deletions
diff --git a/TSRM/Makefile.am b/TSRM/Makefile.am
deleted file mode 100644
index e232381a01..0000000000
--- a/TSRM/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-## process this file with automake to produce Makefile.am
-AUTOMAKE_OPTIONS=foreign
-noinst_LTLIBRARIES=libtsrm.la
-libtsrm_la_SOURCES = TSRM.c tsrm_strtok_r.c
-
-depend:
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
index 01433db53b..1a8d5192ff 100644
--- a/TSRM/TSRM.c
+++ b/TSRM/TSRM.c
@@ -15,16 +15,19 @@
#ifdef ZTS
#include <stdio.h>
-
-#if HAVE_STDARG_H
#include <stdarg.h>
+
+#ifdef ZEND_DEBUG
+# include <assert.h>
+# define TSRM_ASSERT assert
+#else
+# define TSRM_ASSERT
#endif
typedef struct _tsrm_tls_entry tsrm_tls_entry;
-#if defined(TSRM_WIN32)
/* TSRMLS_CACHE_DEFINE; is already done in Zend, this is being always compiled statically. */
-#endif
+TSRMLS_CACHE_EXTERN();
struct _tsrm_tls_entry {
void **storage;
@@ -38,6 +41,7 @@ typedef struct {
size_t size;
ts_allocate_ctor ctor;
ts_allocate_dtor dtor;
+ size_t fast_offset;
int done;
} tsrm_resource_type;
@@ -51,8 +55,12 @@ static ts_rsrc_id id_count;
static tsrm_resource_type *resource_types_table=NULL;
static int resource_types_table_size;
+/* Reserved space for fast globals access */
+static size_t tsrm_reserved_pos = 0;
+static size_t tsrm_reserved_size = 0;
-static MUTEX_T tsmm_mutex; /* thread-safe memory manager mutex */
+static MUTEX_T tsmm_mutex; /* thread-safe memory manager mutex */
+static MUTEX_T tsrm_env_mutex; /* tsrm environ mutex */
/* New thread handlers */
static tsrm_thread_begin_func_t tsrm_new_thread_begin_handler = NULL;
@@ -122,6 +130,7 @@ static DWORD tls_key;
#endif
TSRM_TLS uint8_t in_main_thread = 0;
+TSRM_TLS uint8_t is_thread_shutdown = 0;
/* Startup TSRM (call once for the entire process) */
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename)
@@ -140,6 +149,7 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
/* ensure singleton */
in_main_thread = 1;
+ is_thread_shutdown = 0;
tsrm_error_file = stderr;
tsrm_error_set(debug_level, debug_filename);
@@ -148,6 +158,7 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
tsrm_tls_table = (tsrm_tls_entry **) calloc(tsrm_tls_table_size, sizeof(tsrm_tls_entry *));
if (!tsrm_tls_table) {
TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate TLS table"));
+ is_thread_shutdown = 1;
return 0;
}
id_count=0;
@@ -156,14 +167,20 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
resource_types_table = (tsrm_resource_type *) calloc(resource_types_table_size, sizeof(tsrm_resource_type));
if (!resource_types_table) {
TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate resource types table"));
+ is_thread_shutdown = 1;
free(tsrm_tls_table);
- tsrm_tls_table = NULL;
return 0;
}
tsmm_mutex = tsrm_mutex_alloc();
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Started up TSRM, %d expected threads, %d expected resources", expected_threads, expected_resources));
+
+ tsrm_reserved_pos = 0;
+ tsrm_reserved_size = 0;
+
+ tsrm_env_mutex = tsrm_mutex_alloc();
+
return 1;
}/*}}}*/
@@ -173,41 +190,44 @@ TSRM_API void tsrm_shutdown(void)
{/*{{{*/
int i;
+ if (is_thread_shutdown) {
+ /* shutdown must only occur once */
+ return;
+ }
+
+ is_thread_shutdown = 1;
+
if (!in_main_thread) {
- /* ensure singleton */
+ /* only the main thread may shutdown tsrm */
return;
}
- if (tsrm_tls_table) {
- for (i=0; i<tsrm_tls_table_size; i++) {
- tsrm_tls_entry *p = tsrm_tls_table[i], *next_p;
+ for (i=0; i<tsrm_tls_table_size; i++) {
+ tsrm_tls_entry *p = tsrm_tls_table[i], *next_p;
- while (p) {
- int j;
+ while (p) {
+ int j;
- next_p = p->next;
- 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]);
- }
+ next_p = p->next;
+ 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]);
+ }
+ if (!resource_types_table[j].fast_offset) {
free(p->storage[j]);
}
}
- free(p->storage);
- free(p);
- p = next_p;
}
+ free(p->storage);
+ free(p);
+ p = next_p;
}
- free(tsrm_tls_table);
- tsrm_tls_table = NULL;
- }
- if (resource_types_table) {
- free(resource_types_table);
- resource_types_table=NULL;
}
+ free(tsrm_tls_table);
+ free(resource_types_table);
tsrm_mutex_free(tsmm_mutex);
- tsmm_mutex = NULL;
+ tsrm_mutex_free(tsrm_env_mutex);
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Shutdown TSRM"));
if (tsrm_error_file!=stderr) {
fclose(tsrm_error_file);
@@ -226,14 +246,55 @@ TSRM_API void tsrm_shutdown(void)
tsrm_new_thread_begin_handler = NULL;
tsrm_new_thread_end_handler = NULL;
tsrm_shutdown_handler = NULL;
+
+ tsrm_reserved_pos = 0;
+ tsrm_reserved_size = 0;
}/*}}}*/
+/* {{{ */
+/* environ lock api */
+TSRM_API void tsrm_env_lock() {
+ tsrm_mutex_lock(tsrm_env_mutex);
+}
-/* 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 void tsrm_env_unlock() {
+ tsrm_mutex_unlock(tsrm_env_mutex);
+} /* }}} */
+
+/* enlarge the arrays for the already active threads */
+static void tsrm_update_active_threads(void)
{/*{{{*/
int i;
+ for (i=0; i<tsrm_tls_table_size; i++) {
+ tsrm_tls_entry *p = tsrm_tls_table[i];
+
+ while (p) {
+ if (p->count < id_count) {
+ int j;
+
+ p->storage = (void *) realloc(p->storage, sizeof(void *)*id_count);
+ for (j=p->count; j<id_count; j++) {
+ if (resource_types_table[j].fast_offset) {
+ p->storage[j] = (void *) (((char*)p) + resource_types_table[j].fast_offset);
+ } else {
+ p->storage[j] = (void *) malloc(resource_types_table[j].size);
+ }
+ if (resource_types_table[j].ctor) {
+ resource_types_table[j].ctor(p->storage[j]);
+ }
+ }
+ p->count = id_count;
+ }
+ p = p->next;
+ }
+ }
+}/*}}}*/
+
+
+/* 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_ERROR((TSRM_ERROR_LEVEL_CORE, "Obtaining a new resource id, %d bytes", size));
tsrm_mutex_lock(tsmm_mutex);
@@ -258,28 +319,68 @@ TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].size = size;
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)].fast_offset = 0;
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].done = 0;
- /* enlarge the arrays for the already active threads */
- for (i=0; i<tsrm_tls_table_size; i++) {
- tsrm_tls_entry *p = tsrm_tls_table[i];
+ tsrm_update_active_threads();
+ tsrm_mutex_unlock(tsmm_mutex);
- while (p) {
- if (p->count < id_count) {
- int j;
+ TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully allocated new resource id %d", *rsrc_id));
+ return *rsrc_id;
+}/*}}}*/
- 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);
- if (resource_types_table[j].ctor) {
- resource_types_table[j].ctor(p->storage[j]);
- }
- }
- p->count = id_count;
- }
- p = p->next;
+
+/* Reserve space for fast thread-safe-resources */
+TSRM_API void tsrm_reserve(size_t size)
+{/*{{{*/
+ tsrm_reserved_pos = 0;
+ tsrm_reserved_size = TSRM_ALIGNED_SIZE(size);
+}/*}}}*/
+
+
+/* allocates a new fast thread-safe-resource id */
+TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
+{/*{{{*/
+ TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Obtaining a new fast resource id, %d bytes", size));
+
+ tsrm_mutex_lock(tsmm_mutex);
+
+ /* obtain a resource id */
+ *rsrc_id = TSRM_SHUFFLE_RSRC_ID(id_count++);
+ TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Obtained resource id %d", *rsrc_id));
+
+ size = TSRM_ALIGNED_SIZE(size);
+ if (tsrm_reserved_size - tsrm_reserved_pos < size) {
+ tsrm_mutex_unlock(tsmm_mutex);
+ TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate space for fast resource"));
+ *rsrc_id = 0;
+ *offset = 0;
+ return 0;
+ }
+
+ *offset = TSRM_ALIGNED_SIZE(sizeof(tsrm_tls_entry)) + tsrm_reserved_pos;
+ tsrm_reserved_pos += size;
+
+ /* store the new resource type in the resource sizes table */
+ if (resource_types_table_size < id_count) {
+ tsrm_resource_type *_tmp;
+ _tmp = (tsrm_resource_type *) realloc(resource_types_table, sizeof(tsrm_resource_type)*id_count);
+ if (!_tmp) {
+ tsrm_mutex_unlock(tsmm_mutex);
+ TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate storage for resource"));
+ *rsrc_id = 0;
+ return 0;
}
+ resource_types_table = _tmp;
+ 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)].ctor = ctor;
+ resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].dtor = dtor;
+ resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].fast_offset = *offset;
+ resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].done = 0;
+
+ tsrm_update_active_threads();
tsrm_mutex_unlock(tsmm_mutex);
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully allocated new resource id %d", *rsrc_id));
@@ -292,7 +393,7 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
int i;
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Creating data structures for thread %x", thread_id));
- (*thread_resources_ptr) = (tsrm_tls_entry *) malloc(sizeof(tsrm_tls_entry));
+ (*thread_resources_ptr) = (tsrm_tls_entry *) malloc(TSRM_ALIGNED_SIZE(sizeof(tsrm_tls_entry)) + tsrm_reserved_size);
(*thread_resources_ptr)->storage = NULL;
if (id_count > 0) {
(*thread_resources_ptr)->storage = (void **) malloc(sizeof(void *)*id_count);
@@ -303,6 +404,7 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
/* Set thread local storage to this new thread resources structure */
tsrm_tls_set(*thread_resources_ptr);
+ TSRMLS_CACHE = *thread_resources_ptr;
if (tsrm_new_thread_begin_handler) {
tsrm_new_thread_begin_handler(thread_id);
@@ -310,9 +412,12 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
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);
+ } else {
+ if (resource_types_table[i].fast_offset) {
+ (*thread_resources_ptr)->storage[i] = (void *) (((char*)(*thread_resources_ptr)) + resource_types_table[i].fast_offset);
+ } else {
+ (*thread_resources_ptr)->storage[i] = (void *) malloc(resource_types_table[i].size);
+ }
if (resource_types_table[i].ctor) {
resource_types_table[i].ctor((*thread_resources_ptr)->storage[i]);
}
@@ -405,7 +510,9 @@ void tsrm_free_interpreter_context(void *context)
}
}
for (i=0; i<thread_resources->count; i++) {
- free(thread_resources->storage[i]);
+ if (!resource_types_table[i].fast_offset) {
+ free(thread_resources->storage[i]);
+ }
}
free(thread_resources->storage);
free(thread_resources);
@@ -458,6 +565,8 @@ void ts_free_thread(void)
int hash_value;
tsrm_tls_entry *last=NULL;
+ TSRM_ASSERT(!in_main_thread);
+
tsrm_mutex_lock(tsmm_mutex);
hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size);
thread_resources = tsrm_tls_table[hash_value];
@@ -470,7 +579,9 @@ void ts_free_thread(void)
}
}
for (i=0; i<thread_resources->count; i++) {
- free(thread_resources->storage[i]);
+ if (!resource_types_table[i].fast_offset) {
+ free(thread_resources->storage[i]);
+ }
}
free(thread_resources->storage);
if (last) {
@@ -490,53 +601,6 @@ void ts_free_thread(void)
tsrm_mutex_unlock(tsmm_mutex);
}/*}}}*/
-
-/* frees all resources allocated for all threads except current */
-void ts_free_worker_threads(void)
-{/*{{{*/
- tsrm_tls_entry *thread_resources;
- int i;
- THREAD_T thread_id = tsrm_thread_id();
- int hash_value;
- tsrm_tls_entry *last=NULL;
-
- tsrm_mutex_lock(tsmm_mutex);
- hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size);
- thread_resources = tsrm_tls_table[hash_value];
-
- while (thread_resources) {
- 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]);
- }
- }
- for (i=0; i<thread_resources->count; i++) {
- free(thread_resources->storage[i]);
- }
- free(thread_resources->storage);
- if (last) {
- last->next = thread_resources->next;
- } else {
- tsrm_tls_table[hash_value] = thread_resources->next;
- }
- free(thread_resources);
- if (last) {
- thread_resources = last->next;
- } else {
- thread_resources = tsrm_tls_table[hash_value];
- }
- } else {
- if (thread_resources->next) {
- last = thread_resources;
- }
- thread_resources = thread_resources->next;
- }
- }
- tsrm_mutex_unlock(tsmm_mutex);
-}/*}}}*/
-
-
/* deallocates all occurrences of a given id */
void ts_free_id(ts_rsrc_id id)
{/*{{{*/
@@ -556,7 +620,9 @@ void ts_free_id(ts_rsrc_id id)
if (resource_types_table && resource_types_table[j].dtor) {
resource_types_table[j].dtor(p->storage[j]);
}
- free(p->storage[j]);
+ if (!resource_types_table[j].fast_offset) {
+ free(p->storage[j]);
+ }
p->storage[j] = NULL;
}
p = p->next;
@@ -781,6 +847,11 @@ TSRM_API uint8_t tsrm_is_main_thread(void)
return in_main_thread;
}/*}}}*/
+TSRM_API uint8_t tsrm_is_shutdown(void)
+{/*{{{*/
+ return is_thread_shutdown;
+}/*}}}*/
+
TSRM_API const char *tsrm_api_name(void)
{/*{{{*/
#if defined(GNUPTH)
@@ -797,12 +868,3 @@ TSRM_API const char *tsrm_api_name(void)
}/*}}}*/
#endif /* ZTS */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h
index ad18012f3d..d710eb6f75 100644
--- a/TSRM/TSRM.h
+++ b/TSRM/TSRM.h
@@ -15,9 +15,9 @@
#if !defined(__CYGWIN__) && defined(WIN32)
# define TSRM_WIN32
-# include "tsrm_config.w32.h"
+# include "Zend/zend_config.w32.h"
#else
-# include <tsrm_config.h>
+# include "main/php_config.h"
#endif
#include "main/php_stdint.h"
@@ -52,9 +52,14 @@ typedef uintptr_t tsrm_uintptr_t;
# include <pthread.h>
#elif defined(TSRM_ST)
# include <st.h>
-#elif defined(BETHREADS)
-#include <kernel/OS.h>
-#include <TLS.h>
+#endif
+
+#if SIZEOF_SIZE_T == 4
+# define TSRM_ALIGNED_SIZE(size) \
+ (((size) + INT32_C(15)) & ~INT32_C(15))
+#else
+# define TSRM_ALIGNED_SIZE(size) \
+ (((size) + INT64_C(15)) & ~INT64_C(15))
#endif
typedef int ts_rsrc_id;
@@ -74,9 +79,7 @@ typedef int ts_rsrc_id;
# define MUTEX_T st_mutex_t
#endif
-#ifdef HAVE_SIGNAL_H
#include <signal.h>
-#endif
typedef void (*ts_allocate_ctor)(void *);
typedef void (*ts_allocate_dtor)(void *);
@@ -91,9 +94,17 @@ extern "C" {
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename);
TSRM_API void tsrm_shutdown(void);
+/* environ lock API */
+TSRM_API void tsrm_env_lock();
+TSRM_API void tsrm_env_unlock();
+
/* 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);
+/* Fast resource in reserved (pre-allocated) space */
+TSRM_API void tsrm_reserve(size_t size);
+TSRM_API ts_rsrc_id ts_allocate_fast_id(ts_rsrc_id *rsrc_id, size_t *offset, size_t size, 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);
#define ts_resource(id) ts_resource_ex(id, NULL)
@@ -101,9 +112,6 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id);
/* frees all resources allocated for the current thread */
TSRM_API void ts_free_thread(void);
-/* frees all resources allocated for all threads except current */
-void ts_free_worker_threads(void);
-
/* deallocates all occurrences of a given id */
TSRM_API void ts_free_id(ts_rsrc_id id);
@@ -143,16 +151,13 @@ TSRM_API void tsrm_free_interpreter_context(void *context);
TSRM_API void *tsrm_get_ls_cache(void);
TSRM_API uint8_t tsrm_is_main_thread(void);
+TSRM_API uint8_t tsrm_is_shutdown(void);
TSRM_API const char *tsrm_api_name(void);
-#if defined(__cplusplus) && __cplusplus > 199711L
-# define TSRM_TLS thread_local
+#ifdef TSRM_WIN32
+# define TSRM_TLS __declspec(thread)
#else
-# ifdef TSRM_WIN32
-# define TSRM_TLS __declspec(thread)
-# else
-# define TSRM_TLS __thread
-# endif
+# define TSRM_TLS __thread
#endif
#define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1)
@@ -162,9 +167,13 @@ TSRM_API const char *tsrm_api_name(void);
#define TSRMLS_SET_CTX(ctx) ctx = (void ***) tsrm_get_ls_cache()
#define TSRMG(id, type, element) (TSRMG_BULK(id, type)->element)
#define TSRMG_BULK(id, type) ((type) (*((void ***) tsrm_get_ls_cache()))[TSRM_UNSHUFFLE_RSRC_ID(id)])
+#define TSRMG_FAST(offset, type, element) (TSRMG_FAST_BULK(offset, type)->element)
+#define TSRMG_FAST_BULK(offset, type) ((type) (((char*) tsrm_get_ls_cache())+(offset)))
#define TSRMG_STATIC(id, type, element) (TSRMG_BULK_STATIC(id, type)->element)
#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;
#define TSRMLS_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE = NULL;
#define TSRMLS_CACHE_UPDATE() TSRMLS_CACHE = tsrm_get_ls_cache()
@@ -183,6 +192,9 @@ TSRM_API const char *tsrm_api_name(void);
#else /* non ZTS */
+#define tsrm_env_lock()
+#define tsrm_env_unlock()
+
#define TSRMLS_FETCH()
#define TSRMLS_FETCH_FROM_CTX(ctx)
#define TSRMLS_SET_CTX(ctx)
@@ -204,12 +216,3 @@ TSRM_API const char *tsrm_api_name(void);
#endif /* ZTS */
#endif /* TSRM_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/TSRM/acinclude.m4 b/TSRM/acinclude.m4
deleted file mode 100644
index f886570c77..0000000000
--- a/TSRM/acinclude.m4
+++ /dev/null
@@ -1,3 +0,0 @@
-AC_DEFUN([AM_SET_LIBTOOL_VARIABLE],[
- LIBTOOL='$(SHELL) $(top_builddir)/libtool $1'
-])
diff --git a/TSRM/build.mk b/TSRM/build.mk
deleted file mode 100644
index e5e46b7eaa..0000000000
--- a/TSRM/build.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# Makefile to generate build tools
-#
-# Standard usage:
-# make -f build.mk
-#
-# Written by Sascha Schumann
-
-LT_TARGETS = ltmain.sh ltconfig
-
-config_h_in = tsrm_config.h.in
-
-makefile_am_files = Makefile.am
-makefile_in_files = $(makefile_am_files:.am=.in)
-makefile_files = $(makefile_am_files:e.am=e)
-
-targets = $(makefile_in_files) $(LT_TARGETS) configure $(config_h_in)
-
-all: $(targets)
-
-clean:
- rm -f $(targets)
-
-$(LT_TARGETS):
- rm -f $(LT_TARGETS)
- libtoolize --automake $(AMFLAGS) -f
-
-$(makefile_in_files): $(makefile_am_files)
- automake -a -i $(AMFLAGS) $(makefile_files)
-
-aclocal.m4: configure.ac acinclude.m4
- aclocal
-
-$(config_h_in): configure.ac
-# explicitly remove target since autoheader does not seem to work
-# correctly otherwise (timestamps are not updated)
- @rm -f $@
- autoheader
-
-configure: aclocal.m4 configure.ac
- autoconf
diff --git a/TSRM/buildconf b/TSRM/buildconf
deleted file mode 100755
index fe8dee6f76..0000000000
--- a/TSRM/buildconf
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-case "$1" in
---copy)
- automake_flags=--copy
- shift
-;;
-esac
-
-libtoolize --force --automake $automake_flags
-
-mv aclocal.m4 aclocal.m4.old 2>/dev/null
-aclocal
-if cmp aclocal.m4.old aclocal.m4 > /dev/null 2>&1; then
- echo "buildconf: keeping ${1}aclocal.m4"
- mv aclocal.m4.old aclocal.m4
-else
- echo "buildconf: created or modified ${1}aclocal.m4"
-fi
-
-autoheader
-
-automake --add-missing --include-deps $automake_flags
-
-mv configure configure.old 2>/dev/null
-autoconf
-if cmp configure.old configure > /dev/null 2>&1; then
- echo "buildconf: keeping ${1}configure"
- mv configure.old configure
-else
- echo "buildconf: created or modified ${1}configure"
-fi
-
diff --git a/TSRM/config.w32 b/TSRM/config.w32
index c65a91cc97..fa7145ae4d 100644
--- a/TSRM/config.w32
+++ b/TSRM/config.w32
@@ -1,4 +1,4 @@
// vim:ft=javascript
-ADD_SOURCES("TSRM", "TSRM.c tsrm_strtok_r.c tsrm_win32.c");
+ADD_SOURCES("TSRM", "TSRM.c tsrm_win32.c");
ADD_FLAG("CFLAGS_BD_TSRM", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
diff --git a/TSRM/configure.ac b/TSRM/configure.ac
deleted file mode 100644
index c3ed326bce..0000000000
--- a/TSRM/configure.ac
+++ /dev/null
@@ -1,35 +0,0 @@
-dnl
-dnl Minimalistic configure.ac for TSRM.
-dnl
-
-AC_INIT(TSRM.c)
-AM_INIT_AUTOMAKE(TSRM, 1.0, nodefine)
-AM_CONFIG_HEADER(tsrm_config.h)
-
-AH_TOP([
-#undef PTHREADS
-])
-
-sinclude(tsrm.m4)
-
-TSRM_BASIC_CHECKS
-TSRM_THREADS_CHECKS
-
-AM_PROG_LIBTOOL
-if test "$enable_debug" != "yes"; then
- AM_SET_LIBTOOL_VARIABLE([--silent])
-fi
-
-dnl TSRM_PTHREAD
-
-AC_CHECK_HEADERS(
-utime.h \
-dirent.h \
-stdarg.h \
-alloca.h \
-unistd.h \
-limits.h
-)
-
-AC_CONFIG_FILES([Makefile])
-AC_OUTPUT
diff --git a/TSRM/m4/ax_func_which_gethostbyname_r.m4 b/TSRM/m4/ax_func_which_gethostbyname_r.m4
deleted file mode 100644
index bb6bc959e7..0000000000
--- a/TSRM/m4/ax_func_which_gethostbyname_r.m4
+++ /dev/null
@@ -1,196 +0,0 @@
-# ==================================================================================
-# https://www.gnu.org/software/autoconf-archive/ax_func_which_gethostbyname_r.html
-# ==================================================================================
-#
-# SYNOPSIS
-#
-# AX_FUNC_WHICH_GETHOSTBYNAME_R
-#
-# DESCRIPTION
-#
-# Determines which historical variant of the gethostbyname_r() call
-# (taking three, five, or six arguments) is available on the system and
-# defines one of the following macros accordingly:
-#
-# HAVE_FUNC_GETHOSTBYNAME_R_6
-# HAVE_FUNC_GETHOSTBYNAME_R_5
-# HAVE_FUNC_GETHOSTBYNAME_R_3
-#
-# as well as
-#
-# HAVE_GETHOSTBYNAME_R
-#
-# If used in conjunction with gethostname.c, the API demonstrated in
-# test.c can be used regardless of which gethostbyname_r() is available.
-# These example files can be found at
-# http://www.csn.ul.ie/~caolan/publink/gethostbyname_r
-#
-# based on David Arnold's autoconf suggestion in the threads faq
-#
-# Originally named "AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R". Rewritten for
-# Autoconf 2.5x, and updated for 2.68 by Daniel Richard G.
-#
-# LICENSE
-#
-# Copyright (c) 2008 Caolan McNamara <caolan@skynet.ie>
-# Copyright (c) 2008 Daniel Richard G. <skunk@iskunk.org>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation; either version 2 of the License, or (at your
-# option) any later version.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
-# Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program. If not, see <https://www.gnu.org/licenses/>.
-#
-# As a special exception, the respective Autoconf Macro's copyright owner
-# gives unlimited permission to copy, distribute and modify the configure
-# scripts that are the output of Autoconf when processing the Macro. You
-# need not follow the terms of the GNU General Public License when using
-# or distributing such scripts, even though portions of the text of the
-# Macro appear in them. The GNU General Public License (GPL) does govern
-# all other use of the material that constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the Autoconf
-# Macro released by the Autoconf Archive. When you make and distribute a
-# modified version of the Autoconf Macro, you may extend this special
-# exception to the GPL to apply to your modified version as well.
-
-#serial 8
-
-AC_DEFUN([AX_FUNC_WHICH_GETHOSTBYNAME_R], [
-
- AC_LANG_PUSH([C])
- AC_MSG_CHECKING([how many arguments gethostbyname_r() takes])
-
- AC_CACHE_VAL([ac_cv_func_which_gethostbyname_r], [
-
-################################################################
-
-ac_cv_func_which_gethostbyname_r=unknown
-
-#
-# ONE ARGUMENT (sanity check)
-#
-
-# This should fail, as there is no variant of gethostbyname_r() that takes
-# a single argument. If it actually compiles, then we can assume that
-# netdb.h is not declaring the function, and the compiler is thereby
-# assuming an implicit prototype. In which case, we're out of luck.
-#
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>],
- [
- char *name = "www.gnu.org";
- (void)gethostbyname_r(name) /* ; */
- ])],
- [ac_cv_func_which_gethostbyname_r=no])
-
-#
-# SIX ARGUMENTS
-# (e.g. Linux)
-#
-
-if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
-
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>],
- [
- char *name = "www.gnu.org";
- struct hostent ret, *retp;
- char buf@<:@1024@:>@;
- int buflen = 1024;
- int my_h_errno;
- (void)gethostbyname_r(name, &ret, buf, buflen, &retp, &my_h_errno) /* ; */
- ])],
- [ac_cv_func_which_gethostbyname_r=six])
-
-fi
-
-#
-# FIVE ARGUMENTS
-# (e.g. Solaris)
-#
-
-if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
-
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>],
- [
- char *name = "www.gnu.org";
- struct hostent ret;
- char buf@<:@1024@:>@;
- int buflen = 1024;
- int my_h_errno;
- (void)gethostbyname_r(name, &ret, buf, buflen, &my_h_errno) /* ; */
- ])],
- [ac_cv_func_which_gethostbyname_r=five])
-
-fi
-
-#
-# THREE ARGUMENTS
-# (e.g. AIX, HP-UX, Tru64)
-#
-
-if test "$ac_cv_func_which_gethostbyname_r" = "unknown"; then
-
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>],
- [
- char *name = "www.gnu.org";
- struct hostent ret;
- struct hostent_data data;
- (void)gethostbyname_r(name, &ret, &data) /* ; */
- ])],
- [ac_cv_func_which_gethostbyname_r=three])
-
-fi
-
-################################################################
-
-]) dnl end AC_CACHE_VAL
-
-case "$ac_cv_func_which_gethostbyname_r" in
- three|five|six)
- AC_DEFINE([HAVE_GETHOSTBYNAME_R], [1],
- [Define to 1 if you have some form of gethostbyname_r().])
- ;;
-esac
-
-case "$ac_cv_func_which_gethostbyname_r" in
- three)
- AC_MSG_RESULT([three])
- AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_3], [1],
- [Define to 1 if you have the three-argument form of gethostbyname_r().])
- ;;
-
- five)
- AC_MSG_RESULT([five])
- AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_5], [1],
- [Define to 1 if you have the five-argument form of gethostbyname_r().])
- ;;
-
- six)
- AC_MSG_RESULT([six])
- AC_DEFINE([HAVE_FUNC_GETHOSTBYNAME_R_6], [1],
- [Define to 1 if you have the six-argument form of gethostbyname_r().])
- ;;
-
- no)
- AC_MSG_RESULT([cannot find function declaration in netdb.h])
- ;;
-
- unknown)
- AC_MSG_RESULT([can't tell])
- ;;
-
- *)
- AC_MSG_ERROR([internal error])
- ;;
-esac
-
-AC_LANG_POP
-
-]) dnl end AC_DEFUN
diff --git a/TSRM/readdir.h b/TSRM/readdir.h
deleted file mode 100644
index 11c0f31ea1..0000000000
--- a/TSRM/readdir.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* Keep this header for compatibility with external code, it's currently not
- used anywhere in the core and there are no implementations in TSRM. */
-#include "win32/readdir.h"
diff --git a/TSRM/threads.m4 b/TSRM/threads.m4
index 55864c8982..dc5719bbec 100644
--- a/TSRM/threads.m4
+++ b/TSRM/threads.m4
@@ -28,7 +28,7 @@ dnl OF THE POSSIBILITY OF SUCH DAMAGE.
dnl
dnl PTHREADS_FLAGS
dnl
-dnl Set some magic defines to achieve POSIX threads conformance
+dnl Set some magic defines to achieve POSIX threads conformance.
dnl
AC_DEFUN([PTHREADS_FLAGS],[
if test -z "$host_alias" && test -n "$host"; then
@@ -52,18 +52,17 @@ AC_DEFUN([PTHREADS_FLAGS],[
PTHREAD_FLAGS=-D_REENTRANT;;
*sco*)
PTHREAD_FLAGS=-D_REENTRANT;;
-dnl Solves sigwait() problem, creates problems with u_long etc.
-dnl PTHREAD_FLAGS="-D_REENTRANT -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=199506 -D_XOPEN_SOURCE_EXTENDED=1";;
esac
if test -n "$PTHREAD_FLAGS"; then
CPPFLAGS="$CPPFLAGS $PTHREAD_FLAGS"
fi
-])dnl
+])
+
dnl
dnl PTHREADS_CHECK_COMPILE
dnl
-dnl Check whether the current setup can use POSIX threads calls
+dnl Check whether the current setup can use POSIX threads calls.
dnl
AC_DEFUN([PTHREADS_CHECK_COMPILE], [
AC_LINK_IFELSE([ AC_LANG_SOURCE([
@@ -85,11 +84,12 @@ int main() {
], [
pthreads_checked=no
]
-) ] )dnl
+) ] )
+
dnl
-dnl PTHREADS_CHECK()
+dnl PTHREADS_CHECK
dnl
-dnl Try to find a way to enable POSIX threads
+dnl Try to find a way to enable POSIX threads.
dnl
dnl Magic flags
dnl -kthread gcc (FreeBSD)
@@ -102,14 +102,6 @@ dnl -qthreaded AIX cc V5
dnl -threads gcc (HP-UX)
dnl
AC_DEFUN([PTHREADS_CHECK],[
-
-save_CFLAGS=$CFLAGS
-save_LIBS=$LIBS
-PTHREADS_ASSIGN_VARS
-PTHREADS_CHECK_COMPILE
-LIBS=$save_LIBS
-CFLAGS=$save_CFLAGS
-
AC_CACHE_CHECK(for pthreads_cflags,ac_cv_pthreads_cflags,[
ac_cv_pthreads_cflags=
if test "$pthreads_working" != "yes"; then
@@ -145,21 +137,4 @@ fi
if test "x$ac_cv_pthreads_cflags" != "x" -o "x$ac_cv_pthreads_lib" != "x"; then
pthreads_working="yes"
fi
-
-if test "$pthreads_working" = "yes"; then
- threads_result="POSIX-Threads found"
-else
- threads_result="POSIX-Threads not found"
-fi
-])dnl
-dnl
-dnl
-AC_DEFUN([PTHREADS_ASSIGN_VARS],[
-if test -n "$ac_cv_pthreads_lib"; then
- LIBS="$LIBS -l$ac_cv_pthreads_lib"
-fi
-
-if test -n "$ac_cv_pthreads_cflags"; then
- CFLAGS="$CFLAGS $ac_cv_pthreads_cflags"
-fi
-])dnl
+])
diff --git a/TSRM/tsrm.m4 b/TSRM/tsrm.m4
index d02f88ee94..0330d7a7da 100644
--- a/TSRM/tsrm.m4
+++ b/TSRM/tsrm.m4
@@ -1,23 +1,9 @@
-m4_include([TSRM/m4/ax_func_which_gethostbyname_r.m4])
-
-AC_DEFUN([TSRM_BASIC_CHECKS],[
-
-AC_REQUIRE([AC_PROG_CC])dnl
-dnl AC_REQUIRE([AM_PROG_CC_STDC])dnl
-AC_REQUIRE([AC_PROG_CC_C_O])dnl
-AC_REQUIRE([AC_PROG_RANLIB])dnl
-
-AC_CHECK_HEADERS(stdarg.h)
-
-AC_CHECK_FUNCS(sigprocmask)
-
-AX_FUNC_WHICH_GETHOSTBYNAME_R()
-
-])
-
+dnl This file contains TSRM specific autoconf macros.
+dnl
+dnl TSRM_CHECK_PTH
+dnl
AC_DEFUN([TSRM_CHECK_PTH],[
-
AC_MSG_CHECKING(for GNU Pth)
PTH_PREFIX="`$1 --prefix`"
if test -z "$PTH_PREFIX"; then
@@ -30,9 +16,11 @@ LIBS="$LIBS `$1 --libs`"
AC_DEFINE(GNUPTH, 1, [Whether you use GNU Pth])
AC_MSG_RESULT(yes - installed in $PTH_PREFIX)
-
])
+dnl
+dnl TSRM_CHECK_ST
+dnl
AC_DEFUN([TSRM_CHECK_ST],[
if test -r "$1/include/st.h"; then
CPPFLAGS="$CPPFLAGS -I$1/include"
@@ -50,10 +38,10 @@ AC_DEFUN([TSRM_CHECK_ST],[
AC_DEFINE(TSRM_ST, 1, [ ])
])
-sinclude(threads.m4)
-
+dnl
+dnl TSRM_CHECK_PTHREADS
+dnl
AC_DEFUN([TSRM_CHECK_PTHREADS],[
-
PTHREADS_CHECK
if test "$pthreads_working" != "yes"; then
@@ -66,32 +54,30 @@ AC_MSG_CHECKING(for POSIX threads)
AC_MSG_RESULT(yes)
])
+dnl
+dnl TSRM_THREADS_CHECKS
+dnl
+dnl For the thread implementations, we always use --with-* to maintain
+dnl consistency.
+dnl
AC_DEFUN([TSRM_THREADS_CHECKS],[
-
-dnl For the thread implementations, we always use --with-*
-dnl to maintain consistency
-
-AC_ARG_WITH(tsrm-pth,
-[ --with-tsrm-pth[=pth-config]
- Use GNU Pth],[
- TSRM_PTH=$withval
-],[
- TSRM_PTH=no
-])
-
-AC_ARG_WITH(tsrm-st,
-[ --with-tsrm-st Use SGI's State Threads],[
- TSRM_ST=$withval
-],[
- TSRM_ST=no
-])
-
-AC_ARG_WITH(tsrm-pthreads,
-[ --with-tsrm-pthreads Use POSIX threads (default)],[
- TSRM_PTHREADS=$withval
-],[
- TSRM_PTHREADS=yes
-])
+AC_ARG_WITH([tsrm-pth],
+ [AS_HELP_STRING([[--with-tsrm-pth[=pth-config]]],
+ [Use GNU Pth])],
+ [TSRM_PTH=$withval],
+ [TSRM_PTH=no])
+
+AC_ARG_WITH([tsrm-st],
+ [AS_HELP_STRING([--with-tsrm-st],
+ [Use SGI's State Threads])],
+ [TSRM_ST=$withval],
+ [TSRM_ST=no])
+
+AC_ARG_WITH([tsrm-pthreads],
+ [AS_HELP_STRING([--with-tsrm-pthreads],
+ [Use POSIX threads (default)])],
+ [TSRM_PTHREADS=$withval],
+ [TSRM_PTHREADS=yes])
test "$TSRM_PTH" = "yes" && TSRM_PTH=pth-config
@@ -102,5 +88,4 @@ elif test "$TSRM_ST" != "no"; then
elif test "$TSRM_PTHREADS" != "no"; then
TSRM_CHECK_PTHREADS
fi
-
])
diff --git a/TSRM/tsrm_config.w32.h b/TSRM/tsrm_config.w32.h
deleted file mode 100644
index ab45141179..0000000000
--- a/TSRM/tsrm_config.w32.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef TSRM_CONFIG_W32_H
-#define TSRM_CONFIG_W32_H
-
-#include <../main/config.w32.h>
-#include "Zend/zend_config.w32.h"
-
-#define HAVE_UTIME 1
-#define HAVE_ALLOCA 1
-
-#include <malloc.h>
-#include <stdlib.h>
-#include <crtdbg.h>
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/TSRM/tsrm_config_common.h b/TSRM/tsrm_config_common.h
deleted file mode 100644
index f70f7a5c41..0000000000
--- a/TSRM/tsrm_config_common.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef TSRM_CONFIG_COMMON_H
-#define TSRM_CONFIG_COMMON_H
-
-#ifndef __CYGWIN__
-# ifdef _WIN32
-# define TSRM_WIN32
-# endif
-#endif
-
-#ifdef TSRM_WIN32
-# include "tsrm_config.w32.h"
-#else
-# include <tsrm_config.h>
-# include <sys/param.h>
-#endif
-
-#if HAVE_ALLOCA_H && !defined(_ALLOCA_H)
-# include <alloca.h>
-#endif
-
-/* AIX requires this to be the first thing in the file. */
-#ifndef __GNUC__
-# ifndef HAVE_ALLOCA_H
-# ifdef _AIX
-#pragma alloca
-# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
-# endif
-# endif
-# endif
-#endif
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#ifndef MAXPATHLEN
-# if _WIN32
-# include "win32/ioutil.h"
-# define MAXPATHLEN PHP_WIN32_IOUTIL_MAXPATHLEN
-# elif PATH_MAX
-# define MAXPATHLEN PATH_MAX
-# elif defined(MAX_PATH)
-# define MAXPATHLEN MAX_PATH
-# else
-# define MAXPATHLEN 256
-# endif
-#endif
-
-#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2))
-# define TSRM_ALLOCA_MAX_SIZE 4096
-# define TSRM_ALLOCA_FLAG(name) \
- int name;
-# define tsrm_do_alloca_ex(size, limit, use_heap) \
- ((use_heap = ((size) > (limit))) ? malloc(size) : alloca(size))
-# define tsrm_do_alloca(size, use_heap) \
- tsrm_do_alloca_ex(size, TSRM_ALLOCA_MAX_SIZE, use_heap)
-# define tsrm_free_alloca(p, use_heap) \
- do { if (use_heap) free(p); } while (0)
-#else
-# define TSRM_ALLOCA_FLAG(name)
-# define tsrm_do_alloca(p, use_heap) malloc(p)
-# define tsrm_free_alloca(p, use_heap) free(p)
-#endif
-
-#endif /* TSRM_CONFIG_COMMON_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/TSRM/tsrm_strtok_r.c b/TSRM/tsrm_strtok_r.c
deleted file mode 100644
index cf0b0e672c..0000000000
--- a/TSRM/tsrm_strtok_r.c
+++ /dev/null
@@ -1,72 +0,0 @@
-#include <stdio.h>
-
-#include "tsrm_config_common.h"
-#include "tsrm_strtok_r.h"
-
-static inline int in_character_class(char ch, const char *delim)
-{/*{{{*/
- while (*delim) {
- if (*delim == ch) {
- return 1;
- }
- delim++;
- }
- return 0;
-}/*}}}*/
-
-TSRM_API char *tsrm_strtok_r(char *s, const char *delim, char **last)
-{/*{{{*/
- char *token;
-
- if (s == NULL) {
- s = *last;
- }
-
- while (*s && in_character_class(*s, delim)) {
- s++;
- }
- if (!*s) {
- return NULL;
- }
-
- token = s;
-
- while (*s && !in_character_class(*s, delim)) {
- s++;
- }
- if (!*s) {
- *last = s;
- } else {
- *s = '\0';
- *last = s + 1;
- }
- return token;
-}/*}}}*/
-
-#if 0
-
-main()
-{
- char foo[] = "/foo/bar//\\barbara";
- char *last;
- char *token;
-
- token = tsrm_strtok_r(foo, "/\\", &last);
- while (token) {
- printf ("Token = '%s'\n", token);
- token = tsrm_strtok_r(NULL, "/\\", &last);
- }
-
- return 0;
-}
-
-#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/TSRM/tsrm_strtok_r.h b/TSRM/tsrm_strtok_r.h
deleted file mode 100644
index 323b401d99..0000000000
--- a/TSRM/tsrm_strtok_r.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef TSRM_STRTOK_R
-#define TSRM_STRTOK_R
-
-#include "TSRM.h"
-
-TSRM_API char *tsrm_strtok_r(char *s, const char *delim, char **last);
-
-#endif
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index 6cedaa8360..75240282f6 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -458,7 +458,6 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
process_pair *proc;
char *cmd = NULL;
wchar_t *cmdw = NULL, *cwdw = NULL, *envw = NULL;
- int i;
char *ptype = (char *)type;
HANDLE thread_token = NULL;
HANDLE token_user = NULL;
@@ -468,17 +467,17 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
return NULL;
}
- /*The following two checks can be removed once we drop XP support */
type_len = (int)strlen(type);
- if (type_len <1 || type_len > 2) {
+ if (type_len < 1 || type_len > 2) {
return NULL;
}
- for (i=0; i < type_len; i++) {
- if (!(*ptype == 'r' || *ptype == 'w' || *ptype == 'b' || *ptype == 't')) {
- return NULL;
- }
- ptype++;
+ if (ptype[0] != 'r' && ptype[0] != 'w') {
+ return NULL;
+ }
+
+ if (type_len > 1 && (ptype[1] != 'b' && ptype[1] != 't')) {
+ return NULL;
}
cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c ")+2);
@@ -828,12 +827,3 @@ TSRM_API int win32_utime(const char *filename, struct utimbuf *buf) /* {{{ */
/* }}} */
#endif
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/TSRM/tsrm_win32.h b/TSRM/tsrm_win32.h
index b24224c66a..1ae9beaf2c 100644
--- a/TSRM/tsrm_win32.h
+++ b/TSRM/tsrm_win32.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -109,12 +109,3 @@ TSRM_API void *shmat(int key, const void *shmaddr, int flags);
TSRM_API int shmdt(const void *shmaddr);
TSRM_API int shmctl(int key, int cmd, struct shmid_ds *buf);
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */