mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 20:40:05 +00:00
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.
This commit is contained in:
parent
179ff175df
commit
5430d926c5
@ -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,
|
||||
|
@ -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 \
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
106
nptl/tst-cancel10.c
Normal file
106
nptl/tst-cancel10.c
Normal file
@ -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"
|
60
nptl/tst-signal4.c
Normal file
60
nptl/tst-signal4.c
Normal file
@ -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"
|
Loading…
Reference in New Issue
Block a user