diff options
-rw-r--r-- | libc/signal/Makefile.in | 4 | ||||
-rw-r--r-- | libc/signal/sigwait.c | 82 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/__rt_sigtimedwait.c | 88 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/__rt_sigwaitinfo.c | 95 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/sigprocmask.c | 1 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/pthread/sigaction.c | 4 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/pthread/sigfillset.c | 2 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/pthread/sigprocmask.c | 2 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/unix/sysv/linux/raise.c | 7 | ||||
-rw-r--r-- | libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c | 105 |
10 files changed, 254 insertions, 136 deletions
diff --git a/libc/signal/Makefile.in b/libc/signal/Makefile.in index 26a8f0c56..f21e5ebaa 100644 --- a/libc/signal/Makefile.in +++ b/libc/signal/Makefile.in @@ -11,6 +11,10 @@ CSRC:= allocrtsig.c killpg.c raise.c sigaction.c sigaddset.c sigandset.c \ sigorset.c sigpause.c sigrelse.c sigset.c sigsetmask.c sigsetops.c \ sysv_signal.c sigwait.c +ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y) +CSRC:=$(filter-out raise.c,$(CSRC)) +endif + ifneq ($(strip $(ARCH_OBJS)),) CSRC:=$(filter-out $(notdir $(ARCH_OBJS:.o=.c)),$(CSRC)) endif diff --git a/libc/signal/sigwait.c b/libc/signal/sigwait.c index 13d65ed5e..c8a93dfb2 100644 --- a/libc/signal/sigwait.c +++ b/libc/signal/sigwait.c @@ -1,7 +1,8 @@ /* vi: set sw=4 ts=4: */ /* sigwait * - * Copyright (C) 2003 by Erik Andersen <andersen@uclibc.org> + * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com> + * Copyright (C) 2003-2005 by Erik Andersen <andersen@uclibc.org> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,7 +25,81 @@ #include <signal.h> #include <string.h> -#undef sigwait +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ +# include <sysdep-cancel.h> + +# ifdef __NR_rt_sigtimedwait + +/* Return any pending signal or wait for one for the given time. */ +static int do_sigwait(const sigset_t *set, int *sig) +{ + int ret; + +# ifdef SIGCANCEL + sigset_t tmpset; + if (set != NULL + && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) +# ifdef SIGSETXID + || __builtin_expect (__sigismember (set, SIGSETXID), 0) +# endif + )) + { + /* Create a temporary mask without the bit for SIGCANCEL set. */ + // We are not copying more than we have to. +# ifdef IS_IN_libc + __memcpy(&tmpset, set, _NSIG / 8); +# else + memcpy(&tmpset, set, _NSIG / 8); +# endif + __sigdelset(&tmpset, SIGCANCEL); +# ifdef SIGSETXID + __sigdelset(&tmpset, SIGSETXID); +# endif + set = &tmpset; + } +# endif + + /* XXX The size argument hopefully will have to be changed to the + real size of the user-level sigset_t. */ +# ifdef INTERNAL_SYSCALL + INTERNAL_SYSCALL_DECL(err); + do + ret = INTERNAL_SYSCALL (rt_sigtimedwait, err, 4, set, NULL, + NULL, _NSIG / 8); + while (INTERNAL_SYSCALL_ERROR_P (ret, err) + && INTERNAL_SYSCALL_ERRNO (ret, err) == EINTR); + if (! INTERNAL_SYSCALL_ERROR_P (ret, err)) + { + *sig = ret; + ret = 0; + } +else + ret = INTERNAL_SYSCALL_ERRNO (ret, err); +# else +# error INTERNAL_SYSCALL must be defined!!! +# endif + + return ret; +} + +int __sigwait (const sigset_t *set, int *sig) +{ + if(SINGLE_THREAD_P) + return do_sigwait(set, sig); + + int oldtype = LIBC_CANCEL_ASYNC(); + + int result = do_sigwait(set, sig); + + LIBC_CANCEL_RESET(oldtype); + + return result; +} +# else +# error We must have rt_sigtimedwait defined!!! +# endif +#else +# undef sigwait int attribute_hidden __sigwait (const sigset_t *set, int *sig) { int ret = 1; @@ -34,6 +109,5 @@ int attribute_hidden __sigwait (const sigset_t *set, int *sig) } return 1; } - -/* psm: keep this weak, because the one in libpthread.so could overwrite it */ +#endif weak_alias(__sigwait, sigwait) diff --git a/libc/sysdeps/linux/common/__rt_sigtimedwait.c b/libc/sysdeps/linux/common/__rt_sigtimedwait.c index 09409fe81..f468222af 100644 --- a/libc/sysdeps/linux/common/__rt_sigtimedwait.c +++ b/libc/sysdeps/linux/common/__rt_sigtimedwait.c @@ -2,6 +2,7 @@ /* * __rt_sigtimedwait() for uClibc * + * Copyright (C) 2006 by Steven Hill <sjhill@realitydiluted.com> * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org> * * GNU Library General Public License (LGPL) version 2 or later. @@ -9,35 +10,84 @@ #include "syscalls.h" #include <signal.h> -#define __need_NULL -#include <stddef.h> + #ifdef __NR_rt_sigtimedwait -#define __NR___rt_sigtimedwait __NR_rt_sigtimedwait -static _syscall4(int, __rt_sigtimedwait, const sigset_t *, set, siginfo_t *, info, - const struct timespec *, timeout, size_t, setsize); -int attribute_hidden __sigwaitinfo(const sigset_t * set, siginfo_t * info) +# ifdef __UCLIBC_HAS_THREADS_NATIVE__ +# include <sysdep-cancel.h> + +static int do_sigtimedwait(const sigset_t *set, siginfo_t *info, + const struct timespec *timeout) { - return __rt_sigtimedwait(set, info, NULL, _NSIG / 8); +# ifdef SIGCANCEL + sigset_t tmpset; + + if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) +# ifdef SIGSETXID + || __builtin_expect (__sigismember (set, SIGSETXID), 0) +# endif + )) + { + /* Create a temporary mask without the bit for SIGCANCEL set. */ + // We are not copying more than we have to. + __memcpy (&tmpset, set, _NSIG / 8); + __sigdelset (&tmpset, SIGCANCEL); +# ifdef SIGSETXID + __sigdelset (&tmpset, SIGSETXID); +# endif + set = &tmpset; + } +# endif + + /* XXX The size argument hopefully will have to be changed to the + real size of the user-level sigset_t. */ + int result = INLINE_SYSCALL (rt_sigtimedwait, 4, set, info, + timeout, _NSIG / 8); + + /* The kernel generates a SI_TKILL code in si_code in case tkill is + used. tkill is transparently used in raise(). Since having + SI_TKILL as a code is useful in general we fold the results + here. */ + if (result != -1 && info != NULL && info->si_code == SI_TKILL) + info->si_code = SI_USER; + + return result; } +/* Return any pending signal or wait for one for the given time. */ +int __sigtimedwait(const sigset_t *set, siginfo_t *info, + const struct timespec *timeout) +{ + if(SINGLE_THREAD_P) + return do_sigtimedwait(set, info, timeout); + + int oldtype = LIBC_CANCEL_ASYNC(); + + /* XXX The size argument hopefully will have to be changed to the + real size of the user-level sigset_t. */ + int result = do_sigtimedwait(set, info, timeout); + + LIBC_CANCEL_RESET(oldtype); + + return result; +} +# else +# define __need_NULL +# include <stddef.h> +# define __NR___rt_sigtimedwait __NR_rt_sigtimedwait +static _syscall4(int, __rt_sigtimedwait, const sigset_t *, set, + siginfo_t *, info, const struct timespec *, timeout, + size_t, setsize); + int attribute_hidden __sigtimedwait(const sigset_t * set, siginfo_t * info, - const struct timespec *timeout) + const struct timespec *timeout) { return __rt_sigtimedwait(set, info, timeout, _NSIG / 8); } +# endif #else -int attribute_hidden __sigwaitinfo(const sigset_t * set, siginfo_t * info) -{ - if (set == NULL) - __set_errno(EINVAL); - else - __set_errno(ENOSYS); - return -1; -} - int attribute_hidden __sigtimedwait(const sigset_t * set, siginfo_t * info, - const struct timespec *timeout) + const struct timespec *timeout) { if (set == NULL) __set_errno(EINVAL); @@ -46,6 +96,4 @@ int attribute_hidden __sigtimedwait(const sigset_t * set, siginfo_t * info, return -1; } #endif -/* keep these weak so that libpthread can overwrite them */ weak_alias(__sigtimedwait,sigtimedwait) -weak_alias(__sigwaitinfo,sigwaitinfo) diff --git a/libc/sysdeps/linux/common/__rt_sigwaitinfo.c b/libc/sysdeps/linux/common/__rt_sigwaitinfo.c new file mode 100644 index 000000000..81c34435f --- /dev/null +++ b/libc/sysdeps/linux/common/__rt_sigwaitinfo.c @@ -0,0 +1,95 @@ +/* vi: set sw=4 ts=4: */ +/* + * __rt_sigwaitinfo() for uClibc + * + * Copyright (C) 2006 by Steven Hill <sjhill@realitydiluted.com> + * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org> + * + * GNU Library General Public License (LGPL) version 2 or later. + */ + +#include "syscalls.h" +#include <signal.h> + +#ifdef __NR_rt_sigtimedwait + +# ifdef __UCLIBC_HAS_THREADS_NATIVE__ +# include <sysdep-cancel.h> + +static int do_sigwaitinfo(const sigset_t *set, siginfo_t *info) +{ +# ifdef SIGCANCEL + sigset_t tmpset; + + if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) +# ifdef SIGSETXID + || __builtin_expect (__sigismember (set, SIGSETXID), 0) +# endif + )) + { + /* Create a temporary mask without the bit for SIGCANCEL set. */ + // We are not copying more than we have to. + __memcpy (&tmpset, set, _NSIG / 8); + __sigdelset (&tmpset, SIGCANCEL); +# ifdef SIGSETXID + __sigdelset (&tmpset, SIGSETXID); +# endif + set = &tmpset; + } +# endif + + /* XXX The size argument hopefully will have to be changed to the + real size of the user-level sigset_t. */ + int result = INLINE_SYSCALL (rt_sigtimedwait, 4, set, info, + NULL, _NSIG / 8); + + /* The kernel generates a SI_TKILL code in si_code in case tkill is + used. tkill is transparently used in raise(). Since having + SI_TKILL as a code is useful in general we fold the results + here. */ + if (result != -1 && info != NULL && info->si_code == SI_TKILL) + info->si_code = SI_USER; + + return result; +} + +/* Return any pending signal or wait for one for the given time. */ +int __sigwaitinfo(const sigset_t *set, siginfo_t *info) +{ + if(SINGLE_THREAD_P) + return do_sigwaitinfo(set, info); + + int oldtype = LIBC_CANCEL_ASYNC(); + + /* XXX The size argument hopefully will have to be changed to the + real size of the user-level sigset_t. */ + int result = do_sigwaitinfo(set, info); + + LIBC_CANCEL_RESET(oldtype); + + return result; +} +# else +# define __need_NULL +# include <stddef.h> +# define __NR___rt_sigwaitinfo __NR_rt_sigwaitinfo +static _syscall4(int, __rt_sigwaitinfo, const sigset_t *, set, + siginfo_t *, info, const struct timespec *, timeout, + size_t, setsize); + +int attribute_hidden __sigwaitinfo(const sigset_t * set, siginfo_t * info) +{ + return __rt_sigwaitinfo(set, info, NULL, _NSIG / 8); +} +# endif +#else +int attribute_hidden __sigwaitinfo(const sigset_t * set, siginfo_t * info) +{ + if (set == NULL) + __set_errno(EINVAL); + else + __set_errno(ENOSYS); + return -1; +} +#endif +weak_alias(__sigwaitinfo,sigwaitinfo) diff --git a/libc/sysdeps/linux/common/sigprocmask.c b/libc/sysdeps/linux/common/sigprocmask.c index c555bb51b..803f5b4ae 100644 --- a/libc/sysdeps/linux/common/sigprocmask.c +++ b/libc/sysdeps/linux/common/sigprocmask.c @@ -2,6 +2,7 @@ /* * sigprocmask() for uClibc * + * Copyright (C) 2006 by Steven J. Hill <sjhill@uclibc.org> * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org> * * GNU Library General Public License (LGPL) version 2 or later. diff --git a/libpthread/nptl/sysdeps/pthread/sigaction.c b/libpthread/nptl/sysdeps/pthread/sigaction.c index 6ab8a5279..7524b3e34 100644 --- a/libpthread/nptl/sysdeps/pthread/sigaction.c +++ b/libpthread/nptl/sysdeps/pthread/sigaction.c @@ -28,7 +28,7 @@ SIGCANCEL or SIGTIMER to be handled. */ # define LIBC_SIGACTION 1 -# include_next <sigaction.c> +# include <sigaction.c> int __sigaction (sig, act, oact) @@ -44,7 +44,7 @@ __sigaction (sig, act, oact) return __libc_sigaction (sig, act, oact); } -weak_alias(__sigaction, sigaction) +hidden_weak_alias(__sigaction, sigaction) #else diff --git a/libpthread/nptl/sysdeps/pthread/sigfillset.c b/libpthread/nptl/sysdeps/pthread/sigfillset.c index c95847f65..fbe458f55 100644 --- a/libpthread/nptl/sysdeps/pthread/sigfillset.c +++ b/libpthread/nptl/sysdeps/pthread/sigfillset.c @@ -18,4 +18,4 @@ #include <pthreadP.h> -#include_next <sigfillset.c> +#include <../../../../libc/signal/sigfillset.c> diff --git a/libpthread/nptl/sysdeps/pthread/sigprocmask.c b/libpthread/nptl/sysdeps/pthread/sigprocmask.c index 3c3209384..7a3891d32 100644 --- a/libpthread/nptl/sysdeps/pthread/sigprocmask.c +++ b/libpthread/nptl/sysdeps/pthread/sigprocmask.c @@ -18,4 +18,4 @@ #include <pthreadP.h> -#include_next <sigprocmask.c> +#include <../../../../libc/sysdeps/linux/common/sigprocmask.c> diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c b/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c index 0669cab78..07cb35ae1 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c @@ -25,8 +25,8 @@ #include <kernel-features.h> -int -raise (sig) +int attribute_hidden +__raise (sig) int sig; { struct pthread *pd = THREAD_SELF; @@ -71,5 +71,4 @@ raise (sig) return INLINE_SYSCALL (tkill, 2, selftid, sig); #endif } -hidden_def (raise) -weak_alias (raise, gsignal) +weak_alias(__raise, raise) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c b/libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c index 51d1829c3..bde0a9292 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sigwait.c @@ -1,105 +1,2 @@ -/* Copyright (C) 1997,1998,2000,2002-2004,2005 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 <pthreadP.h> -#include <errno.h> -#include <signal.h> -#define __need_NULL -#include <stddef.h> -#include <string.h> - -#include <sysdep-cancel.h> -#include <sys/syscall.h> - -#ifdef __NR_rt_sigtimedwait - -/* Return any pending signal or wait for one for the given time. */ -static int -do_sigwait (const sigset_t *set, int *sig) -{ - int ret; - -#ifdef SIGCANCEL - sigset_t tmpset; - if (set != NULL - && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) -# ifdef SIGSETXID - || __builtin_expect (__sigismember (set, SIGSETXID), 0) -# endif - )) - { - /* Create a temporary mask without the bit for SIGCANCEL set. */ - // We are not copying more than we have to. - memcpy (&tmpset, set, _NSIG / 8); - __sigdelset (&tmpset, SIGCANCEL); -# ifdef SIGSETXID - __sigdelset (&tmpset, SIGSETXID); -# endif - set = &tmpset; - } -#endif - - /* XXX The size argument hopefully will have to be changed to the - real size of the user-level sigset_t. */ -#ifdef INTERNAL_SYSCALL - INTERNAL_SYSCALL_DECL (err); - do - ret = INTERNAL_SYSCALL (rt_sigtimedwait, err, 4, set, - NULL, NULL, _NSIG / 8); - while (INTERNAL_SYSCALL_ERROR_P (ret, err) - && INTERNAL_SYSCALL_ERRNO (ret, err) == EINTR); - if (! INTERNAL_SYSCALL_ERROR_P (ret, err)) - { - *sig = ret; - ret = 0; - } - else - ret = INTERNAL_SYSCALL_ERRNO (ret, err); -#else - do - ret = INLINE_SYSCALL (rt_sigtimedwait, 4, set, - NULL, NULL, _NSIG / 8); - while (ret == -1 && errno == EINTR); - if (ret != -1) - { - *sig = ret; - ret = 0; - } - else - ret = errno; -#endif - - return ret; -} - -int attribute_hidden -__sigwait (const sigset_t *set, int *sig) -{ - if (SINGLE_THREAD_P) - return do_sigwait (set, sig); - - int oldtype = LIBC_CANCEL_ASYNC (); - - int result = do_sigwait (set, sig); - - LIBC_CANCEL_RESET (oldtype); - - return result; -} -weak_alias (__sigwait, sigwait) -#endif +#include "../../../../../../libc/signal/sigwait.c" |