mirror of
https://sourceware.org/git/glibc.git
synced 2025-12-24 17:51:17 +03:00
Update.
1998-08-26 15:46 Ulrich Drepper <drepper@cygnus.com> * internals.h: Define THREAD_GETMEM and THREAD_SETMEM to default if not already defined. (struct _pthread_descr_struct): Add p_self and p_nr field. * manager.c (__pthread_handles): Define second element to point to manager thread. (__pthread_handles_num): Initialize to 2. (__pthread_manager): Use INIT_THREAD_SELF with two arguments. (pthread_start_thread): Likewise. (pthread_handle_create): Start search for free slot at entry 2. Initialize new fields p_self and p_nr. Call __clone with CLONE_PTRACE if available. (pthread_free): Call FREE_THREAD_SELF if available. * pthread.c (__pthread_initial_thread): Initialize new fields. (__pthread_manager_thread): Likewise. (__pthread_initialize_manager): Call __clone with CLONE_PTRACE. * cancel.c: Use THREAD_GETMEM and THREAD_SETMEM to access the elements of the thread descriptor. * condvar.c: Likewise. * errno.c: Likewise. * join.c: Likewise. * manager.c: Likewise. * pthread.c: Likewise. * ptlongjmp.c: Likewise. * semaphore.c: Likewise. * signals.c: Likewise. * specific.c: Likewise. * spinlock.c: Likewise. * sysdeps/alpha/pt-machine.h (INIT_THREAD_SELF): Add extra parameter. * sysdeps/i386/useldt.h: New file. * sysdeps/i386/i686/pt-machine.h: Show how to use this file. * sysdeps/sparc/sparc32/pt-machine.h: Define THREAD_GETMEM and THREAD_SETMEM using __thread_self. * sysdeps/sparc/sparc64/pt-machine.h: Likewise.
This commit is contained in:
@@ -76,17 +76,19 @@ static void pthread_sighandler(int signo)
|
||||
char * in_sighandler;
|
||||
/* If we're in a sigwait operation, just record the signal received
|
||||
and return without calling the user's handler */
|
||||
if (self->p_sigwaiting) {
|
||||
self->p_sigwaiting = 0;
|
||||
self->p_signal = signo;
|
||||
if (THREAD_GETMEM(self, p_sigwaiting)) {
|
||||
THREAD_SETMEM(self, p_sigwaiting, 0);
|
||||
THREAD_SETMEM(self, p_signal, signo);
|
||||
return;
|
||||
}
|
||||
/* Record that we're in a signal handler and call the user's
|
||||
handler function */
|
||||
in_sighandler = self->p_in_sighandler;
|
||||
if (in_sighandler == NULL) self->p_in_sighandler = CURRENT_STACK_FRAME;
|
||||
in_sighandler = THREAD_GETMEM(self, p_in_sighandler);
|
||||
if (in_sighandler == NULL)
|
||||
THREAD_SETMEM(self, p_in_sighandler, CURRENT_STACK_FRAME);
|
||||
sighandler[signo](signo);
|
||||
if (in_sighandler == NULL) self->p_in_sighandler = NULL;
|
||||
if (in_sighandler == NULL)
|
||||
THREAD_SETMEM(self, p_in_sighandler, NULL);
|
||||
}
|
||||
|
||||
int sigaction(int sig, const struct sigaction * act,
|
||||
@@ -131,21 +133,22 @@ int sigwait(const sigset_t * set, int * sig)
|
||||
}
|
||||
/* Test for cancellation */
|
||||
if (sigsetjmp(jmpbuf, 1) == 0) {
|
||||
self->p_cancel_jmp = &jmpbuf;
|
||||
if (! (self->p_canceled && self->p_cancelstate == PTHREAD_CANCEL_ENABLE)) {
|
||||
THREAD_SETMEM(self, p_cancel_jmp, &jmpbuf);
|
||||
if (! (THREAD_GETMEM(self, p_canceled)
|
||||
&& THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE)) {
|
||||
/* Reset the signal count */
|
||||
self->p_signal = 0;
|
||||
THREAD_SETMEM(self, p_signal, 0);
|
||||
/* Say we're in sigwait */
|
||||
self->p_sigwaiting = 1;
|
||||
THREAD_SETMEM(self, p_sigwaiting, 1);
|
||||
/* Unblock the signals and wait for them */
|
||||
sigsuspend(&mask);
|
||||
}
|
||||
}
|
||||
self->p_cancel_jmp = NULL;
|
||||
THREAD_SETMEM(self, p_cancel_jmp, NULL);
|
||||
/* The signals are now reblocked. Check for cancellation */
|
||||
pthread_testcancel();
|
||||
/* We should have self->p_signal != 0 and equal to the signal received */
|
||||
*sig = self->p_signal;
|
||||
*sig = THREAD_GETMEM(self, p_signal);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user