Skip to content

Commit 0701d68

Browse files
committed
Save TSRMLS_FETCH()'s
1 parent 0a382bd commit 0701d68

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

TSRM/TSRM.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ static int resource_types_table_size;
5151
static MUTEX_T tsmm_mutex; /* thread-safe memory manager mutex */
5252

5353
/* New thread handlers */
54-
static void (*tsrm_new_thread_begin_handler)();
55-
static void (*tsrm_new_thread_end_handler)();
54+
static tsrm_thread_begin_func_t tsrm_new_thread_begin_handler;
55+
static tsrm_thread_end_func_t tsrm_new_thread_end_handler;
5656

5757
/* Debug support */
5858
int tsrm_error(int level, const char *format, ...);
@@ -254,7 +254,7 @@ static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_
254254
#endif
255255

256256
if (tsrm_new_thread_begin_handler) {
257-
tsrm_new_thread_begin_handler(thread_id);
257+
tsrm_new_thread_begin_handler(thread_id, &((*thread_resources_ptr)->storage));
258258
}
259259
for (i=0; i<id_count; i++) {
260260
(*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_
266266
tsrm_mutex_unlock(tsmm_mutex);
267267

268268
if (tsrm_new_thread_end_handler) {
269-
tsrm_new_thread_end_handler(thread_id);
269+
tsrm_new_thread_end_handler(thread_id, &((*thread_resources_ptr)->storage));
270270
}
271271
}
272272

@@ -509,7 +509,7 @@ TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp)
509509
}
510510

511511

512-
TSRM_API void *tsrm_set_new_thread_begin_handler(void (*new_thread_begin_handler)(THREAD_T thread_id))
512+
TSRM_API void *tsrm_set_new_thread_begin_handler(tsrm_thread_begin_func_t new_thread_begin_handler)
513513
{
514514
void *retval = (void *) tsrm_new_thread_begin_handler;
515515

@@ -518,7 +518,7 @@ TSRM_API void *tsrm_set_new_thread_begin_handler(void (*new_thread_begin_handler
518518
}
519519

520520

521-
TSRM_API void *tsrm_set_new_thread_end_handler(void (*new_thread_end_handler)(THREAD_T thread_id))
521+
TSRM_API void *tsrm_set_new_thread_end_handler(tsrm_thread_end_func_t new_thread_end_handler)
522522
{
523523
void *retval = (void *) tsrm_new_thread_end_handler;
524524

TSRM/TSRM.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ TSRM_API void ts_free_id(ts_rsrc_id id);
9898
#define TSRM_ERROR_LEVEL_ERROR 1
9999
#define TSRM_ERROR_LEVEL_CORE 2
100100
#define TSRM_ERROR_LEVEL_INFO 3
101+
102+
typedef void (*tsrm_thread_begin_func_t)(THREAD_T thread_id, void ***tsrm_ls);
103+
typedef void (*tsrm_thread_end_func_t)(THREAD_T thread_id, void ***tsrm_ls);
104+
105+
101106
TSRM_API int tsrm_error(int level, const char *format, ...);
102107
TSRM_API void tsrm_error_set(int level, char *debug_filename);
103108

@@ -108,8 +113,8 @@ TSRM_API void tsrm_mutex_free(MUTEX_T mutexp);
108113
TSRM_API int tsrm_mutex_lock(MUTEX_T mutexp);
109114
TSRM_API int tsrm_mutex_unlock(MUTEX_T mutexp);
110115

111-
TSRM_API void *tsrm_set_new_thread_begin_handler(void (*new_thread_begin_handler)(THREAD_T thread_id));
112-
TSRM_API void *tsrm_set_new_thread_end_handler(void (*new_thread_end_handler)(THREAD_T thread_id));
116+
TSRM_API void *tsrm_set_new_thread_begin_handler(tsrm_thread_begin_func_t new_thread_begin_handler);
117+
TSRM_API void *tsrm_set_new_thread_end_handler(tsrm_thread_end_func_t new_thread_end_handler);
113118

114119
#define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1)
115120
#define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1)

0 commit comments

Comments
 (0)