* sysdeps/unix/sysv/linux/ia64/sigsuspend.c: File removed.

* sysdeps/unix/sysv/linux/x86_64/sigsuspend.c: File removed.
	* sysdeps/unix/sysv/linux/s390/s390-64/sigsuspend.c: File removed.
	* sysdeps/unix/sysv/linux/sparc/sparc64/sigsuspend.c: File removed.

	* sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): New macro.
	(nanosleep_not_cancel): New macro.
	(sigsuspend_not_cancel): new macro.
	* sysdeps/unix/sysv/linux/sigsuspend.c [__ASSUME_REALTIME_SIGNALS]
	(do_sigsuspend): Define as inline.
	(__sigsuspend): Always use do_sigsuspend.
	[! NO_CANCELLATION] (__sigsuspend_nocancel): New function.
	* include/signal.h: Declare __sigsuspend_nocancel.
	* sysdeps/posix/pause.c
	[! NO_CANCELLATION] (__pause_nocancel): New function.

	* include/unistd.h (__pause_nocancel): Add attribute_hidden.
	* include/time.h (__nanosleep_nocancel): Likewise.
This commit is contained in:
Roland McGrath 2006-07-31 05:58:51 +00:00
parent b32e6700d0
commit b894c2ea7e
14 changed files with 109 additions and 116 deletions

View File

@ -1,3 +1,24 @@
2006-07-30 Roland McGrath <roland@redhat.com>
* sysdeps/unix/sysv/linux/ia64/sigsuspend.c: File removed.
* sysdeps/unix/sysv/linux/x86_64/sigsuspend.c: File removed.
* sysdeps/unix/sysv/linux/s390/s390-64/sigsuspend.c: File removed.
* sysdeps/unix/sysv/linux/sparc/sparc64/sigsuspend.c: File removed.
* sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): New macro.
(nanosleep_not_cancel): New macro.
(sigsuspend_not_cancel): new macro.
* sysdeps/unix/sysv/linux/sigsuspend.c [__ASSUME_REALTIME_SIGNALS]
(do_sigsuspend): Define as inline.
(__sigsuspend): Always use do_sigsuspend.
[! NO_CANCELLATION] (__sigsuspend_nocancel): New function.
* include/signal.h: Declare __sigsuspend_nocancel.
* sysdeps/posix/pause.c
[! NO_CANCELLATION] (__pause_nocancel): New function.
* include/unistd.h (__pause_nocancel): Add attribute_hidden.
* include/time.h (__nanosleep_nocancel): Likewise.
2006-07-30 Ulrich Drepper <drepper@redhat.com> 2006-07-30 Ulrich Drepper <drepper@redhat.com>
* locale/programs/localedef.c (add_to_readlist): Rename local * locale/programs/localedef.c (add_to_readlist): Rename local

View File

@ -26,6 +26,9 @@ extern int __sigprocmask (int __how,
__const sigset_t *__set, sigset_t *__oset); __const sigset_t *__set, sigset_t *__oset);
extern int __sigsuspend (__const sigset_t *__set); extern int __sigsuspend (__const sigset_t *__set);
libc_hidden_proto (__sigsuspend) libc_hidden_proto (__sigsuspend)
#ifndef NO_CANCELLATION
extern int __sigsuspend_nocancel (__const sigset_t *__set) attribute_hidden;
#endif
extern int __sigwait (__const sigset_t *__set, int *__sig); extern int __sigwait (__const sigset_t *__set, int *__sig);
libc_hidden_proto (__sigwait) libc_hidden_proto (__sigwait)
extern int __sigwaitinfo (__const sigset_t *__set, siginfo_t *__info); extern int __sigwaitinfo (__const sigset_t *__set, siginfo_t *__info);

View File

@ -1,3 +1,16 @@
2006-07-30 Roland McGrath <roland@redhat.com>
* Makefile (libpthread-routines): Add ptw-sigsuspend.
* sysdeps/unix/sysv/linux/i386/not-cancel.h
(pause_not_cancel): New macro.
(nanosleep_not_cancel): New macro.
(sigsuspend_not_cancel): New macro.
* pthread_mutex_timedlock.c (pthread_mutex_timedlock): Use
nanosleep_not_cancel macro from <not-cancel.h>.
* pthread_mutex_lock.c (__pthread_mutex_lock): Use pause_not_cancel
macro from <not-cancel.h>.
2006-07-28 Ulrich Drepper <drepper@redhat.com> 2006-07-28 Ulrich Drepper <drepper@redhat.com>
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>

