diff options
author | Zeev Suraski <zeev@php.net> | 2001-07-28 10:46:11 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 2001-07-28 10:46:11 +0000 |
commit | 633a1c30d115baa6436883ff44fd5abb127e0a7f (patch) | |
tree | ec7c704409b6bcde0d8ec2c551bb20866e2e6770 /TSRM | |
parent | adb1fa5a4cf74be70a517df8414acb418d52d823 (diff) | |
download | php-git-633a1c30d115baa6436883ff44fd5abb127e0a7f.tar.gz |
Redesigned thread safety mechanism - nua nua
Diffstat (limited to 'TSRM')
-rw-r--r-- | TSRM/TSRM.h | 30 | ||||
-rw-r--r-- | TSRM/tsrm_virtual_cwd.c | 40 | ||||
-rw-r--r-- | TSRM/tsrm_virtual_cwd.h | 12 | ||||
-rw-r--r-- | TSRM/tsrm_win32.c | 4 | ||||
-rw-r--r-- | TSRM/tsrm_win32.h | 5 |
5 files changed, 41 insertions, 50 deletions
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index 2e6c481d46..9cfc9820e8 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -17,6 +17,17 @@ # include "tsrm_config.h" #endif + +#ifdef TSRM_WIN32 +# ifdef TSRM_EXPORTS +# define TSRM_API __declspec(dllexport) +# else +# define TSRM_API __declspec(dllimport) +# endif +#else +# define TSRM_API +#endif + /* Only compile multi-threading functions if we're in ZTS mode */ #ifdef ZTS @@ -36,17 +47,6 @@ typedef int ts_rsrc_id; -#ifdef TSRM_WIN32 -# ifdef TSRM_EXPORTS -# define TSRM_API __declspec(dllexport) -# else -# define TSRM_API __declspec(dllimport) -# endif -#else -# define TSRM_API -#endif - - /* Define THREAD_T and MUTEX_T */ #ifdef TSRM_WIN32 # define THREAD_T DWORD @@ -115,8 +115,8 @@ TSRM_API void *tsrm_set_new_thread_end_handler(void (*new_thread_end_handler)(TH #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 = ts_resource_ex(0, NULL) -#define TSRMG(id, type, element) (((type) (*tsrm_ls)[TSRM_UNSHUFFLE_RSRC_ID(id)])->element) +#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 TSRMLS_D void ***tsrm_ls #define TSRMLS_DC , TSRMLS_D #define TSRMLS_C tsrm_ls @@ -126,13 +126,13 @@ TSRM_API void *tsrm_set_new_thread_end_handler(void (*new_thread_end_handler)(TH } #endif -#else +#else /* non ZTS */ +#define TSRMLS_FETCH() #define TSRMLS_D #define TSRMLS_DC #define TSRMLS_C #define TSRMLS_CC -#define TSRMLS_FETCH() #endif /* ZTS */ diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index 2c899ee667..ce2e75a0e7 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -38,7 +38,9 @@ #define VIRTUAL_CWD_DEBUG 0 +#ifdef ZTS #include "TSRM.h" +#endif /* Only need mutex for popen() in Windows because it doesn't chdir() on UNIX */ #if defined(TSRM_WIN32) && defined(ZTS) @@ -201,7 +203,7 @@ CWD_API void virtual_cwd_shutdown(void) CWD_API char *virtual_getcwd_ex(size_t *length) { cwd_state *state; - CWDLS_FETCH(); + TSRMLS_FETCH(); state = &CWDG(cwd); @@ -405,7 +407,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func CWD_API int virtual_chdir(const char *path) { - CWDLS_FETCH(); + TSRMLS_FETCH(); return virtual_file_ex(&CWDG(cwd), path, php_is_dir_ok)?-1:0; } @@ -446,7 +448,7 @@ CWD_API char *virtual_realpath(const char *path, char *real_path) { cwd_state new_state; int retval; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); retval = virtual_file_ex(&new_state, path, NULL); @@ -465,7 +467,7 @@ CWD_API int virtual_filepath_ex(const char *path, char **filepath, verify_path_f { cwd_state new_state; int retval; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); retval = virtual_file_ex(&new_state, path, verify_path); @@ -485,7 +487,7 @@ CWD_API FILE *virtual_fopen(const char *path, const char *mode) { cwd_state new_state; FILE *f; - CWDLS_FETCH(); + TSRMLS_FETCH(); if (path[0] == '\0') { /* Fail to open empty path */ return NULL; @@ -505,7 +507,7 @@ CWD_API int virtual_utime(const char *filename, struct utimbuf *buf) { cwd_state new_state; int ret; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); virtual_file_ex(&new_state, filename, NULL); @@ -521,7 +523,7 @@ CWD_API int virtual_chmod(const char *filename, mode_t mode) { cwd_state new_state; int ret; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); virtual_file_ex(&new_state, filename, NULL); @@ -537,7 +539,7 @@ CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group) { cwd_state new_state; int ret; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); virtual_file_ex(&new_state, filename, NULL); @@ -553,7 +555,7 @@ CWD_API int virtual_open(const char *path, int flags, ...) { cwd_state new_state; int f; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); virtual_file_ex(&new_state, path, NULL); @@ -578,7 +580,7 @@ CWD_API int virtual_creat(const char *path, mode_t mode) { cwd_state new_state; int f; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); virtual_file_ex(&new_state, path, NULL); @@ -594,7 +596,7 @@ CWD_API int virtual_rename(char *oldname, char *newname) cwd_state old_state; cwd_state new_state; int retval; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&old_state, &CWDG(cwd)); virtual_file_ex(&old_state, oldname, NULL); @@ -616,7 +618,7 @@ CWD_API int virtual_stat(const char *path, struct stat *buf) { cwd_state new_state; int retval; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); virtual_file_ex(&new_state, path, NULL); @@ -633,7 +635,7 @@ CWD_API int virtual_lstat(const char *path, struct stat *buf) { cwd_state new_state; int retval; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); virtual_file_ex(&new_state, path, NULL); @@ -650,7 +652,7 @@ CWD_API int virtual_unlink(const char *path) { cwd_state new_state; int retval; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); virtual_file_ex(&new_state, path, NULL); @@ -665,7 +667,7 @@ CWD_API int virtual_mkdir(const char *pathname, mode_t mode) { cwd_state new_state; int retval; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); virtual_file_ex(&new_state, pathname, NULL); @@ -683,7 +685,7 @@ CWD_API int virtual_rmdir(const char *pathname) { cwd_state new_state; int retval; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); virtual_file_ex(&new_state, pathname, NULL); @@ -702,7 +704,7 @@ CWD_API DIR *virtual_opendir(const char *pathname) { cwd_state new_state; DIR *retval; - CWDLS_FETCH(); + TSRMLS_FETCH(); CWD_STATE_COPY(&new_state, &CWDG(cwd)); virtual_file_ex(&new_state, pathname, NULL); @@ -721,7 +723,7 @@ CWD_API FILE *virtual_popen(const char *command, const char *type) char *command_line; char *ptr; FILE *retval; - CWDLS_FETCH(); + TSRMLS_FETCH(); command_length = strlen(command); @@ -760,7 +762,7 @@ CWD_API FILE *virtual_popen(const char *command, const char *type) char prev_cwd[MAXPATHLEN]; char *getcwd_result; FILE *retval; - CWDLS_FETCH(); + TSRMLS_FETCH(); getcwd_result = getcwd(prev_cwd, MAXPATHLEN); if (!getcwd_result) { diff --git a/TSRM/tsrm_virtual_cwd.h b/TSRM/tsrm_virtual_cwd.h index 4b1fa2d556..d1b27eb513 100644 --- a/TSRM/tsrm_virtual_cwd.h +++ b/TSRM/tsrm_virtual_cwd.h @@ -134,19 +134,9 @@ typedef struct _virtual_cwd_globals { } virtual_cwd_globals; #ifdef ZTS -# define CWDLS_D virtual_cwd_globals *cwd_globals -# define CWDLS_DC , CWDLS_D -# define CWDLS_C cwd_globals -# define CWDLS_CC , CWDLS_C -# define CWDG(v) (cwd_globals->v) -# define CWDLS_FETCH() virtual_cwd_globals *cwd_globals = ts_resource(cwd_globals_id) +# define CWDG(v) TSRMG(cwd_globals_id, virtual_cwd_globals *, v) #else -# define CWDLS_D void -# define CWDLS_DC -# define CWDLS_C -# define CWDLS_CC # define CWDG(v) (cwd_globals.v) -# define CWDLS_FETCH() #endif /* The actual macros to be used in programs using TSRM diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c index 7a1554afbd..f8d2b7d741 100644 --- a/TSRM/tsrm_win32.c +++ b/TSRM/tsrm_win32.c @@ -71,7 +71,7 @@ static ProcessPair* process_get(FILE *stream) { ProcessPair* ptr; ProcessPair* newptr; - TWLS_FETCH(); + TSRMLS_FETCH(); for (ptr = TWG(process); ptr < (TWG(process) + TWG(process_size)); ptr++) { if (ptr->stream == stream) { @@ -112,7 +112,7 @@ TSRM_API FILE* popen(const char *command, const char *type) HANDLE in, out; char *cmd; ProcessPair *proc; - TWLS_FETCH(); + TSRMLS_FETCH(); security.nLength = sizeof(SECURITY_ATTRIBUTES); security.bInheritHandle = TRUE; diff --git a/TSRM/tsrm_win32.h b/TSRM/tsrm_win32.h index 95cdd99a82..cb09786682 100644 --- a/TSRM/tsrm_win32.h +++ b/TSRM/tsrm_win32.h @@ -38,12 +38,11 @@ typedef struct { } tsrm_win32_globals; #ifdef ZTS -# define TWG(v) (win32_globals->v) -# define TWLS_FETCH() tsrm_win32_globals *win32_globals = ts_resource(win32_globals_id) +# define TWG(v) TSRMG(win32_globals_id, tsrm_win32_globals *, v) #else # define TWG(v) (win32_globals.v) -# define TWLS_FETCH() #endif + #endif TSRM_API void tsrm_win32_startup(void); |