]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nptl/libc-cancellation.c
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / nptl / libc-cancellation.c
index 1db99ea18a87d274c931cf777d47c104839ee5d5..c2c1fbb519f98925f89fab6caf762e700a95ecdb 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
-#include <setjmp.h>
-#include <stdlib.h>
 #include "pthreadP.h"
-#include "atomic.h"
 
 
-#if !defined NOT_IN_libc
-
-/* 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
-__libc_enable_asynccancel (void)
-{
-  struct pthread *self = THREAD_SELF;
-  int oldval;
-
-  while (1)
-    {
-      oldval = THREAD_GETMEM (self, cancelhandling);
-      int newval = oldval | CANCELTYPE_BITMASK;
-
-      if (newval == oldval)
-       break;
-
-      if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval,
-                                          oldval) == 0)
-       {
-         if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
-           {
-             THREAD_SETMEM (self, result, PTHREAD_CANCELED);
-             __do_cancel ();
-           }
-
-         break;
-       }
-    }
-
-  return oldval;
-}
-
-
-void
-internal_function attribute_hidden
-__libc_disable_asynccancel (int oldtype)
-{
-  /* If asynchronous cancellation was enabled before we do not have
-     anything to do.  */
-  if (oldtype & CANCELTYPE_BITMASK)
-    return;
-
-  struct pthread *self = THREAD_SELF;
-
-  while (1)
-    {
-      int oldval = THREAD_GETMEM (self, cancelhandling);
-      int newval = oldval & ~CANCELTYPE_BITMASK;
-
-      if (newval == oldval)
-       break;
-
-      if (atomic_compare_and_exchange_acq (&self->cancelhandling, newval,
-                                          oldval) == 0)
-       break;
-    }
-}
-
-#endif
+#define __pthread_enable_asynccancel __libc_enable_asynccancel
+#define __pthread_disable_asynccancel __libc_disable_asynccancel
+#include <nptl/cancellation.c>