Save TSRMLS_FETCH()'s

This commit is contained in:
Zeev Suraski 2001-07-30 01:46:35 +00:00
parent 0a382bd3dc
commit 0701d68f97
2 changed files with 13 additions and 8 deletions

View file

@ -51,8 +51,8 @@ static int resource_types_table_size;
static MUTEX_T tsmm_mutex; /* thread-safe memory manager mutex */ static MUTEX_T tsmm_mutex; /* thread-safe memory manager mutex */
/* New thread handlers */ /* New thread handlers */
static void (*tsrm_new_thread_begin_handler)(); static tsrm_thread_begin_func_t tsrm_new_thread_begin_handler;
static void (*tsrm_new_thread_end_handler)(); static tsrm_thread_end_func_t tsrm_new_thread_end_handler;
/* Debug support */ /* Debug support */
int tsrm_error(int level, const char *format, ...); int tsrm_error(int level, const char *format, ...);
@ -254,7 +254,7 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
#endif #endif
if (tsrm_new_thread_begin_handler) { if (tsrm_new_thread_begin_handler) {
tsrm_new_thread_begin_handler(thread_id); tsrm_new_thread_begin_handler(thread_id, &((*thread_resources_ptr)->storage));
} }
for (i=0; i<id_count; i++) { for (i=0; i<id_count; i++) {
(*thread_resources_ptr)->storage[i] = (void *) malloc(resource_types_table[i].size); (*thread_resources_ptr)->storage[i] = (void *) malloc(resource_types_table[i].size);
@ -266,7 +266,7 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
tsrm_mutex_unlock(tsmm_mutex); tsrm_mutex_unlock(tsmm_mutex);
if (tsrm_new_thread_end_handler) { if (tsrm_new_thread_end_handler) {
tsrm_new_thread_end_handler(thread_id); tsrm_new_thread_end_handler(thread_id, &((*thread_resources_ptr)->storage));
} }
} }
@ -509,7 +509,7 @@ TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
} }
TSRM_API void *tsrm_set_new_thread_begin_handler(void (*new_thread_begin_handler)(THREAD_T thread_id)) TSRM_API void *tsrm_set_new_thread_begin_handler(tsrm_thread_begin_func_t new_thread_begin_handler)
{ {
void *retval = (void *) tsrm_new_thread_begin_handler; void *retval = (void *) tsrm_new_thread_begin_handler;
@ -518,7 +518,7 @@ TSRM_API void *tsrm_set_new_thread_begin_handler(void (*new_thread_begin_handler
} }
TSRM_API void *tsrm_set_new_thread_end_handler(void (*new_thread_end_handler)(THREAD_T thread_id)) TSRM_API void *tsrm_set_new_thread_end_handler(tsrm_thread_end_func_t new_thread_end_handler)
{ {
void *retval = (void *) tsrm_new_thread_end_handler; void *retval = (void *) tsrm_new_thread_end_handler;

View file

@ -98,6 +98,11 @@ TSRM_API void ts_free_id(ts_rsrc_id id);
#define TSRM_ERROR_LEVEL_ERROR 1 #define TSRM_ERROR_LEVEL_ERROR 1
#define TSRM_ERROR_LEVEL_CORE 2 #define TSRM_ERROR_LEVEL_CORE 2
#define TSRM_ERROR_LEVEL_INFO 3 #define TSRM_ERROR_LEVEL_INFO 3
typedef void (*tsrm_thread_begin_func_t)(THREAD_T thread_id, void ***tsrm_ls);
typedef void (*tsrm_thread_end_func_t)(THREAD_T thread_id, void ***tsrm_ls);
TSRM_API int tsrm_error(int level, const char *format, ...); TSRM_API int tsrm_error(int level, const char *format, ...);
TSRM_API void tsrm_error_set(int level, char *debug_filename); TSRM_API void tsrm_error_set(int level, char *debug_filename);
@ -108,8 +113,8 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp);
TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp); TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp);
TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp); TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp);
TSRM_API void *tsrm_set_new_thread_begin_handler(void (*new_thread_begin_handler)(THREAD_T thread_id)); 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(void (*new_thread_end_handler)(THREAD_T thread_id)); TSRM_API void *tsrm_set_new_thread_end_handler(tsrm_thread_end_func_t new_thread_end_handler);
#define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1) #define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1)
#define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1) #define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1)