summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-02-01 21:25:15 +0100
committerOndřej Surý <ondrej@sury.org>2012-02-01 21:25:15 +0100
commit96fb2ff5760132a915766f1d9ec7c63001feacd8 (patch)
tree160904a89a8f3522fa4e47632db101b045e7814a /TSRM
parent8f1428d29ef91d74b4d272af171675f2971eb15b (diff)
downloadphp-96fb2ff5760132a915766f1d9ec7c63001feacd8.tar.gz
Imported Upstream version 5.4.0~rc6upstream/5.4.0_rc6
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/TSRM.c16
-rw-r--r--TSRM/TSRM.h7
-rw-r--r--TSRM/acconfig.h1
-rw-r--r--TSRM/build.mk4
-rw-r--r--TSRM/config.w322
-rw-r--r--TSRM/configure.in6
-rw-r--r--TSRM/tsrm.m42
-rw-r--r--TSRM/tsrm_virtual_cwd.c58
-rw-r--r--TSRM/tsrm_virtual_cwd.h10
-rw-r--r--TSRM/tsrm_win32.c12
-rw-r--r--TSRM/tsrm_win32.h4
11 files changed, 67 insertions, 55 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c
index 41368a498..efdea5c88 100644
--- a/TSRM/TSRM.c
+++ b/TSRM/TSRM.c
@@ -710,6 +710,22 @@ TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
#endif
}
+/*
+ Changes the signal mask of the calling thread
+*/
+#ifdef HAVE_SIGPROCMASK
+TSRM_API int tsrm_sigmask(int how, const sigset_t *set, sigset_t *oldset)
+{
+ TSRM_ERROR((TSRM_ERROR_LEVEL_INFO, "Changed sigmask in thread: %ld", tsrm_thread_id()));
+ /* TODO: add support for other APIs */
+#ifdef PTHREADS
+ return pthread_sigmask(how, set, oldset);
+#else
+ return sigprocmask(how, set, oldset);
+#endif
+}
+#endif
+
TSRM_API void *tsrm_set_new_thread_begin_handler(tsrm_thread_begin_func_t new_thread_begin_handler)
{
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h
index d3d6f9b2d..b232429d4 100644
--- a/TSRM/TSRM.h
+++ b/TSRM/TSRM.h
@@ -90,6 +90,10 @@ typedef struct {
# define MUTEX_T beos_ben *
#endif
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
typedef void (*ts_allocate_ctor)(void *, void ***);
typedef void (*ts_allocate_dtor)(void *, void ***);
@@ -138,6 +142,9 @@ TSRM_API MUTEX_T tsrm_mutex_alloc(void);
TSRM_API void tsrm_mutex_free(MUTEX_T mutexp);
TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp);
TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp);
+#ifdef HAVE_SIGPROCMASK
+TSRM_API int tsrm_sigmask(int how, const sigset_t *set, sigset_t *oldset);
+#endif
TSRM_API void *tsrm_set_new_thread_begin_handler(tsrm_thread_begin_func_t new_thread_begin_handler);
TSRM_API void *tsrm_set_new_thread_end_handler(tsrm_thread_end_func_t new_thread_end_handler);
diff --git a/TSRM/acconfig.h b/TSRM/acconfig.h
deleted file mode 100644
index 2b94cf35e..000000000
--- a/TSRM/acconfig.h
+++ /dev/null
@@ -1 +0,0 @@
-#undef PTHREADS
diff --git a/TSRM/build.mk b/TSRM/build.mk
index 5cd3aa9a7..798ad286e 100644
--- a/TSRM/build.mk
+++ b/TSRM/build.mk
@@ -5,7 +5,7 @@
#
# Written by Sascha Schumann
#
-# $Id: build.mk 14329 1999-10-10 02:02:13Z sascha $
+# $Id: build.mk 311067 2011-05-16 00:14:47Z rasmus $
LT_TARGETS = ltmain.sh ltconfig
@@ -33,7 +33,7 @@ $(makefile_in_files): $(makefile_am_files)
aclocal.m4: configure.in acinclude.m4
aclocal
-$(config_h_in): configure.in acconfig.h
+$(config_h_in): configure.in
# explicitly remove target since autoheader does not seem to work
# correctly otherwise (timestamps are not updated)
@rm -f $@
diff --git a/TSRM/config.w32 b/TSRM/config.w32
index 8a3b49db8..556ad1be0 100644
--- a/TSRM/config.w32
+++ b/TSRM/config.w32
@@ -1,5 +1,5 @@
// vim:ft=javascript
-// $Id: config.w32 298737 2010-04-28 22:25:31Z pajoye $
+// $Id: config.w32 298738 2010-04-28 22:26:08Z pajoye $
ADD_SOURCES("TSRM", "TSRM.c tsrm_strtok_r.c tsrm_virtual_cwd.c tsrm_win32.c");
diff --git a/TSRM/configure.in b/TSRM/configure.in
index 6705f583d..4dd3d94f6 100644
--- a/TSRM/configure.in
+++ b/TSRM/configure.in
@@ -1,4 +1,4 @@
-dnl $Id: configure.in 53832 2001-08-08 10:26:21Z zeev $
+dnl $Id: configure.in 311067 2011-05-16 00:14:47Z rasmus $
dnl
dnl Minimalistic configure.in for TSRM.
dnl
@@ -7,6 +7,10 @@ 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
diff --git a/TSRM/tsrm.m4 b/TSRM/tsrm.m4
index 85e6a83a8..b53a4bb80 100644
--- a/TSRM/tsrm.m4
+++ b/TSRM/tsrm.m4
@@ -30,6 +30,8 @@ AC_REQUIRE([AC_PROG_RANLIB])dnl
AC_CHECK_HEADERS(stdarg.h)
+AC_CHECK_FUNCS(sigprocmask)
+
])
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index 29f59bdba..27474e43c 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -277,18 +277,6 @@ CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){
}
/* }}} */
-CWD_API int php_sys_stat(const char *path, struct stat *buf) /* {{{ */
-{
- return php_sys_stat_ex(path, buf, 0);
-}
-/* }}} */
-
-CWD_API int php_sys_lstat(const char *path, struct stat *buf) /* {{{ */
-{
- return php_sys_stat_ex(path, buf, 1);
-}
-/* }}} */
-
CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat) /* {{{ */
{
WIN32_FILE_ATTRIBUTE_DATA data;
@@ -718,7 +706,6 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p
} else {
CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1;
}
-
free(r);
} else if (key == (*bucket)->key && path_len == (*bucket)->path_len &&
memcmp(path, (*bucket)->path, path_len) == 0) {
@@ -1145,7 +1132,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
/* Resolve path relatively to state and put the real path into state */
/* returns 0 for ok, 1 for error */
-CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath) /* {{{ */
+CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath TSRMLS_DC) /* {{{ */
{
int path_length = strlen(path);
char resolved_path[MAXPATHLEN];
@@ -1155,7 +1142,6 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
int ret;
int add_slash;
void *tmp;
- TSRMLS_FETCH();
if (path_length == 0 || path_length >= MAXPATHLEN-1) {
#ifdef TSRM_WIN32
@@ -1351,7 +1337,7 @@ verify:
CWD_API int virtual_chdir(const char *path TSRMLS_DC) /* {{{ */
{
- return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH)?-1:0;
+ return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok, CWD_REALPATH TSRMLS_CC)?-1:0;
}
/* }}} */
@@ -1419,7 +1405,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path TSRMLS_DC) /* {
new_state.cwd_length = 0;
}
- if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)==0) {
+ if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)==0) {
int len = new_state.cwd_length>MAXPATHLEN-1?MAXPATHLEN-1:new_state.cwd_length;
memcpy(real_path, new_state.cwd, len);
@@ -1441,7 +1427,7 @@ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_f
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- retval = virtual_file_ex(&new_state, path, verify_path, CWD_FILEPATH);
+ retval = virtual_file_ex(&new_state, path, verify_path, CWD_FILEPATH TSRMLS_CC);
*filepath = new_state.cwd;
@@ -1466,7 +1452,7 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode TSRMLS_DC) /* {{{
}
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, path, NULL, CWD_FILEPATH)) {
+ if (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return NULL;
}
@@ -1484,13 +1470,13 @@ CWD_API int virtual_access(const char *pathname, int mode TSRMLS_DC) /* {{{ */
int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, pathname, NULL, CWD_REALPATH)) {
+ if (virtual_file_ex(&new_state, pathname, NULL, CWD_REALPATH TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return -1;
}
#if defined(TSRM_WIN32)
- ret = tsrm_win32_access(new_state.cwd, mode);
+ ret = tsrm_win32_access(new_state.cwd, mode TSRMLS_CC);
#else
ret = access(new_state.cwd, mode);
#endif
@@ -1557,7 +1543,7 @@ CWD_API int virtual_utime(const char *filename, struct utimbuf *buf TSRMLS_DC) /
int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH)) {
+ if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return -1;
}
@@ -1580,7 +1566,7 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC) /* {{{ */
int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH)) {
+ if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return -1;
}
@@ -1599,7 +1585,7 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int li
int ret;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH)) {
+ if (virtual_file_ex(&new_state, filename, NULL, CWD_REALPATH TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return -1;
}
@@ -1626,7 +1612,7 @@ CWD_API int virtual_open(const char *path TSRMLS_DC, int flags, ...) /* {{{ */
int f;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, path, NULL, CWD_FILEPATH)) {
+ if (virtual_file_ex(&new_state, path, NULL, CWD_FILEPATH TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return -1;
}
@@ -1654,7 +1640,7 @@ CWD_API int virtual_creat(const char *path, mode_t mode TSRMLS_DC) /* {{{ */
int f;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, path, NULL, CWD_FILEPATH)) {
+ if (virtual_file_ex(&new_state, path, NULL, CWD_FILEPATH TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return -1;
}
@@ -1673,14 +1659,14 @@ CWD_API int virtual_rename(char *oldname, char *newname TSRMLS_DC) /* {{{ */
int retval;
CWD_STATE_COPY(&old_state, &CWDG(cwd));
- if (virtual_file_ex(&old_state, oldname, NULL, CWD_EXPAND)) {
+ if (virtual_file_ex(&old_state, oldname, NULL, CWD_EXPAND TSRMLS_CC)) {
CWD_STATE_FREE(&old_state);
return -1;
}
oldname = old_state.cwd;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, newname, NULL, CWD_EXPAND)) {
+ if (virtual_file_ex(&new_state, newname, NULL, CWD_EXPAND TSRMLS_CC)) {
CWD_STATE_FREE(&old_state);
CWD_STATE_FREE(&new_state);
return -1;
@@ -1709,7 +1695,7 @@ CWD_API int virtual_stat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ */
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)) {
+ if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return -1;
}
@@ -1727,7 +1713,7 @@ CWD_API int virtual_lstat(const char *path, struct stat *buf TSRMLS_DC) /* {{{ *
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND)) {
+ if (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return -1;
}
@@ -1745,7 +1731,7 @@ CWD_API int virtual_unlink(const char *path TSRMLS_DC) /* {{{ */
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND)) {
+ if (virtual_file_ex(&new_state, path, NULL, CWD_EXPAND TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return -1;
}
@@ -1763,7 +1749,7 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode TSRMLS_DC) /* {{{ */
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, pathname, NULL, CWD_FILEPATH)) {
+ if (virtual_file_ex(&new_state, pathname, NULL, CWD_FILEPATH TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return -1;
}
@@ -1784,7 +1770,7 @@ CWD_API int virtual_rmdir(const char *pathname TSRMLS_DC) /* {{{ */
int retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, pathname, NULL, CWD_EXPAND)) {
+ if (virtual_file_ex(&new_state, pathname, NULL, CWD_EXPAND TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return -1;
}
@@ -1806,7 +1792,7 @@ CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC) /* {{{ */
DIR *retval;
CWD_STATE_COPY(&new_state, &CWDG(cwd));
- if (virtual_file_ex(&new_state, pathname, NULL, CWD_REALPATH)) {
+ if (virtual_file_ex(&new_state, pathname, NULL, CWD_REALPATH TSRMLS_CC)) {
CWD_STATE_FREE(&new_state);
return NULL;
}
@@ -1821,7 +1807,7 @@ CWD_API DIR *virtual_opendir(const char *pathname TSRMLS_DC) /* {{{ */
#ifdef TSRM_WIN32
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /* {{{ */
{
- return popen_ex(command, type, CWDG(cwd).cwd, NULL);
+ return popen_ex(command, type, CWDG(cwd).cwd, NULL TSRMLS_CC);
}
/* }}} */
#elif defined(NETWARE)
@@ -1944,7 +1930,7 @@ CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{
new_state.cwd_length = 0;
}
- if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH)) {
+ if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)) {
free(new_state.cwd);
return NULL;
}
diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h
index 505a2aad8..cef3d0c22 100644
--- a/TSRM/tsrm_virtual_cwd.h
+++ b/TSRM/tsrm_virtual_cwd.h
@@ -131,8 +131,8 @@ typedef unsigned short mode_t;
#ifdef TSRM_WIN32
CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat);
-CWD_API int php_sys_stat(const char *path, struct stat *buf);
-CWD_API int php_sys_lstat(const char *path, struct stat *buf);
+# define php_sys_stat(path, buf) php_sys_stat_ex(path, buf, 0)
+# define php_sys_lstat(path, buf) php_sys_stat_ex(path, buf, 1)
CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len);
#else
# define php_sys_stat stat
@@ -201,7 +201,7 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int li
#define CWD_FILEPATH 1 /* resolve symlinks if file is exist otherwise expand */
#define CWD_REALPATH 2 /* call realpath(), resolve symlinks. File must exist */
-CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath);
+CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath TSRMLS_DC);
CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC);
@@ -267,7 +267,7 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D);
#define VCWD_REALPATH(path, real_path) virtual_realpath(path, real_path TSRMLS_CC)
#define VCWD_RENAME(oldname, newname) virtual_rename(oldname, newname TSRMLS_CC)
#define VCWD_STAT(path, buff) virtual_stat(path, buff TSRMLS_CC)
-#define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
+# define VCWD_LSTAT(path, buff) virtual_lstat(path, buff TSRMLS_CC)
#define VCWD_UNLINK(path) virtual_unlink(path TSRMLS_CC)
#define VCWD_MKDIR(pathname, mode) virtual_mkdir(pathname, mode TSRMLS_CC)
#define VCWD_RMDIR(pathname) virtual_rmdir(pathname TSRMLS_CC)
@@ -310,7 +310,7 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D);
#define VCWD_OPENDIR(pathname) opendir(pathname)
#define VCWD_POPEN(command, type) popen(command, type)
#if defined(TSRM_WIN32)
-#define VCWD_ACCESS(pathname, mode) tsrm_win32_access(pathname, mode)
+#define VCWD_ACCESS(pathname, mode) tsrm_win32_access(pathname, mode TSRMLS_CC)
#else
#define VCWD_ACCESS(pathname, mode) access(pathname, mode)
#endif
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index e7a7fd9d7..ecf918635 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -190,7 +190,7 @@ Finished:
return NULL;
}
-TSRM_API int tsrm_win32_access(const char *pathname, int mode)
+TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC)
{
time_t t;
HANDLE thread_token;
@@ -208,8 +208,6 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
realpath_cache_bucket * bucket = NULL;
char * real_path = NULL;
- TSRMLS_FETCH();
-
if (mode == 1 /*X_OK*/) {
DWORD type;
return GetBinaryType(pathname, &type) ? 0 : -1;
@@ -448,10 +446,12 @@ static HANDLE dupHandle(HANDLE fh, BOOL inherit) {
TSRM_API FILE *popen(const char *command, const char *type)
{
- return popen_ex(command, type, NULL, NULL);
+ TSRMLS_FETCH();
+
+ return popen_ex(command, type, NULL, NULL TSRMLS_CC);
}
-TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env)
+TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env TSRMLS_DC)
{
FILE *stream = NULL;
int fno, type_len = strlen(type), read, mode;
@@ -469,8 +469,6 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
HANDLE token_user = NULL;
BOOL asuser = TRUE;
- TSRMLS_FETCH();
-
if (!type) {
return NULL;
}
diff --git a/TSRM/tsrm_win32.h b/TSRM/tsrm_win32.h
index 74ecb9e7a..0507c0b64 100644
--- a/TSRM/tsrm_win32.h
+++ b/TSRM/tsrm_win32.h
@@ -95,10 +95,10 @@ char * tsrm_win32_get_path_sid_key(const char *pathname TSRMLS_DC);
TSRM_API void tsrm_win32_startup(void);
TSRM_API void tsrm_win32_shutdown(void);
-TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env);
+TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd, char *env TSRMLS_DC);
TSRM_API FILE *popen(const char *command, const char *type);
TSRM_API int pclose(FILE *stream);
-TSRM_API int tsrm_win32_access(const char *pathname, int mode);
+TSRM_API int tsrm_win32_access(const char *pathname, int mode TSRMLS_DC);
TSRM_API int win32_utime(const char *filename, struct utimbuf *buf);
TSRM_API int shmget(int key, int size, int flags);