View File

@ -108,7 +108,7 @@ libpthread-routines = init vars events version \
ptw-msync ptw-nanosleep ptw-open ptw-open64 ptw-pause \ ptw-msync ptw-nanosleep ptw-open ptw-open64 ptw-pause \
ptw-pread ptw-pread64 ptw-pwrite ptw-pwrite64 \ ptw-pread ptw-pread64 ptw-pwrite ptw-pwrite64 \
ptw-tcdrain ptw-wait ptw-waitpid ptw-msgrcv ptw-msgsnd \ ptw-tcdrain ptw-wait ptw-waitpid ptw-msgrcv ptw-msgsnd \
ptw-sigwait \ ptw-sigwait ptw-sigsuspend \
pt-raise pt-system \ pt-raise pt-system \
flockfile ftrylockfile funlockfile \ flockfile ftrylockfile funlockfile \
sigaction \ sigaction \

View File

@ -21,6 +21,7 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <not-cancel.h>
#include "pthreadP.h" #include "pthreadP.h"
#include <lowlevellock.h> #include <lowlevellock.h>
@ -278,7 +279,7 @@ __pthread_mutex_lock (mutex)
/* Delay the thread indefinitely. */ /* Delay the thread indefinitely. */
while (1) while (1)
__pause_nocancel (); pause_not_cancel ();
} }
oldval = mutex->__data.__lock; oldval = mutex->__data.__lock;

View File

@ -19,8 +19,10 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <time.h>
#include "pthreadP.h" #include "pthreadP.h"
#include <lowlevellock.h> #include <lowlevellock.h>
#include <not-cancel.h>
int int
@ -281,7 +283,7 @@ pthread_mutex_timedlock (mutex, abstime)
--reltime.tv_sec; --reltime.tv_sec;
} }
if (reltime.tv_sec >= 0) if (reltime.tv_sec >= 0)
while (__nanosleep_nocancel (&reltime, &reltime) != 0) while (nanosleep_not_cancel (&reltime, &reltime) != 0)
continue; continue;
return ETIMEDOUT; return ETIMEDOUT;

View File

@ -91,3 +91,15 @@ extern int __openat64_nocancel (int fd, const char *fname, int oflag,
# define waitpid_not_cancel(pid, stat_loc, options) \ # define waitpid_not_cancel(pid, stat_loc, options) \
INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL) INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
#endif #endif
/* Uncancelable pause. */
#define pause_not_cancel() \
__pause_nocancel ()
/* Uncancelable nanosleep. */
#define nanosleep_not_cancel(requested_time, remaining) \
__nanosleep_nocancel (requested_time, remaining)
/* Uncancelable sigsuspend. */
#define sigsuspend_not_cancel(set) \
__sigsuspend_nocancel (set)

View File

