[PATCH 2/3] linux: Use pthread_sigmask on sigprocmask
Adhemerval Zanella
adhemerval.zanella@linaro.org
Thu Mar 12 20:54:23 GMT 2020
With pthread_sigmask on libc.so, it allows consolidate both
implementations.
Checked on x86_64-linux-gnu.
---
nptl/pthreadP.h | 3 +++
nptl/pthread_sigmask.c | 4 +++-
sysdeps/unix/sysv/linux/sigprocmask.c | 20 +++++---------------
3 files changed, 11 insertions(+), 16 deletions(-)
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)
--
2.17.1
More information about the Libc-alpha
mailing list