diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-02-17 10:22:52 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-02-17 10:22:52 +0000 |
commit | 5430d926c54d552794e2ef626b37b7f8bc1ec68e (patch) | |
tree | 8f07e18afee8bdebefc1f9863888c52f8c992ebc | |
parent | 179ff175dff6afdb1f2a12f8c18fa48b29bbee6a (diff) | |
download | glibc-5430d926c54d552794e2ef626b37b7f8bc1ec68e.zip glibc-5430d926c54d552794e2ef626b37b7f8bc1ec68e.tar.gz glibc-5430d926c54d552794e2ef626b37b7f8bc1ec68e.tar.bz2 |
Update.
2003-02-17 Ulrich Drepper <drepper@redhat.com>
* Makefile (tests): Add tst-basic6.
* tst-basic6.c: New file.
* tst-basic1.c: Add test for process ID.
* Makefile (tests): Add tst-cancel10.
* tst-cancel10.c: New file.
* Makefile (tests): Add tst-signal4.
* tst-signal4.c: New file.
* sysdeps/pthread/pthread_sigmask.c (pthread_sigmask): Use
__sigismember instead of sigismember. Add __builtin_expect.
-rw-r--r-- | nptl/ChangeLog | 16 | ||||
-rw-r--r-- | nptl/Makefile | 6 | ||||
-rw-r--r-- | nptl/sysdeps/pthread/pthread_sigmask.c | 3 | ||||
-rw-r--r-- | nptl/tst-basic1.c | 16 | ||||
-rw-r--r-- | nptl/tst-cancel10.c | 106 | ||||
-rw-r--r-- | nptl/tst-signal4.c | 60 |
6 files changed, 200 insertions, 7 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 654c462..2acb2fb 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,3 +1,19 @@ +2003-02-17 Ulrich Drepper <drepper@redhat.com> + + * Makefile (tests): Add tst-basic6. + * tst-basic6.c: New file. + + * tst-basic1.c: Add test for process ID. + + * Makefile (tests): Add tst-cancel10. + * tst-cancel10.c: New file. + + * Makefile (tests): Add tst-signal4. + * tst-signal4.c: New file. + + * sysdeps/pthread/pthread_sigmask.c (pthread_sigmask): Use + __sigismember instead of sigismember. Add __builtin_expect. + 2003-02-16 Ulrich Drepper <drepper@redhat.com> * tst-attr1.c (do_test): Add tests for pthread_setcanceltype, diff --git a/nptl/Makefile b/nptl/Makefile index b4bbe99..c2353bc 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -136,16 +136,16 @@ tests = tst-attr1 tst-attr2 \ tst-key1 tst-key2 tst-key3 \ tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 \ tst-barrier1 tst-barrier2 tst-barrier3 \ - tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 \ + tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \ tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 \ tst-tsd1 tst-tsd2 \ tst-fork1 tst-fork2 tst-fork3 \ tst-atfork1 \ tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \ - tst-cancel6 tst-cancel7 tst-cancel8 tst-cancel9 \ + tst-cancel6 tst-cancel7 tst-cancel8 tst-cancel9 tst-cancel10 \ tst-cleanup1 tst-cleanup2 tst-cleanup3 \ tst-flock1 tst-flock2 \ - tst-signal1 tst-signal2 tst-signal3 \ + tst-signal1 tst-signal2 tst-signal3 tst-signal4 \ tst-exec1 tst-exec2 tst-exec3 \ tst-exit1 \ tst-stdio1 tst-stdio2 \ diff --git a/nptl/sysdeps/pthread/pthread_sigmask.c b/nptl/sysdeps/pthread/pthread_sigmask.c index 3a3fa35..4114e0b 100644 --- a/nptl/sysdeps/pthread/pthread_sigmask.c +++ b/nptl/sysdeps/pthread/pthread_sigmask.c @@ -34,8 +34,7 @@ pthread_sigmask (how, newmask, oldmask) /* The only thing we have to make sure here is that SIGCANCEL is not blocked. */ if (newmask != NULL - && (how == SIG_SETMASK || how == SIG_BLOCK) - && sigismember (newmask, SIGCANCEL)) + && __builtin_expect (__sigismember (newmask, SIGCANCEL), 0)) { local_newmask = *newmask; sigdelset (&local_newmask, SIGCANCEL); diff --git a/nptl/tst-basic1.c b/nptl/tst-basic1.c index 36ae767..8bb736e 100644 --- a/nptl/tst-basic1.c +++ b/nptl/tst-basic1.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -20,10 +20,20 @@ #include <pthread.h> #include <stdio.h> #include <unistd.h> +#include <sys/types.h> -static void *tf (void *a) +static pid_t pid; + +static void * +tf (void *a) { + if (getpid () != pid) + { + write (2, "pid mismatch\n", 13); + _exit (1); + } + return a; } @@ -31,6 +41,8 @@ static void *tf (void *a) int do_test (void) { + pid = getpid (); + #define N 2 pthread_t t[N]; int i; diff --git a/nptl/tst-cancel10.c b/nptl/tst-cancel10.c new file mode 100644 index 0000000..b8b9953 --- /dev/null +++ b/nptl/tst-cancel10.c @@ -0,0 +1,106 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@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 <string.h> + + +static void +cleanup (void *arg) +{ + /* Just for fun. */ + if (pthread_cancel (pthread_self ()) != 0) + { + puts ("cleanup: cancel failed"); + exit (1); + } + + printf ("cleanup for %ld\n", (long int) arg); +} + + +static void * +tf (void *arg) +{ + long int n = (long int) arg; + + pthread_cleanup_push (cleanup, arg); + + if (pthread_setcanceltype ((n & 1) == 0 + ? PTHREAD_CANCEL_DEFERRED + : PTHREAD_CANCEL_ASYNCHRONOUS, NULL) != 0) + { + puts ("setcanceltype failed"); + exit (1); + } + + if (pthread_cancel (pthread_self ()) != 0) + { + puts ("cancel failed"); + exit (1); + } + + pthread_testcancel (); + + /* We should never come here. */ + + pthread_cleanup_pop (0); + + return NULL; +} + + +static int +do_test (void) +{ +#define N 20 + int i; + pthread_t th[N]; + + for (i = 0; i < N; ++i) + if (pthread_create (&th[i], NULL, tf, (void *) (long int) i) != 0) + { + puts ("create failed"); + exit (1); + } + + for (i = 0; i < N; ++i) + { + void *r; + if (pthread_join (th[i], &r) != 0) + { + puts ("join failed"); + exit (1); + } + + if (r != PTHREAD_CANCELED) + { + puts ("thread not canceled"); + exit (1); + } + } + + return 0; +} + + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/nptl/tst-signal4.c b/nptl/tst-signal4.c new file mode 100644 index 0000000..dcb2893 --- /dev/null +++ b/nptl/tst-signal4.c @@ -0,0 +1,60 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@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 <errno.h> +#include <pthread.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> + +static int +do_test (void) +{ + sigset_t ss; + + sigemptyset (&ss); + + int i; + for (i = 0; i < 10000; ++i) + { + long int r = random (); + + if (r != SIG_BLOCK && r != SIG_SETMASK && r != SIG_UNBLOCK) + { + int e = pthread_sigmask (r, &ss, NULL); + + if (e == 0) + { + printf ("pthread_sigmask succeeded for how = %ld\n", r); + exit (1); + } + + if (e != EINVAL) + { + puts ("pthread_sigmask didn't return EINVAL"); + exit (1); + } + } + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" |