diff --git a/sysdeps/unix/sysv/linux/ia64/sigprocmask.c b/sysdeps/unix/sysv/linux/ia64/sigprocmask.c
index 920c5fd052..9e95e52d58 100644
--- a/sysdeps/unix/sysv/linux/ia64/sigprocmask.c
+++ b/sysdeps/unix/sysv/linux/ia64/sigprocmask.c
@@ -17,24 +17,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* Linux/ia64 only has rt signals, thus we do not even want to try falling
-   back to the old style signals as the default Linux handler does. */
+#define NEED_CLEAR_SIGCANCEL_SIGSETXID        0
 
-#include <errno.h>
-#include <signal.h>
-#include <unistd.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-/* Get and/or change the set of blocked signals.  */
-int
-__sigprocmask (int how, const sigset_t *set, sigset_t *oset)
-{
-
-  /* XXX The size argument hopefully will have to be changed to the
-     real size of the user-level sigset_t.  */
-  return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8);
-}
-libc_hidden_def (__sigprocmask)
-weak_alias (__sigprocmask, sigprocmask)
+#include <sysdeps/unix/sysv/linux/sigprocmask.c>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c b/sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c
index a8010e7f14..227b512910 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c
@@ -15,24 +15,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* 64 bit Linux for S/390 only has rt signals, thus we do not even want to try
-   falling back to the old style signals as the default Linux handler does. */
+#define NEED_CLEAR_SIGCANCEL_SIGSETXID        0
 
-#include <errno.h>
-#include <signal.h>
-#include <unistd.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-/* Get and/or change the set of blocked signals.  */
-int
-__sigprocmask (int how, const sigset_t *set, sigset_t *oset)
-{
-
-  /* XXX The size argument hopefully will have to be changed to the
-     real size of the user-level sigset_t.  */
-  return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8);
-}
-libc_hidden_def (__sigprocmask)
-weak_alias (__sigprocmask, sigprocmask)
+#include <sysdeps/unix/sysv/linux/sigprocmask.c>
diff --git a/sysdeps/unix/sysv/linux/sigprocmask.c b/sysdeps/unix/sysv/linux/sigprocmask.c
index e776563336..94d4d0945f 100644
--- a/sysdeps/unix/sysv/linux/sigprocmask.c
+++ b/sysdeps/unix/sysv/linux/sigprocmask.c
@@ -17,19 +17,25 @@
 
 #include <errno.h>
 #include <signal.h>
-#include <string.h>  /* Needed for string function builtin redirection.  */
 #include <unistd.h>
 
 #include <sysdep.h>
 #include <sys/syscall.h>
 
-#include <nptl/pthreadP.h>              /* SIGCANCEL, SIGSETXID */
+#ifndef NEED_CLEAR_SIGCANCEL_SIGSETXID
+#define NEED_CLEAR_SIGCANCEL_SIGSETXID	1
+#endif
 
+#if NEED_CLEAR_SIGCANCEL_SIGSETXID
+#include <nptl/pthreadP.h>
+#include <string.h>
+#endif
 
 /* Get and/or change the set of blocked signals.  */
 int
 __sigprocmask (int how, const sigset_t *set, sigset_t *oset)
 {
+#if NEED_CLEAR_SIGCANCEL_SIGSETXID
   sigset_t local_newmask;
 
   /* The only thing we have to make sure here is that SIGCANCEL and
@@ -43,6 +49,7 @@ __sigprocmask (int how, const sigset_t *set, sigset_t *oset)
       __sigdelset (&local_newmask, SIGSETXID);
       set = &local_newmask;
     }
+#endif
 
   return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8);
 }
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c b/sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c
index ef7d7feb49..0db24d6fce 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c
@@ -15,20 +15,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <signal.h>
-#include <unistd.h>
+#define NEED_CLEAR_SIGCANCEL_SIGSETXID        0
 
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-/* Get and/or change the set of blocked signals.  */
-int
-__sigprocmask (int how, const sigset_t *set, sigset_t *oset)
-{
-  /* XXX The size argument hopefully will have to be changed to the
-     real size of the user-level sigset_t.  */
-  return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8);
-}
-libc_hidden_def (__sigprocmask)
-weak_alias (__sigprocmask, sigprocmask)
+#include <sysdeps/unix/sysv/linux/sigprocmask.c>
diff --git a/sysdeps/unix/sysv/linux/x86_64/sigprocmask.c b/sysdeps/unix/sysv/linux/x86_64/sigprocmask.c
index 1610ddf47f..d3179ebea5 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sigprocmask.c
+++ b/sysdeps/unix/sysv/linux/x86_64/sigprocmask.c
@@ -16,24 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* Linux/x86_64 only has rt signals, thus we do not even want to try falling
-   back to the old style signals as the default Linux handler does. */
+#define NEED_CLEAR_SIGCANCEL_SIGSETXID        0
 
-#include <errno.h>
-#include <signal.h>
-#include <unistd.h>
-
-#include <sysdep.h>
-#include <sys/syscall.h>
-
-/* Get and/or change the set of blocked signals.  */
-int
-__sigprocmask (int how, const sigset_t *set, sigset_t *oset)
-{
-
-  /* XXX The size argument hopefully will have to be changed to the
-     real size of the user-level sigset_t.  */
-  return INLINE_SYSCALL (rt_sigprocmask, 4, how, set, oset, _NSIG / 8);
-}
-libc_hidden_def (__sigprocmask)
-weak_alias (__sigprocmask, sigprocmask)
+#include <sysdeps/unix/sysv/linux/sigprocmask.c>
