mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
NPTL: Conditionalize asynchronous cancellation support on [SIGCANCEL].
This commit is contained in:
@ -1,5 +1,10 @@
|
|||||||
2014-11-20 Roland McGrath <roland@hack.frob.com>
|
2014-11-20 Roland McGrath <roland@hack.frob.com>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
* nptl/default-sched.h: New file.
|
* nptl/default-sched.h: New file.
|
||||||
* sysdeps/unix/sysv/linux/default-sched.h: New file.
|
* sysdeps/unix/sysv/linux/default-sched.h: New file.
|
||||||
* nptl/pthread_create.c: Include it.
|
* nptl/pthread_create.c: Include it.
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "pthreadP.h"
|
#include "pthreadP.h"
|
||||||
#include "atomic.h"
|
#include <atomic.h>
|
||||||
#include <sysdep.h>
|
#include <sysdep.h>
|
||||||
|
|
||||||
|
|
||||||
@ -63,6 +64,7 @@ pthread_cancel (th)
|
|||||||
oldval))
|
oldval))
|
||||||
goto again;
|
goto again;
|
||||||
|
|
||||||
|
#ifdef SIGCANCEL
|
||||||
/* The cancellation handler will take care of marking the
|
/* The cancellation handler will take care of marking the
|
||||||
thread as canceled. */
|
thread as canceled. */
|
||||||
INTERNAL_SYSCALL_DECL (err);
|
INTERNAL_SYSCALL_DECL (err);
|
||||||
@ -80,13 +82,20 @@ pthread_cancel (th)
|
|||||||
|
|
||||||
if (INTERNAL_SYSCALL_ERROR_P (val, err))
|
if (INTERNAL_SYSCALL_ERROR_P (val, err))
|
||||||
result = INTERNAL_SYSCALL_ERRNO (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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A single-threaded process should be able to kill itself, since there is
|
/* A single-threaded process should be able to kill itself, since
|
||||||
nothing in the POSIX specification that says that it cannot. So we set
|
there is nothing in the POSIX specification that says that it
|
||||||
multiple_threads to true so that cancellation points get executed. */
|
cannot. So we set multiple_threads to true so that cancellation
|
||||||
|
points get executed. */
|
||||||
THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1);
|
THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1);
|
||||||
#ifndef TLS_MULTIPLE_THREADS_IN_TCB
|
#ifndef TLS_MULTIPLE_THREADS_IN_TCB
|
||||||
__pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
|
__pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
|
||||||
|
@ -26,12 +26,15 @@ __pthread_setcanceltype (type, oldtype)
|
|||||||
int type;
|
int type;
|
||||||
int *oldtype;
|
int *oldtype;
|
||||||
{
|
{
|
||||||
volatile struct pthread *self;
|
|
||||||
|
|
||||||
if (type < PTHREAD_CANCEL_DEFERRED || type > PTHREAD_CANCEL_ASYNCHRONOUS)
|
if (type < PTHREAD_CANCEL_DEFERRED || type > PTHREAD_CANCEL_ASYNCHRONOUS)
|
||||||
return EINVAL;
|
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);
|
int oldval = THREAD_GETMEM (self, cancelhandling);
|
||||||
while (1)
|
while (1)
|
||||||
|
Reference in New Issue
Block a user