[PATCH v2 3/4] linux: Use pthread_sigmask on sigprocmask

Adhemerval Zanella adhemerval.zanella@linaro.org
Fri Mar 13 19:48:26 GMT 2020


With pthread_sigmask on libc.so, it allows consolidate both
implementations.

Checked on x86_64-linux-gnu.
---
 nptl/pthreadP.h                       |  1 +
 nptl/pthread_sigmask.c                |  2 ++
 sysdeps/unix/sysv/linux/sigprocmask.c | 20 +++++---------------
 3 files changed, 8 insertions(+), 15 deletions(-)

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 0e326d610c..c6c6e83c08 100644
--- a/nptl/pthread_sigmask.c
+++ b/nptl/pthread_sigmask.c
@@ -46,6 +46,8 @@ __pthread_sigmask (int how, const sigset_t *newmask, sigset_t *oldmask)
 	  ? INTERNAL_SYSCALL_ERRNO (result)
 	  : 0);
 }
+libc_hidden_def (__pthread_sigmask)
+
 versioned_symbol (libc, __pthread_sigmask, pthread_sigmask, GLIBC_2_32);
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_32)
 strong_alias (__pthread_sigmask, __pthread_sigmask_2);
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