diff options
Diffstat (limited to 'TSRM/TSRM.h')
-rw-r--r-- | TSRM/TSRM.h | 58 |
1 files changed, 17 insertions, 41 deletions
diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index d710eb6f75..75553edabc 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -44,14 +44,8 @@ typedef uintptr_t tsrm_uintptr_t; # ifndef TSRM_INCLUDE_FULL_WINDOWS_HEADERS # define WIN32_LEAN_AND_MEAN # endif -# include <windows.h> -# include <shellapi.h> -#elif defined(GNUPTH) -# include <pth.h> -#elif defined(PTHREADS) +#else # include <pthread.h> -#elif defined(TSRM_ST) -# include <st.h> #endif #if SIZEOF_SIZE_T == 4 @@ -68,15 +62,9 @@ typedef int ts_rsrc_id; #ifdef TSRM_WIN32 # define THREAD_T DWORD # define MUTEX_T CRITICAL_SECTION * -#elif defined(GNUPTH) -# define THREAD_T pth_t -# define MUTEX_T pth_mutex_t * -#elif defined(PTHREADS) +#else # define THREAD_T pthread_t # define MUTEX_T pthread_mutex_t * -#elif defined(TSRM_ST) -# define THREAD_T st_thread_t -# define MUTEX_T st_mutex_t #endif #include <signal.h> @@ -143,13 +131,8 @@ TSRM_API void *tsrm_set_new_thread_begin_handler(tsrm_thread_begin_func_t new_th TSRM_API void *tsrm_set_new_thread_end_handler(tsrm_thread_end_func_t new_thread_end_handler); TSRM_API void *tsrm_set_shutdown_handler(tsrm_shutdown_func_t shutdown_handler); -/* these 3 APIs should only be used by people that fully understand the threading model - * used by PHP/Zend and the selected SAPI. */ -TSRM_API void *tsrm_new_interpreter_context(void); -TSRM_API void *tsrm_set_interpreter_context(void *new_ctx); -TSRM_API void tsrm_free_interpreter_context(void *context); - TSRM_API void *tsrm_get_ls_cache(void); +TSRM_API size_t tsrm_get_ls_cache_tcb_offset(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); @@ -160,11 +143,21 @@ TSRM_API const char *tsrm_api_name(void); # define TSRM_TLS __thread #endif +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + +#if !__has_attribute(tls_model) +# define TSRM_TLS_MODEL_ATTR +#elif __PIC__ +# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("initial-exec"))) +#else +# define TSRM_TLS_MODEL_ATTR __attribute__((tls_model("local-exec"))) +#endif + #define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1) #define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1) -#define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = (void ***) ctx -#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) @@ -174,18 +167,11 @@ TSRM_API const char *tsrm_api_name(void); #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_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR; +#define TSRMLS_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL; #define TSRMLS_CACHE_UPDATE() TSRMLS_CACHE = tsrm_get_ls_cache() #define TSRMLS_CACHE _tsrm_ls_cache -/* BC only */ -#define TSRMLS_D void -#define TSRMLS_DC -#define TSRMLS_C -#define TSRMLS_CC -#define TSRMLS_FETCH() - #ifdef __cplusplus } #endif @@ -195,10 +181,6 @@ TSRM_API const char *tsrm_api_name(void); #define tsrm_env_lock() #define tsrm_env_unlock() -#define TSRMLS_FETCH() -#define TSRMLS_FETCH_FROM_CTX(ctx) -#define TSRMLS_SET_CTX(ctx) - #define TSRMG_STATIC(id, type, element) #define TSRMLS_CACHE_EXTERN() #define TSRMLS_CACHE_DEFINE() @@ -207,12 +189,6 @@ TSRM_API const char *tsrm_api_name(void); #define TSRM_TLS -/* BC only */ -#define TSRMLS_D void -#define TSRMLS_DC -#define TSRMLS_C -#define TSRMLS_CC - #endif /* ZTS */ #endif /* TSRM_H */ |