(__pthread_enable_asynccancel,
authordrepper <drepper>
Wed, 18 Dec 2002 01:09:57 +0000 (01:09 +0000)
committerdrepper <drepper>
Wed, 18 Dec 2002 01:09:57 +0000 (01:09 +0000)
__pthread_disable_asynccancel): New functions.
(__pthread_provide_wrappers): Remove.
(pthread_setcancelstate, pthread_setcanceltype): Rename to __
prefixed variants.  Add strong_alias.

linuxthreads/cancel.c

index 47c0bfe..838f55d 100644 (file)
@@ -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