From patchwork Thu Nov 20 21:44:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 3823 Received: (qmail 27120 invoked by alias); 20 Nov 2014 21:44:46 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 27111 invoked by uid 89); 20 Nov 2014 21:44:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [COMMITTED PATCH] NPTL: Conditionalize asynchronous cancellation support on [SIGCANCEL]. Message-Id: <20141120214443.01CC22C3B2D@topped-with-meat.com> Date: Thu, 20 Nov 2014 13:44:42 -0800 (PST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=AXEvtsmxfhnqd2psdFIA:9 a=CjuIK1q_8ugA:10 Verified no generated code changes on x86_64-linux-gnu. Thanks, Roland * nptl/pthread_setcanceltype.c [!SIGCANCEL]: Return ENOTSUP early for PTHREAD_CANCEL_ASYNCHRONOUS. * nptl/pthread_cancel.c [!SIGCANCEL]: Just abort rather than trying to send SIGCANCEL. --- a/nptl/pthread_cancel.c +++ b/nptl/pthread_cancel.c @@ -18,8 +18,9 @@ #include #include +#include #include "pthreadP.h" -#include "atomic.h" +#include #include @@ -63,6 +64,7 @@ pthread_cancel (th) oldval)) goto again; +#ifdef SIGCANCEL /* The cancellation handler will take care of marking the thread as canceled. */ INTERNAL_SYSCALL_DECL (err); @@ -80,13 +82,20 @@ pthread_cancel (th) if (INTERNAL_SYSCALL_ERROR_P (val, err)) result = INTERNAL_SYSCALL_ERRNO (val, err); +#else + /* It should be impossible to get here at all, since + pthread_setcanceltype should never have allowed + PTHREAD_CANCEL_ASYNCHRONOUS to be set. */ + abort (); +#endif break; } - /* A single-threaded process should be able to kill itself, since there is - nothing in the POSIX specification that says that it cannot. So we set - multiple_threads to true so that cancellation points get executed. */ + /* A single-threaded process should be able to kill itself, since + there is nothing in the POSIX specification that says that it + cannot. So we set multiple_threads to true so that cancellation + points get executed. */ THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1); #ifndef TLS_MULTIPLE_THREADS_IN_TCB __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1; --- a/nptl/pthread_setcanceltype.c +++ b/nptl/pthread_setcanceltype.c @@ -26,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)