diff options
Diffstat (limited to 'linuxthreads/cancel.c')
-rw-r--r-- | linuxthreads/cancel.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/linuxthreads/cancel.c b/linuxthreads/cancel.c index 47c0bfee04..838f55d8b2 100644 --- a/linuxthreads/cancel.c +++ b/linuxthreads/cancel.c @@ -30,7 +30,7 @@ #endif -int pthread_setcancelstate(int state, int * oldstate) +int __pthread_setcancelstate(int state, int * oldstate) { pthread_descr self = thread_self(); if (state < PTHREAD_CANCEL_ENABLE || state > PTHREAD_CANCEL_DISABLE) @@ -43,8 +43,9 @@ int pthread_setcancelstate(int state, int * oldstate) __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME); return 0; } +strong_alias (__pthread_setcancelstate, pthread_setcancelstate); -int pthread_setcanceltype(int type, int * oldtype) +int __pthread_setcanceltype(int type, int * oldtype) { pthread_descr self = thread_self(); if (type < PTHREAD_CANCEL_DEFERRED || type > PTHREAD_CANCEL_ASYNCHRONOUS) @@ -57,6 +58,33 @@ int pthread_setcanceltype(int type, int * oldtype) __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME); return 0; } +strong_alias (__pthread_setcanceltype, pthread_setcanceltype); + + +/* The next two functions are similar to pthread_setcanceltype() but + more specialized for the use in the cancelable functions like write(). + They do not need to check parameters etc. */ +int +attribute_hidden +__pthread_enable_asynccancel (void) +{ + pthread_descr self = thread_self(); + int oldtype = THREAD_GETMEM(self, p_canceltype); + THREAD_SETMEM(self, p_canceltype, PTHREAD_CANCEL_ASYNCHRONOUS); + if (__builtin_expect (THREAD_GETMEM(self, p_canceled), 0) && + THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE) + __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME); + return oldtype; +} + +void +internal_function attribute_hidden +__pthread_disable_asynccancel (int oldtype) +{ + pthread_descr self = thread_self(); + THREAD_SETMEM(self, p_canceltype, oldtype); +} + int pthread_cancel(pthread_t thread) { @@ -210,14 +238,3 @@ void __pthread_perform_cleanup(char *currentframe) __rpc_thread_destroy (); #endif } - -#ifndef SHARED -/* We need a hook to force the cancelation wrappers and file locking - to be linked in when static libpthread is used. */ -extern const int __pthread_provide_wrappers; -static const int *const __pthread_require_wrappers = - &__pthread_provide_wrappers; -extern const int __pthread_provide_lockfile; -static const int *const __pthread_require_lockfile = - &__pthread_provide_lockfile; -#endif |