From 4ed54ca07b8115bd9e7813a1484d4c7936a25e70 Mon Sep 17 00:00:00 2001 From: rpj Date: Wed, 14 Oct 1998 03:06:39 +0000 Subject: Mon Oct 12 00:00:44 1998 Ross Johnson * implement.h (_pthread_tsd_key_table): New. * create.c (_pthread_start_call): Initialise per-thread TSD keys to NULL. * misc.c (pthread_once): Correct typo in comment. * implement.h (_pthread_destructor_push): Remove. (_pthread_destructor_pop): Remove. (_pthread_destructor_run_all): Rename from _pthread_destructor_pop_all. (_PTHREAD_TSD_KEY_DELETED): Add enum. (_PTHREAD_TSD_KEY_INUSE): Add enum. * cleanup.c (_pthread_destructor_push): Remove. (_pthread_destructor_pop): Remove. (_pthread_destructor_run_all): Totally revamped TSD. * dll.c (_pthread_TSD_keys_TlsIndex): Initialise. * tsd.c (pthread_setspecific): Totally revamped TSD. (pthread_getspecific): Ditto. (pthread_create): Ditto. (pthread_delete): Ditto. Sun Oct 11 22:44:55 1998 Ross Johnson * global.c (_pthread_tsd_key_table): Add new global. * implement.h (_pthread_tsd_key_t and struct _pthread_tsd_key): Add. (struct _pthread): Remove destructorstack. * cleanup.c (_pthread_destructor_run_all): Rename from _pthread_destructor_pop_all. The key destructor stack was made global rather than per-thread. No longer removes destructor nodes from the stack. Comments updated. --- implement.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'implement.h') diff --git a/implement.h b/implement.h index bf55e91..a87edb2 100644 --- a/implement.h +++ b/implement.h @@ -19,6 +19,11 @@ enum { _PTHREAD_REUSE }; +enum { + _PTHREAD_TSD_KEY_DELETED, + _PTHREAD_TSD_KEY_INUSE +}; + #define _PTHREAD_VALID(T) \ ((T) != NULL \ && ((T)->ptstatus == _PTHREAD_NEW \ @@ -40,6 +45,14 @@ struct _pthread_handler_node { void * arg; }; +/* TSD key element. */ +typedef struct _pthread_tsd_key _pthread_tsd_key_t; + +struct _pthread_tsd_key { + int in_use; + void (* destructor)(void *); +}; + /* Stores a thread call routine and argument. */ typedef struct { unsigned (*routine)(void *); @@ -84,7 +97,6 @@ struct _pthread { /* These must be kept in this order and together. */ _pthread_handler_node_t * cleanupstack; - _pthread_handler_node_t * destructorstack; _pthread_handler_node_t * forkpreparestack; _pthread_handler_node_t * forkparentstack; _pthread_handler_node_t * forkchildstack; @@ -107,12 +119,7 @@ void _pthread_handler_pop(int stack, void _pthread_handler_pop_all(int stack, int execute); -int _pthread_destructor_push(void (*routine)(void *), - pthread_key_t key); - -void _pthread_destructor_pop(pthread_key_t key); - -void _pthread_destructor_pop_all(); +void _pthread_destructor_run_all(); /* Primitives to manage threads table entries. */ @@ -161,6 +168,9 @@ extern pthread_t _pthread_win32handle_map[]; /* Per thread mutex locks. */ extern pthread_mutex_t _pthread_threads_mutex_table[]; +/* Global TSD key array. */ +extern _pthread_tsd_key_t _pthread_tsd_key_table[]; + #endif /* _IMPLEMENT_H */ -- cgit v1.2.3