]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nptl/pthread_setcanceltype.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / nptl / pthread_setcanceltype.c
index bbe87ba64bb1b4eff079a60348faf0a79817faf8..11eff86bb8edc467b6d9215a79b5e486d56daba8 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2015 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -13,9 +13,8 @@
    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 <errno.h>
 #include "pthreadP.h"
@@ -27,12 +26,15 @@ __pthread_setcanceltype (type, oldtype)
      int type;
      int *oldtype;
 {
-  volatile struct pthread *self;
-
   if (type < PTHREAD_CANCEL_DEFERRED || type > PTHREAD_CANCEL_ASYNCHRONOUS)
     return EINVAL;
 
-  self = THREAD_SELF;
+#ifndef SIGCANCEL
+  if (type == PTHREAD_CANCEL_ASYNCHRONOUS)
+    return ENOTSUP;
+#endif
+
+  volatile struct pthread *self = THREAD_SELF;
 
   int oldval = THREAD_GETMEM (self, cancelhandling);
   while (1)
@@ -56,7 +58,7 @@ __pthread_setcanceltype (type, oldtype)
         atomically since other bits could be modified as well.  */
       int curval = THREAD_ATOMIC_CMPXCHG_VAL (self, cancelhandling, newval,
                                              oldval);
-      if (__builtin_expect (curval == oldval, 1))
+      if (__glibc_likely (curval == oldval))
        {
          if (CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS (newval))
            {