diff options
Diffstat (limited to 'libc/sysdeps/linux/common/sigprocmask.c')
-rw-r--r-- | libc/sysdeps/linux/common/sigprocmask.c | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/libc/sysdeps/linux/common/sigprocmask.c b/libc/sysdeps/linux/common/sigprocmask.c index 13bb2beb7..011d7b367 100644 --- a/libc/sysdeps/linux/common/sigprocmask.c +++ b/libc/sysdeps/linux/common/sigprocmask.c @@ -14,6 +14,7 @@ #undef sigprocmask +libc_hidden_proto(sigprocmask) #ifdef __NR_rt_sigprocmask @@ -24,20 +25,28 @@ _syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set, int sigprocmask(int how, const sigset_t * set, sigset_t * oldset) { - if (set && -# if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2) - (((unsigned int) how) > 2) -# elif (SIG_BLOCK == 1) && (SIG_UNBLOCK == 2) && (SIG_SETMASK == 3) - (((unsigned int)(how-1)) > 2) -# else -# warning "compile time assumption violated.. slow path..." - ((how != SIG_BLOCK) && (how != SIG_UNBLOCK) - && (how != SIG_SETMASK)) +#ifdef SIGCANCEL + sigset_t local_newmask; + + /* + * The only thing we have to make sure here is that SIGCANCEL and + * SIGSETXID are not blocked. + */ + if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) +# ifdef SIGSETXID + || __builtin_expect (__sigismember (set, SIGSETXID), 0) +# endif + )) + { + local_newmask = *set; + __sigdelset (&local_newmask, SIGCANCEL); +# ifdef SIGSETXID + __sigdelset (&local_newmask, SIGSETXID); # endif - ) { - __set_errno(EINVAL); - return -1; + set = &local_newmask; } +#endif + return __rt_sigprocmask(how, set, oldset, _NSIG / 8); } @@ -51,20 +60,28 @@ _syscall3(int, __syscall_sigprocmask, int, how, const sigset_t *, set, int sigprocmask(int how, const sigset_t * set, sigset_t * oldset) { - if (set && -# if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2) - (((unsigned int) how) > 2) -# elif (SIG_BLOCK == 1) && (SIG_UNBLOCK == 2) && (SIG_SETMASK == 3) - (((unsigned int)(how-1)) > 2) -# else -# warning "compile time assumption violated.. slow path..." - ((how != SIG_BLOCK) && (how != SIG_UNBLOCK) - && (how != SIG_SETMASK)) +#ifdef SIGCANCEL + sigset_t local_newmask; + + /* + * The only thing we have to make sure here is that SIGCANCEL and + * SIGSETXID are not blocked. + */ + if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0) +# ifdef SIGSETXID + || __builtin_expect (__sigismember (set, SIGSETXID), 0) +# endif + )) + { + local_newmask = *set; + __sigdelset (&local_newmask, SIGCANCEL); +# ifdef SIGSETXID + __sigdelset (&local_newmask, SIGSETXID); # endif - ) { - __set_errno(EINVAL); - return -1; + set = &local_newmask; } +#endif + return (__syscall_sigprocmask(how, set, oldset)); } #endif |