summaryrefslogtreecommitdiff
path: root/implement.h
diff options
context:
space:
mode:
authorrpj <rpj>1998-07-25 12:27:18 +0000
committerrpj <rpj>1998-07-25 12:27:18 +0000
commit860f5268e2d230e4fc04ab588f74ea5e05bab44a (patch)
tree2aa1da3bc97970139101d61318bbf1c41c0056c4 /implement.h
parente80271449742bf9c3f1e54312fbc5af6f413ff35 (diff)
Sat Jul 25 00:00:13 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* create.c (_pthread_start_call): Set thread priority. Ensure our thread entry is removed from the thread table but only if pthread_detach() was called and there are no waiting joins. (pthread_create): Set detach flag in thread entry if the thread is created PTHREAD_CREATE_DETACHED. * pthread.h (pthread_attr_t): Rename member "detachedstate". * attr.c (pthread_attr_init): Rename attr members. * exit.c (pthread_exit): Fix indirection mistake. * implement.h (_PTHREAD_THREADS_TABLE_INDEX): Add. * exit.c (_pthread_vacuum): Fix incorrect args to _pthread_handler_pop_all() calls. Make thread entry removal conditional. * sync.c (pthread_join): Add multiple join and async detach handling. * implement.h (_PTHREAD_THREADS_TABLE_INDEX): Add. * global.c (_pthread_threads_mutex_table): Add. * implement.h (_pthread_once_flag): Remove. (_pthread_once_lock): Ditto. (_pthread_threads_mutex_table): Add. * global.c (_pthread_once_flag): Remove. (_pthread_once_lock): Ditto. * sync.c (pthread_join): Fix tests involving new return value from _pthread_find_thread_entry(). (pthread_detach): Ditto. * private.c (_pthread_find_thread_entry): Failure return code changed from -1 to NULL.
Diffstat (limited to 'implement.h')
-rw-r--r--implement.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/implement.h b/implement.h
index 033e0e8..807bf0e 100644
--- a/implement.h
+++ b/implement.h
@@ -38,11 +38,23 @@ typedef struct {
jmpbuf env;
} _pthread_call_t;
+/* Macro to return the address of the thread entry of the calling thread. */
#define _PTHREAD_THIS (_pthread_find_thread_entry(pthread_this()))
+/* Macro to compute the address of a given handler stack. */
#define _PTHREAD_STACK(stack) \
((_pthread_handler_node_t *) &(_PTHREAD_THIS)->cleanupstack + stack);
+/* Macro to compute the table index of a thread entry from it's entry
+ address. */
+#define _PTHREAD_THREADS_TABLE_INDEX(this) \
+ ((_pthread_threads_table_t *) this - \
+ (_pthread_threads_table_t *) _pthread_threads_threads_table)
+
+/* Macro to compute the address of a per-thread mutex lock. */
+#define _PTHREAD_THREAD_MUTEX(this) \
+ (&_pthread_threads_mutex_table[_PTHREAD_THREADS_TABLE_INDEX(this)])
+
/* An element in the thread table. */
typedef struct _pthread_threads_thread _pthread_threads_thread_t;
@@ -52,6 +64,7 @@ struct _pthread_threads_thread {
_pthread_call_t call;
int cancelthread;
void ** joinvalueptr;
+ int join_count;
_pthread_handler_node_t * cleanupstack;
_pthread_handler_node_t * destructorstack;
_pthread_handler_node_t * forkpreparestack;
@@ -102,10 +115,7 @@ extern DWORD _pthread_threads_count;
extern _pthread_threads_thread_t _pthread_threads_table[];
-extern unsigned short _pthread_once_flag;
-
-extern pthread_mutex_t _pthread_once_lock;
-
+extern pthread_mutex_t _pthread_threads_mutex_table[];
#endif /* _IMPLEMENT_H */