Message ID | 20200312205424.17101-2-adhemerval.zanella@linaro.org |
---|---|
State | New |
Headers | show |
Series | [1/3] nptl: Move pthread_sigmask implementation to libc | expand |
On 12/03/2020 17:54, Adhemerval Zanella wrote: > With pthread_sigmask on libc.so, it allows consolidate both > implementations. > > Checked on x86_64-linux-gnu. Updated patch below due the update of the previous one: -- diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index edec8d0501..c6d8fc69be 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -484,6 +484,7 @@ extern int __pthread_clockjoin_ex (pthread_t, void **, clockid_t, attribute_hidden; extern int __pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask); +libc_hidden_proto (__pthread_sigmask) #if IS_IN (libpthread) diff --git a/nptl/pthread_sigmask.c b/nptl/pthread_sigmask.c index 2c3ba8d59b..cf134c53ab 100644 --- a/nptl/pthread_sigmask.c +++ b/nptl/pthread_sigmask.c @@ -49,6 +49,7 @@ __pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask) } #if IS_IN(libc) +libc_hidden_def (__pthread_sigmask) weak_alias (__pthread_sigmask, pthread_sigmask) #elif IS_IN(libpthread) # if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_32) diff --git a/sysdeps/unix/sysv/linux/sigprocmask.c b/sysdeps/unix/sysv/linux/sigprocmask.c index eb9e4d5e83..6ed0ab1e6a 100644 --- a/sysdeps/unix/sysv/linux/sigprocmask.c +++ b/sysdeps/unix/sysv/linux/sigprocmask.c @@ -22,21 +22,11 @@ int __sigprocmask (int how, const sigset_t *set, sigset_t *oset) { - sigset_t local_newmask; - - /* The only thing we have to make sure here is that SIGCANCEL and - SIGSETXID are not blocked. */ - if (set != NULL - && __glibc_unlikely (__sigismember (set, SIGCANCEL) - || __glibc_unlikely (__sigismember (set, SIGSETXID)))) - { - local_newmask = *set; - __sigdelset (&local_newmask, SIGCANCEL); - __sigdelset (&local_newmask, SIGSETXID); - set = &local_newmask; - } - - return INLINE_SYSCALL_CALL (rt_sigprocmask, how, set, oset, _NSIG / 8); + int result = __pthread_sigmask (how, set, oset); + if (result == 0) + return 0; + __set_errno (result); + return result; } libc_hidden_def (__sigprocmask) weak_alias (__sigprocmask, sigprocmask)
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 06fb0d74c5..c6d8fc69be 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -482,6 +482,9 @@ extern void __pthread_testcancel (void); extern int __pthread_clockjoin_ex (pthread_t, void **, clockid_t, const struct timespec *, bool) attribute_hidden; +extern int __pthread_sigmask (int how, const sigset_t *newmask, + sigset_t *oldmask); +libc_hidden_proto (__pthread_sigmask) #if IS_IN (libpthread) diff --git a/nptl/pthread_sigmask.c b/nptl/pthread_sigmask.c index c7860e02a5..9c7e9e270a 100644 --- a/nptl/pthread_sigmask.c +++ b/nptl/pthread_sigmask.c @@ -23,7 +23,7 @@ int -pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask) +__pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask) { sigset_t local_newmask; @@ -47,3 +47,5 @@ pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask) ? INTERNAL_SYSCALL_ERRNO (result) : 0); } +libc_hidden_def (__pthread_sigmask) +weak_alias (__pthread_sigmask, pthread_sigmask) diff --git a/sysdeps/unix/sysv/linux/sigprocmask.c b/sysdeps/unix/sysv/linux/sigprocmask.c index eb9e4d5e83..6ed0ab1e6a 100644 --- a/sysdeps/unix/sysv/linux/sigprocmask.c +++ b/sysdeps/unix/sysv/linux/sigprocmask.c @@ -22,21 +22,11 @@ int __sigprocmask (int how, const sigset_t *set, sigset_t *oset) { - sigset_t local_newmask; - - /* The only thing we have to make sure here is that SIGCANCEL and - SIGSETXID are not blocked. */ - if (set != NULL - && __glibc_unlikely (__sigismember (set, SIGCANCEL) - || __glibc_unlikely (__sigismember (set, SIGSETXID)))) - { - local_newmask = *set; - __sigdelset (&local_newmask, SIGCANCEL); - __sigdelset (&local_newmask, SIGSETXID); - set = &local_newmask; - } - - return INLINE_SYSCALL_CALL (rt_sigprocmask, how, set, oset, _NSIG / 8); + int result = __pthread_sigmask (how, set, oset); + if (result == 0) + return 0; + __set_errno (result); + return result; } libc_hidden_def (__sigprocmask) weak_alias (__sigprocmask, sigprocmask)