summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2001-06-21 16:54:05 +0000
committerSascha Schumann <sas@php.net>2001-06-21 16:54:05 +0000
commit6ae7e5f54a0bb8ab292dd1b5e2cff60ff04fd481 (patch)
tree5ef0f941598f52cb820c9ed698e2b210471c1795 /TSRM
parent851b1e3b357be98569f74404cf7a7e5377c0ab2c (diff)
downloadphp-git-6ae7e5f54a0bb8ab292dd1b5e2cff60ff04fd481.tar.gz
Support for SGI's State Threads. Will be used by PHP's thttpd SAPI
initially.
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/TSRM.c25
-rw-r--r--TSRM/TSRM.h5
-rw-r--r--TSRM/tsrm.m426
3 files changed, 54 insertions, 2 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
index ac7033c0b1..d96165001d 100644
--- a/TSRM/TSRM.c
+++ b/TSRM/TSRM.c
@@ -75,6 +75,8 @@ static FILE *tsrm_error_file;
#if defined(PTHREADS)
/* Thread local storage */
static pthread_key_t tls_key;
+#elif defined(TSRM_ST)
+static int tls_key;
#endif
@@ -85,6 +87,9 @@ TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debu
pth_init();
#elif defined(PTHREADS)
pthread_key_create( &tls_key, 0 );
+#elif defined(TSRM_ST)
+ st_init();
+ st_key_create(&tls_key, 0);
#endif
tsrm_error_file = stderr;
@@ -227,6 +232,8 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
#if defined(PTHREADS)
/* Set thread local storage to this new thread resources structure */
pthread_setspecific( tls_key, (void *)*thread_resources_ptr );
+#elif defined(TSRM_ST)
+ st_thread_setspecific(tls_key, (void *) *thread_resources_ptr);
#endif
if (tsrm_new_thread_begin_handler) {
@@ -262,11 +269,15 @@ TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id)
* and our hashtable lookup.
*/
thread_resources = pthread_getspecific( tls_key );
+#elif defined(TSRM_ST)
+ thread_resources = st_thread_getspecific(tls_key);
+#else
+ thread_resources = NULL;
+#endif
if (thread_resources) {
TSRM_ERROR(TSRM_ERROR_LEVEL_INFO, "Fetching resource id %d for current thread %d", id, (long) thread_resources->thread_id );
return ts_resource_read( thread_resources, id );
}
-#endif
thread_id = tsrm_thread_id();
} else {
thread_id = *th_id;
@@ -391,6 +402,8 @@ TSRM_API THREAD_T tsrm_thread_id(void)
return systhread_current();
#elif defined(PI3WEB)
return PIThread_getCurrent();
+#elif defined(TSRM_ST)
+ return st_thread_self();
#endif
}
@@ -413,6 +426,8 @@ TSRM_API MUTEX_T tsrm_mutex_alloc(void)
mutexp = crit_init();
#elif defined(PI3WEB)
mutexp = PIPlatform_allocLocalMutex();
+#elif defined(TSRM_ST)
+ mutexp = st_mutex_new();
#endif
#ifdef THR_DEBUG
printf("Mutex created thread: %d\n",mythreadid());
@@ -435,7 +450,9 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp)
#elif defined(NSAPI)
crit_terminate(mutexp);
#elif defined(PI3WEB)
- PISync_delete(mutexp)
+ PISync_delete(mutexp);
+#elif defined(TSRM_ST)
+ st_mutex_destroy(mutexp);
#endif
}
#ifdef THR_DEBUG
@@ -459,6 +476,8 @@ TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp)
return crit_enter(mutexp);
#elif defined(PI3WEB)
return PISync_lock(mutexp);
+#elif defined(TSRM_ST)
+ return st_mutex_lock(mutexp);
#endif
}
@@ -478,6 +497,8 @@ TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
return crit_exit(mutexp);
#elif defined(PI3WEB)
return PISync_unlock(mutexp);
+#elif defined(TSRM_ST)
+ return st_mutex_unlock(mutexp);
#endif
}
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h
index fa789b6732..00a61157ee 100644
--- a/TSRM/TSRM.h
+++ b/TSRM/TSRM.h
@@ -30,6 +30,8 @@
# include <pth.h>
#elif defined(PTHREADS)
# include <pthread.h>
+#elif defined(TSRM_ST)
+# include <st.h>
#endif
typedef int ts_rsrc_id;
@@ -61,6 +63,9 @@ typedef int ts_rsrc_id;
#elif defined(PI3WEB)
# define THREAD_T PIThread *
# define MUTEX_T PISync *
+#elif defined(TSRM_ST)
+# define THREAD_T st_thread_t
+# define MUTEX_T st_mutex_t
#endif
typedef void (*ts_allocate_ctor)(void *);
diff --git a/TSRM/tsrm.m4 b/TSRM/tsrm.m4
index 73a67ba7c8..16a0baf37b 100644
--- a/TSRM/tsrm.m4
+++ b/TSRM/tsrm.m4
@@ -50,6 +50,23 @@ AC_MSG_RESULT(yes - installed in $PTH_PREFIX)
])
+AC_DEFUN(TSRM_CHECK_ST,[
+ if test -r "$1/include/st.h"; then
+ CPPFLAGS="$CPPFLAGS -I$1/include"
+ LDFLAGS="$LDFLAGS -L$1/lib"
+ elif test -r "$1/st.h"; then
+ CPPFLAGS="$CPPFLAGS -I$1"
+ LDFLAGS="$LDFLAGS -L$1"
+ fi
+ AC_CHECK_HEADERS(st.h,[ ],[
+ AC_MSG_ERROR([Sorry[,] I was unable to locate the State Threads header file. Please specify the prefix using --with-tsrm-st=/prefix])
+ ])
+ LIBS="$LIBS -lst"
+ AC_MSG_CHECKING(for SGI's State Threads)
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(TSRM_ST, 1, [ ])
+])
+
sinclude(threads.m4)
sinclude(TSRM/threads.m4)
@@ -80,6 +97,13 @@ AC_ARG_WITH(tsrm-pth,
TSRM_PTH=no
])
+AC_ARG_WITH(tsrm-st,
+[ --with-tsrm-st],[
+ TSRM_ST=$withval
+],[
+ TSRM_ST=no
+])
+
AC_ARG_WITH(tsrm-pthreads,
[ --with-tsrm-pthreads Use POSIX threads (default)],[
TSRM_PTHREADS=$withval
@@ -91,6 +115,8 @@ test "$TSRM_PTH" = "yes" && TSRM_PTH=pth-config
if test "$TSRM_PTH" != "no"; then
TSRM_CHECK_PTH($TSRM_PTH)
+elif test "$TSRM_ST" != "no"; then
+ TSRM_CHECK_ST($TSRM_ST)
elif test "$TSRM_PTHREADS" != "no"; then
TSRM_CHECK_PTHREADS
fi