@ -1,5 +1,5 @@
/* pause -- suspend the process until a signal arrives. POSIX.1 version. /* pause -- suspend the process until a signal arrives. POSIX.1 version.
Copyright (C) 2003 Free Software Foundation, Inc. Copyright (C) 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -23,6 +23,7 @@
/* Suspend the process until a signal arrives. /* Suspend the process until a signal arrives.
This always returns -1 and sets errno to EINTR. */ This always returns -1 and sets errno to EINTR. */
int int
__libc_pause (void) __libc_pause (void)
{ {
@ -39,3 +40,18 @@ __libc_pause (void)
weak_alias (__libc_pause, pause) weak_alias (__libc_pause, pause)
LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */ LIBC_CANCEL_HANDLED (); /* sigsuspend handles our cancellation. */
#ifndef NO_CANCELLATION
# include <not-cancel.h>
int
__pause_nocancel (void)
{
sigset_t set;
__sigemptyset (&set);
__sigprocmask (SIG_BLOCK, NULL, &set);
return sigsuspend_not_cancel (&set);
}
#endif

View File

@ -1,49 +0,0 @@
/* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 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-cancel.h>
#include <sys/syscall.h>
#include <bp-checks.h>
/* Change the set of blocked signals to SET,
wait until a signal arrives, and restore the set of blocked signals. */
int
__sigsuspend (set)
const sigset_t *set;
{
/* XXX The size argument hopefully will have to be changed to the
real size of the user-level sigset_t. */
if (SINGLE_THREAD_P)
return INLINE_SYSCALL (rt_sigsuspend, 2, CHECK_SIGSET (set), _NSIG / 8);
int oldtype = LIBC_CANCEL_ASYNC ();
int result = INLINE_SYSCALL (rt_sigsuspend, 2, CHECK_SIGSET (set), _NSIG / 8);
LIBC_CANCEL_RESET (oldtype);
return result;
}
libc_hidden_def (__sigsuspend)
weak_alias (__sigsuspend, sigsuspend)
strong_alias (__sigsuspend, __libc_sigsuspend)

View File

@ -81,3 +81,25 @@ extern int __openat64_nocancel (int fd, const char *fname, int oflag,
# define waitpid_not_cancel(pid, stat_loc, options) \ # define waitpid_not_cancel(pid, stat_loc, options) \
INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL) INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
#endif #endif
/* Uncancelable pause. */
#ifdef __NR_pause
# define pause_not_cancel() \
INLINE_SYSCALL (pause, 0)
#else
# define pause_not_cancel() \
__pause_nocancel ()
#endif
/* Uncancelable nanosleep. */
#ifdef __NR_nanosleep
# define nanosleep_not_cancel(requested_time, remaining) \
INLINE_SYSCALL (nanosleep, 2, requested_time, remaining)
#else
# define nanosleep_not_cancel(requested_time, remaining) \
__nanosleep_nocancel (requested_time, remaining)
#endif
/* Uncancelable sigsuspend. */
#define sigsuspend_not_cancel(set) \
__sigsuspend_nocancel (set)

View File

@ -1,47 +0,0 @@
/* Copyright (C) 2001, 2002, 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-cancel.h>
#include <sys/syscall.h>
/* Change the set of blocked signals to SET,
wait until a signal arrives, and restore the set of blocked signals. */
int
__sigsuspend (set)
const sigset_t *set;
{
/* XXX The size argument hopefully will have to be changed to the
real size of the user-level sigset_t. */
if (SINGLE_THREAD_P)
return INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8);
int oldtype = LIBC_CANCEL_ASYNC ();
int result = INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8);
LIBC_CANCEL_RESET (oldtype);
return result;
}
libc_hidden_def (__sigsuspend)
weak_alias (__sigsuspend, sigsuspend)
strong_alias (__sigsuspend, __libc_sigsuspend)

View File

@ -56,6 +56,12 @@ do_sigsuspend (const sigset_t *set)
return INLINE_SYSCALL (sigsuspend, 3, 0, 0, set->__val[0]); return INLINE_SYSCALL (sigsuspend, 3, 0, 0, set->__val[0]);
} }
#else
static inline int __attribute__ ((always_inline))
do_sigsuspend (const sigset_t *set)
{
return INLINE_SYSCALL (rt_sigsuspend, 2, CHECK_SIGSET (set), _NSIG / 8);
}
#endif #endif
/* Change the set of blocked signals to SET, /* Change the set of blocked signals to SET,
@ -64,19 +70,6 @@ int
__sigsuspend (set) __sigsuspend (set)
const sigset_t *set; const sigset_t *set;
{ {
#if __ASSUME_REALTIME_SIGNALS
if (SINGLE_THREAD_P)
return INLINE_SYSCALL (rt_sigsuspend, 2, CHECK_SIGSET (set), _NSIG / 8);
int oldtype = LIBC_CANCEL_ASYNC ();
int result = INLINE_SYSCALL (rt_sigsuspend, 2, CHECK_SIGSET (set),
_NSIG / 8);
LIBC_CANCEL_RESET (oldtype);
return result;
#else
if (SINGLE_THREAD_P) if (SINGLE_THREAD_P)
return do_sigsuspend (set); return do_sigsuspend (set);
@ -87,8 +80,16 @@ __sigsuspend (set)
LIBC_CANCEL_RESET (oldtype); LIBC_CANCEL_RESET (oldtype);
return result; return result;
#endif
} }
libc_hidden_def (__sigsuspend) libc_hidden_def (__sigsuspend)
weak_alias (__sigsuspend, sigsuspend) weak_alias (__sigsuspend, sigsuspend)
strong_alias (__sigsuspend, __libc_sigsuspend) strong_alias (__sigsuspend, __libc_sigsuspend)
#ifndef NO_CANCELLATION
int
__sigsuspend_nocancel (set)
const sigset_t *set;
{
return do_sigsuspend (set);
}
#endif

View File

@ -1 +0,0 @@
#include "../../ia64/sigsuspend.c"

View File

@ -1 +0,0 @@
#include <sysdeps/unix/sysv/linux/ia64/sigsuspend.c>