diff options
author | Roland McGrath <roland@gnu.org> | 2003-04-02 00:11:05 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2003-04-02 00:11:05 +0000 |
commit | 9a197dcc6a93d7938bede6ca85fd1f769424cf17 (patch) | |
tree | b369b79b99a6a3869ae2c08bba80b81a7c46f095 /linuxthreads | |
parent | de58be8a098dfb710f0b6167c8fabc265f2920de (diff) | |
download | glibc-9a197dcc6a93d7938bede6ca85fd1f769424cf17.zip glibc-9a197dcc6a93d7938bede6ca85fd1f769424cf17.tar.gz glibc-9a197dcc6a93d7938bede6ca85fd1f769424cf17.tar.bz2 |
* sysdeps/unix/sysv/linux/sparc/sparc64/sigsuspend.c: Use the
IA-64 version.
Diffstat (limited to 'linuxthreads')
-rw-r--r-- | linuxthreads/ChangeLog | 15 | ||||
-rw-r--r-- | linuxthreads/Makefile | 6 | ||||
-rw-r--r-- | linuxthreads/internals.h | 2 | ||||
-rw-r--r-- | linuxthreads/pthread.c | 3 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S | 28 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c | 33 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c | 56 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-sigsuspend.c | 1 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/pt-sigsuspend.c | 1 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/x86_64/pt-sigsuspend.c | 1 | ||||
-rw-r--r-- | linuxthreads/tst-cancel7.c | 111 |
11 files changed, 253 insertions, 4 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index dbdb0d4..6bd2000 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,18 @@ +2003-04-01 Jakub Jelinek <jakub@redhat.com> + + * pthread.c (__pthread_wait_for_restart_signal): Use + __pthread_sigsuspend instead of sigsuspend. + * internals.h (__pthread_sigsuspend): New prototype. + * Makefile (libpthread-routines): Add pt-sigsuspend. + (tests): Add tst-cancel7. + * sysdeps/unix/sysv/linux/pt-sigsuspend.c: New file. + * sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S: New file. + * sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c: New file. + * sysdeps/unix/sysv/linux/s390/s390-64/pt-sigsuspend.c: New file. + * sysdeps/unix/sysv/linux/sparc/sparc64/pt-sigsuspend.c: New file. + * sysdeps/unix/sysv/linux/x86_64/pt-sigsuspend.c: New file. + * tst-cancel7.c: New test. + 2003-03-31 Alexandre Oliva <aoliva@redhat.com> * alloca_cutoff.c: Include internals.h. diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile index 8a6f9bf..fd8f92b 100644 --- a/linuxthreads/Makefile +++ b/linuxthreads/Makefile @@ -36,8 +36,8 @@ extra-libs-others := $(extra-libs) install-lib-ldscripts := libpthread.so libpthread-routines := attr cancel condvar join manager mutex ptfork \ - ptlongjmp pthread signals specific errno lockfile \ - semaphore spinlock rwlock pt-machine \ + ptlongjmp pthread pt-sigsuspend signals specific errno \ + lockfile semaphore spinlock rwlock pt-machine \ oldsemaphore events getcpuclockid pspinlock barrier \ ptclock_gettime ptclock_settime sighandler \ pthandles libc-tls-loc pt-allocrtsig \ @@ -89,7 +89,7 @@ tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \ tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \ ex17 ex18 tst-cancel tst-context bug-sleep \ tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \ - tst-cancel6 tst-popen tst-popen2 + tst-cancel6 tst-cancel7 tst-popen tst-popen2 test-srcs = tst-signal # These tests are linked with libc before libpthread tests-reverse += tst-cancel5 diff --git a/linuxthreads/internals.h b/linuxthreads/internals.h index 36fdfe1..eb5ba13 100644 --- a/linuxthreads/internals.h +++ b/linuxthreads/internals.h @@ -377,6 +377,8 @@ extern int __pthread_timedsuspend_new(pthread_descr self, const struct timespec extern void __pthread_wait_for_restart_signal(pthread_descr self); +extern void __pthread_sigsuspend (const sigset_t *mask) attribute_hidden; + extern int __pthread_yield (void); extern int __pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock, diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c index 01be30b..f165ab1 100644 --- a/linuxthreads/pthread.c +++ b/linuxthreads/pthread.c @@ -1144,7 +1144,8 @@ void __pthread_wait_for_restart_signal(pthread_descr self) sigdelset(&mask, __pthread_sig_restart); /* Unblock the restart signal */ THREAD_SETMEM(self, p_signal, 0); do { - sigsuspend(&mask); /* Wait for signal */ + __pthread_sigsuspend(&mask); /* Wait for signal. Must not be a + cancellation point. */ } while (THREAD_GETMEM(self, p_signal) !=__pthread_sig_restart); READ_MEMORY_BARRIER(); /* See comment in __pthread_restart_new */ diff --git a/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S b/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S new file mode 100644 index 0000000..91e5c86 --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/alpha/pt-sigsuspend.S @@ -0,0 +1,28 @@ +/* Internal sigsuspend system call for LinuxThreads. Alpha version. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + 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. */ + +#include <sysdep.h> + +#undef PSEUDO_PREPARE_ARGS +#define PSEUDO_PREPARE_ARGS ldq a0, 0(a0); + + .hidden __pthread_sigsuspend +PSEUDO_NOERRNO(__pthread_sigsuspend, sigsuspend, 1) + ret +PSEUDO_END_NOERRNO(__pthread_sigsuspend) diff --git a/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c b/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c new file mode 100644 index 0000000..0b96e3d --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/ia64/pt-sigsuspend.c @@ -0,0 +1,33 @@ +/* Internal sigsuspend system call for LinuxThreads. IA64 version. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + 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. */ + +#include <errno.h> +#include <signal.h> +#include <unistd.h> + +#include <sysdep.h> +#include <sys/syscall.h> +#include <linuxthreads/internals.h> + +void +__pthread_sigsuspend (const sigset_t *set) +{ + INTERNAL_SYSCALL_DECL (err); + INTERNAL_SYSCALL (rt_sigsuspend, err, 2, set, _NSIG / 8); +} diff --git a/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c b/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c new file mode 100644 index 0000000..5528c55 --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/pt-sigsuspend.c @@ -0,0 +1,56 @@ +/* Internal sigsuspend system call for LinuxThreads. Generic Linux version. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + 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. */ + +#include <errno.h> +#include <signal.h> +#include <unistd.h> + +#include <sysdep.h> +#include <sys/syscall.h> +#include <linuxthreads/internals.h> + +#include "kernel-features.h" + +void +__pthread_sigsuspend (const sigset_t *set) +{ + INTERNAL_SYSCALL_DECL (err); +#if !__ASSUME_REALTIME_SIGNALS + static int __pthread_missing_rt_sigs; + +# ifdef __NR_rt_sigsuspend + /* First try the RT signals. */ + if (!__pthread_missing_rt_sigs) + { + /* XXX The size argument hopefully will have to be changed to the + real size of the user-level sigset_t. */ + int r; + r = INTERNAL_SYSCALL (rt_sigsuspend, err, 2, set, _NSIG / 8); + if (INTERNAL_SYSCALL_ERRNO (r, err) != ENOSYS) + return; + + __pthread_missing_rt_sigs = 1; + } +# endif + + INTERNAL_SYSCALL (sigsuspend, err, 3, 0, 0, set->__val[0]); +#else + INTERNAL_SYSCALL (rt_sigsuspend, err, 2, set, _NSIG / 8); +#endif +} diff --git a/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-sigsuspend.c b/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-sigsuspend.c new file mode 100644 index 0000000..d57283a --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/pt-sigsuspend.c @@ -0,0 +1 @@ +#include "../../ia64/pt-sigsuspend.c" diff --git a/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/pt-sigsuspend.c b/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/pt-sigsuspend.c new file mode 100644 index 0000000..d57283a --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/pt-sigsuspend.c @@ -0,0 +1 @@ +#include "../../ia64/pt-sigsuspend.c" diff --git a/linuxthreads/sysdeps/unix/sysv/linux/x86_64/pt-sigsuspend.c b/linuxthreads/sysdeps/unix/sysv/linux/x86_64/pt-sigsuspend.c new file mode 100644 index 0000000..3a0c2af --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/x86_64/pt-sigsuspend.c @@ -0,0 +1 @@ +#include "../ia64/pt-sigsuspend.c" diff --git a/linuxthreads/tst-cancel7.c b/linuxthreads/tst-cancel7.c new file mode 100644 index 0000000..11298ea --- /dev/null +++ b/linuxthreads/tst-cancel7.c @@ -0,0 +1,111 @@ +/* Test for pthread cancellation of mutex blocks. + Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek <jakub@redhat.com>, 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + 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. */ + +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; +pthread_barrier_t b; +int value = 0; + +static void * +tf (void *arg) +{ + int r = pthread_barrier_wait (&b); + if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) + { + printf ("%s: barrier_wait failed\n", __FUNCTION__); + exit (1); + } + + pthread_mutex_lock (&lock); + ++value; + pthread_testcancel (); + ++value; + pthread_mutex_unlock (&lock); + return NULL; +} + + +static int +do_test (void) +{ + pthread_mutex_lock (&lock); + + if (pthread_barrier_init (&b, NULL, 2) != 0) + { + puts ("barrier init failed"); + return 1; + } + + pthread_t th; + if (pthread_create (&th, NULL, tf, NULL) != 0) + { + puts ("pthread_create failed"); + return 1; + } + + int r = pthread_barrier_wait (&b); + if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) + { + printf ("%s: barrier_wait failed\n", __FUNCTION__); + exit (1); + } + + if (pthread_cancel (th) != 0) + { + puts ("pthread_cancel failed"); + return 1; + } + + pthread_mutex_unlock (&lock); + + void *status; + if (pthread_join (th, &status) != 0) + { + puts ("join failed"); + return 1; + } + + if (status != PTHREAD_CANCELED) + { + puts ("thread not canceled"); + return 1; + } + + if (value == 0) + { + puts ("thread cancelled in the pthread_mutex_lock call"); + return 1; + } + + if (value != 1) + { + puts ("thread not cancelled in pthread_testcancel call"); + return 1; + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" |