summaryrefslogtreecommitdiff
path: root/implement.h
diff options
context:
space:
mode:
authorrpj <rpj>1998-07-22 16:42:53 +0000
committerrpj <rpj>1998-07-22 16:42:53 +0000
commitf33f4460f9de9c2d2ae6f3bf05caed391c6ad485 (patch)
tree12bb86525d369c1c4de220bb58d92d3eab2f5a7e /implement.h
parentb84f1cc523f4236200689b2f78b16b26bc05f429 (diff)
Wed Jul 22 00:16:22 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* attr.c, implement.h, pthread.h, ChangeLog: Resolve CVS merge conflicts. * private.c (_pthread_find_thread_entry): Changes to return type to support leaner _pthread_threads_table[] which now only stores _pthread_thread_thread_t *. (_pthread_new_thread_entry): Internal changes. (_pthread_delete_thread_entry): Internal changes to avoid contention. Calling routines changed accordingly. * pthread.h: Modified cleanup macros to use new generic push and pop. Added destructor and atfork stacks to _pthread_threads_thread_t. * cleanup.c (_pthread_handler_push, _pthread_handler_pop, _pthread_handler_pop_all): Renamed cleanup push and pop routines and made generic to handle destructors and atfork handlers as well. * create.c (_pthread_start_call): New function is a wrapper for all new threads. It allows us to do some cleanup when the thread returns, ie. that is otherwise only done if the thread is cancelled. * exit.c (_pthread_vacuum): New function contains code from pthread_exit() that we need in the new _pthread_start_call() as well. * implement.h: Various additions and minor changes. * pthread.h: Various additions and minor changes. Change cleanup handler macros to use generic handler push and pop functions. * attr.c: Minor mods to all functions. (is_attr): Implemented missing function. * create.c (pthread_create): More clean up. * private.c (_pthread_find_thread_entry): Implement. (_pthread_delete_thread_entry): Implement. (_pthread_new_thread_entry): Implement. These functions manipulate the implementations internal thread table and are part of general code cleanup and modularisation. They replace _pthread_getthreadindex() which was removed. * exit.c (pthread_exit): Changed to use the new code above. * pthread.h: Add cancelability constants. Update comments.
Diffstat (limited to 'implement.h')
-rw-r--r--implement.h48
1 files changed, 27 insertions, 21 deletions
diff --git a/implement.h b/implement.h
index 811e717..2256965 100644
--- a/implement.h
+++ b/implement.h
@@ -7,42 +7,48 @@
#ifndef _IMPLEMENT_H
#define _IMPLEMENT_H
-/* FIXME: Arbitrary. Need values from Win32.
- */
-#define PTHREAD_THREADS_MAX 128
-#define PTHREAD_STACK_MIN 65535
-
#define _PTHREAD_HASH_INDEX(x) (((ULONG) x) % PTHREAD_THREADS_MAX)
-/* This is all compile time arithmetic */
-#define RND_SIZEOF(T) (((sizeof(T) / sizeof(DWORD)) + 1) * sizeof(DWORD))
+#define _PTHREAD_CANCEL_DEFAULTS \
+ (PTHREAD_CANCEL_ENABLE | PTHREAD_CANCEL_DEFERRED)
+/* Handler execution flags. */
+#define _PTHREAD_HANDLER_NOEXECUTE 0
+#define _PTHREAD_HANDLER_EXECUTE 1
-typedef struct _pthread_cleanup_stack _pthread_cleanup_stack_t;
-struct _pthread_cleanup_stck {
- _pthread_cleanup_stack_t first;
- int count;
-};
+/* Handler popping schemes. */
+enum { _PTHREAD_HANDLER_POP_LIFO, _PTHREAD_HANDLER_POP_FIFO };
-typedef struct _pthread_cleanup_node _pthread_cleanup_node_t;
-struct _pthread_cleanup_node {
- _pthread_cleanup_node_t next;
- void (* routine)(void *);
- void * arg;
-};
+/* Special value to mark attribute objects as valid. */
+#define _PTHREAD_ATTR_INVALID 0xC0FFEE
+
+/* Round a sizeof(type) up to a multiple of sizeof(DWORD).
+ This is all compile time arithmetic.
+ */
+#define RND_SIZEOF(T) (((sizeof(T) / sizeof(DWORD)) + 1) * sizeof(DWORD))
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-void _pthread_cleanup_push(void (*routine)(void *), void *arg);
-void _pthread_cleanup_pop(int execute);
-void _pthread_do_cancellation(int tindex);
+/* Primitives to manage threads table entries. */
+
+int _pthread_new_thread_entry(pthread_t thread,
+ _pthread_threads_thread_t ** entry);
+
+_pthread_threads_thread ** _pthread_find_thread_entry(pthread_t thread);
+
+void _pthread_delete_thread_entry(_pthread_threads_thread_t ** this);
+
+/* Thread cleanup. */
+
+void _pthread_vacuum(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
+
#endif /* _IMPLEMENT_H */