diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-04-12 00:14:16 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-04-12 00:14:16 +0000 |
commit | 6efd481484e5d8d47b834fd034dc62f4c036d2cf (patch) | |
tree | c4bd9e169d534ceaf83f4b3f6b7f034e0e1cb379 /nptl/pthreadP.h | |
parent | 32b0da568de098fc2d62da7cf6a06ddbaba156d7 (diff) | |
download | glibc-6efd481484e5d8d47b834fd034dc62f4c036d2cf.tar.gz |
Declare __pthread_unwind. Define __do_cancel to use it. Declare old cleanup handler installation functions.
Diffstat (limited to 'nptl/pthreadP.h')
-rw-r--r-- | nptl/pthreadP.h | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index db345d505f..d51f837969 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -94,6 +94,29 @@ extern int __pthread_debug attribute_hidden; } \ } while (0) + +extern void __pthread_unwind (__pthread_unwind_buf_t *__buf) + __cleanup_fct_attribute __attribute ((__noreturn__)) +#ifndef SHARED + weak_function +#endif + ; + +/* Called when a thread reacts on a cancellation request. */ +static inline void +__attribute ((noreturn)) +__do_cancel (void) +{ + struct pthread *self = THREAD_SELF; + + /* Make sure we get no more cancellations. */ + THREAD_ATOMIC_BIT_SET (self, cancelhandling, EXITING_BIT); + + __pthread_unwind ((__pthread_unwind_buf_t *) + THREAD_GETMEM (self, cleanup_jmp_buf)); +} + + /* Set cancellation mode to asynchronous. */ #define CANCEL_ASYNC() \ __pthread_enable_asynccancel () @@ -143,38 +166,6 @@ extern int __pthread_debug attribute_hidden; #endif -/* This function is responsible for calling all registered cleanup - handlers and then terminate the thread. This includes dellocating - the thread-specific data. The implementation is complicated by the - fact that we have to handle to cancellation handler registration - methods: exceptions using try/finally and setjmp. - - The setjmp method is always available. The user might compile some - code which uses this method because no modern compiler is - available. So we have to handle these first since we cannot call - the cleanup handlers if the stack frames are gone. At the same - time this opens a hole for the register exception handler blocks - since now they might be in danger of using an overwritten stack - frame. The advise is to only use new or only old style cancellation - handling. */ -static inline void -__do_cancel (void) -{ - struct pthread *self = THREAD_SELF; - - /* Make sure we get no more cancellations. */ - THREAD_ATOMIC_BIT_SET (self, cancelhandling, EXITING_BIT); - - /* Throw an exception. */ - // XXX TBI - - /* If throwing an exception didn't work try the longjmp. */ - __libc_longjmp (self->cancelbuf, 1); - - /* NOTREACHED */ -} - - /* Internal prototypes. */ /* Thread list handling. */ @@ -344,7 +335,6 @@ extern int __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex); - /* The two functions are in libc.so and not exported. */ extern int __libc_enable_asynccancel (void) attribute_hidden; extern void __libc_disable_asynccancel (int oldtype) @@ -372,4 +362,14 @@ extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer, int execute); +/* Old cleanup interfaces, still used in libc.so. */ +extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer, + void (*routine) (void *), void *arg); +extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer, + int execute); +extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer, + void (*routine) (void *), void *arg); +extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer, + int execute); + #endif /* pthreadP.h */ |