diff mbox series

[17/19] nptl: Add pthread_attr_setsigmask_np, pthread_attr_getsigmask_np

Message ID 0e7a4cf5916f879db0fde6f0f5edec6af189fc54.1589884403.git.fweimer@redhat.com
State New
Headers show
Series Signal mask for timer helper thread | expand

Commit Message

Florian Weimer May 19, 2020, 10:44 a.m. UTC
---
 NEWS                                          |   4 +
 nptl/Makefile                                 |   4 +
 nptl/Versions                                 |   3 +
 nptl/pthreadP.h                               |  10 +
 nptl/pthread_attr_copy.c                      |   5 +
 nptl/pthread_attr_getsigmask.c                |  38 ++++
 nptl/pthread_attr_setsigmask.c                |  34 +++
 nptl/pthread_attr_setsigmask_internal.c       |  45 ++++
 nptl/pthread_create.c                         |  25 ++-
 nptl/tst-pthread-attr-sigmask.c               | 204 ++++++++++++++++++
 sysdeps/nptl/internaltypes.h                  |   3 +
 sysdeps/nptl/pthread.h                        |  15 ++
 sysdeps/unix/sysv/linux/aarch64/libc.abilist  |   2 +
 sysdeps/unix/sysv/linux/alpha/libc.abilist    |   2 +
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |   2 +
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |   2 +
 sysdeps/unix/sysv/linux/csky/libc.abilist     |   2 +
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |   2 +
 sysdeps/unix/sysv/linux/i386/libc.abilist     |   2 +
 sysdeps/unix/sysv/linux/ia64/libc.abilist     |   2 +
 .../sysv/linux/m68k/coldfire/libc.abilist     |   2 +
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |   2 +
 .../sysv/linux/microblaze/be/libc.abilist     |   2 +
 .../sysv/linux/microblaze/le/libc.abilist     |   2 +
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |   2 +
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |   2 +
 .../sysv/linux/mips/mips64/n32/libc.abilist   |   2 +
 .../sysv/linux/mips/mips64/n64/libc.abilist   |   2 +
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |   2 +
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |   2 +
 .../powerpc/powerpc32/nofpu/libc.abilist      |   2 +
 .../linux/powerpc/powerpc64/be/libc.abilist   |   2 +
 .../linux/powerpc/powerpc64/le/libc.abilist   |   2 +
 .../unix/sysv/linux/riscv/rv64/libc.abilist   |   2 +
 .../unix/sysv/linux/s390/s390-32/libc.abilist |   2 +
 .../unix/sysv/linux/s390/s390-64/libc.abilist |   2 +
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |   2 +
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |   2 +
 .../sysv/linux/sparc/sparc32/libc.abilist     |   2 +
 .../sysv/linux/sparc/sparc64/libc.abilist     |   2 +
 .../unix/sysv/linux/x86_64/64/libc.abilist    |   2 +
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |   2 +
 42 files changed, 442 insertions(+), 8 deletions(-)
 create mode 100644 nptl/pthread_attr_getsigmask.c
 create mode 100644 nptl/pthread_attr_setsigmask.c
 create mode 100644 nptl/pthread_attr_setsigmask_internal.c
 create mode 100644 nptl/tst-pthread-attr-sigmask.c

Comments

Carlos O'Donell June 2, 2020, 4:01 a.m. UTC | #1
On 5/19/20 6:44 AM, Florian Weimer via Libc-alpha wrote:

OK for master with NEWS entry sentence fix (missing word),
and typo fixed.

The new interface looks good to me and is generally useful
for starting a thread with the given signal mask and avoiding
the usual coordination between caller and thread (which can
be very useful).

No regressions on x86_64 and i686, and the tst-timer-sigmask
failure is gone.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  NEWS                                          |   4 +
>  nptl/Makefile                                 |   4 +
>  nptl/Versions                                 |   3 +
>  nptl/pthreadP.h                               |  10 +
>  nptl/pthread_attr_copy.c                      |   5 +
>  nptl/pthread_attr_getsigmask.c                |  38 ++++
>  nptl/pthread_attr_setsigmask.c                |  34 +++
>  nptl/pthread_attr_setsigmask_internal.c       |  45 ++++
>  nptl/pthread_create.c                         |  25 ++-
>  nptl/tst-pthread-attr-sigmask.c               | 204 ++++++++++++++++++
>  sysdeps/nptl/internaltypes.h                  |   3 +
>  sysdeps/nptl/pthread.h                        |  15 ++
>  sysdeps/unix/sysv/linux/aarch64/libc.abilist  |   2 +
>  sysdeps/unix/sysv/linux/alpha/libc.abilist    |   2 +
>  sysdeps/unix/sysv/linux/arm/be/libc.abilist   |   2 +
>  sysdeps/unix/sysv/linux/arm/le/libc.abilist   |   2 +
>  sysdeps/unix/sysv/linux/csky/libc.abilist     |   2 +
>  sysdeps/unix/sysv/linux/hppa/libc.abilist     |   2 +
>  sysdeps/unix/sysv/linux/i386/libc.abilist     |   2 +
>  sysdeps/unix/sysv/linux/ia64/libc.abilist     |   2 +
>  .../sysv/linux/m68k/coldfire/libc.abilist     |   2 +
>  .../unix/sysv/linux/m68k/m680x0/libc.abilist  |   2 +
>  .../sysv/linux/microblaze/be/libc.abilist     |   2 +
>  .../sysv/linux/microblaze/le/libc.abilist     |   2 +
>  .../sysv/linux/mips/mips32/fpu/libc.abilist   |   2 +
>  .../sysv/linux/mips/mips32/nofpu/libc.abilist |   2 +
>  .../sysv/linux/mips/mips64/n32/libc.abilist   |   2 +
>  .../sysv/linux/mips/mips64/n64/libc.abilist   |   2 +
>  sysdeps/unix/sysv/linux/nios2/libc.abilist    |   2 +
>  .../linux/powerpc/powerpc32/fpu/libc.abilist  |   2 +
>  .../powerpc/powerpc32/nofpu/libc.abilist      |   2 +
>  .../linux/powerpc/powerpc64/be/libc.abilist   |   2 +
>  .../linux/powerpc/powerpc64/le/libc.abilist   |   2 +
>  .../unix/sysv/linux/riscv/rv64/libc.abilist   |   2 +
>  .../unix/sysv/linux/s390/s390-32/libc.abilist |   2 +
>  .../unix/sysv/linux/s390/s390-64/libc.abilist |   2 +
>  sysdeps/unix/sysv/linux/sh/be/libc.abilist    |   2 +
>  sysdeps/unix/sysv/linux/sh/le/libc.abilist    |   2 +
>  .../sysv/linux/sparc/sparc32/libc.abilist     |   2 +
>  .../sysv/linux/sparc/sparc64/libc.abilist     |   2 +
>  .../unix/sysv/linux/x86_64/64/libc.abilist    |   2 +
>  .../unix/sysv/linux/x86_64/x32/libc.abilist   |   2 +
>  42 files changed, 442 insertions(+), 8 deletions(-)
>  create mode 100644 nptl/pthread_attr_getsigmask.c
>  create mode 100644 nptl/pthread_attr_setsigmask.c
>  create mode 100644 nptl/pthread_attr_setsigmask_internal.c
>  create mode 100644 nptl/tst-pthread-attr-sigmask.c
> 
> diff --git a/NEWS b/NEWS
> index 141078c319..2508feb249 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -23,6 +23,10 @@ Major new features:
>    toolchains.  It is recommended to use GCC 8 or newer when testing
>    this option.
>  
> +* On Linux, the pthread_attr_setsigmask_np and
> +  pthread_attr_getsigmask_np functions have been added.  They allow to
> +  specify the signal mask of a thread created with pthread_create.

Missing "applications" or "developers", either is fine.

e.g. s/They allow to/They allow applications to/g.

> +
>  Deprecated and removed features, and other changes affecting compatibility:
>  
>  * The deprecated <sys/sysctl.h> header and the sysctl function have been
> diff --git a/nptl/Makefile b/nptl/Makefile
> index d6f12d0371..cd0ed97181 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -47,6 +47,7 @@ routines = \
>    pthread_attr_getschedparam \
>    pthread_attr_getschedpolicy \
>    pthread_attr_getscope \
> +  pthread_attr_getsigmask \
>    pthread_attr_init \
>    pthread_attr_setaffinity \
>    pthread_attr_setdetachstate \
> @@ -54,6 +55,8 @@ routines = \
>    pthread_attr_setschedparam \
>    pthread_attr_setschedpolicy \
>    pthread_attr_setscope \
> +  pthread_attr_setsigmask \
> +  pthread_attr_setsigmask_internal \
>    pthread_cond_destroy \
>    pthread_cond_init \
>    pthread_condattr_destroy \
> @@ -330,6 +333,7 @@ tests = tst-attr2 tst-attr3 tst-default-attr \
>  	tst-thread-affinity-pthread2 \
>  	tst-thread-affinity-sched \
>  	tst-pthread-defaultattr-free \
> +	tst-pthread-attr-sigmask \

OK.

>  
>  
>  tests-container =  tst-pthread-getattr
> diff --git a/nptl/Versions b/nptl/Versions
> index e4696c128f..aed118e717 100644
> --- a/nptl/Versions
> +++ b/nptl/Versions
> @@ -44,7 +44,9 @@ libc {
>      thrd_current; thrd_equal; thrd_sleep; thrd_yield;
>    }
>    GLIBC_2.32 {
> +    pthread_attr_getsigmask_np;
>      pthread_attr_setaffinity_np;
> +    pthread_attr_setsigmask_np;
>      pthread_getaffinity_np;
>      pthread_getattr_np;
>      pthread_sigmask;
> @@ -62,6 +64,7 @@ libc {
>      __pthread_attr_init; __pthread_attr_destroy;
>      __pthread_attr_copy;
>      __pthread_getattr_default_np;
> +    __pthread_attr_setsigmask_internal;

OK.

>    }
>  }
>  
> diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
> index 7b3153594e..b48ce1f050 100644
> --- a/nptl/pthreadP.h
> +++ b/nptl/pthreadP.h
> @@ -528,6 +528,16 @@ extern int __pthread_getaffinity_np (pthread_t th, size_t cpusetsize,
>  				     cpu_set_t *cpuset);
>  libc_hidden_proto (__pthread_getaffinity_np)
>  
> +/* Special internal version of pthread_attr_setsigmask_np which does
> +   not filter out internal signals from *SIGMASK.  This can be used to
> +   launch threads with internal symbols blocked.  */

Typo: s/symbols/signals/g

> +  extern int __pthread_attr_setsigmask_internal (pthread_attr_t *attr,
> +						 const sigset_t *sigmask);
> +libc_hidden_proto (__pthread_attr_setsigmask_internal)
> +
> +extern __typeof (pthread_attr_getsigmask_np) __pthread_attr_getsigmask_np;
> +libc_hidden_proto (__pthread_attr_getsigmask_np)

OK.

> +
>  #if IS_IN (libpthread)
>  /* Special versions which use non-exported functions.  */
>  extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
> diff --git a/nptl/pthread_attr_copy.c b/nptl/pthread_attr_copy.c
> index eb29557505..5d0c62f65c 100644
> --- a/nptl/pthread_attr_copy.c
> +++ b/nptl/pthread_attr_copy.c
> @@ -42,6 +42,11 @@ __pthread_attr_copy (pthread_attr_t *target, const pthread_attr_t *source)
>          ret = __pthread_attr_setaffinity_np (&temp.external,
>                                               isource->extension->cpusetsize,
>                                               isource->extension->cpuset);
> +
> +      /* Propagate the signal mask information.  */
> +      if (ret == 0 && isource->extension->sigmask_set)
> +        ret = __pthread_attr_setsigmask_internal ((pthread_attr_t *) &temp,
> +                                                  &isource->extension->sigmask);

OK.

>      }
>  
>    if (ret != 0)
> diff --git a/nptl/pthread_attr_getsigmask.c b/nptl/pthread_attr_getsigmask.c
> new file mode 100644
> index 0000000000..99b9812ef8
> --- /dev/null
> +++ b/nptl/pthread_attr_getsigmask.c
> @@ -0,0 +1,38 @@
> +/* Obtain the configured signal mask from a POSIX thread attribute.
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <pthreadP.h>
> +
> +int
> +__pthread_attr_getsigmask_np (const pthread_attr_t *attr, sigset_t *sigmask)
> +{
> +  struct pthread_attr *iattr = (struct pthread_attr *) attr;
> +
> +  if (iattr->extension == NULL || !iattr->extension->sigmask_set)
> +    {
> +      __sigemptyset (sigmask);
> +      return PTHREAD_ATTR_NO_SIGMASK_NP;
> +    }
> +  else
> +    {
> +      *sigmask = iattr->extension->sigmask;
> +      return 0;
> +    }
> +}
> +libc_hidden_def (__pthread_attr_getsigmask_np)
> +weak_alias (__pthread_attr_getsigmask_np, pthread_attr_getsigmask_np)

OK.

> diff --git a/nptl/pthread_attr_setsigmask.c b/nptl/pthread_attr_setsigmask.c
> new file mode 100644
> index 0000000000..4574f51056
> --- /dev/null
> +++ b/nptl/pthread_attr_setsigmask.c
> @@ -0,0 +1,34 @@
> +/* Set the signal mask in a POSIX thread attribute.  Public variant.
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <pthreadP.h>
> +#include <internal-signals.h>
> +
> +int
> +pthread_attr_setsigmask_np (pthread_attr_t *attr, const sigset_t *sigmask)
> +{
> +  int ret = __pthread_attr_setsigmask_internal (attr, sigmask);
> +  if (ret != 0)
> +    return ret;
> +
> +  /* Filter out internal signals.  */
> +  struct pthread_attr *iattr = (struct pthread_attr *) attr;
> +  __clear_internal_signals (&iattr->extension->sigmask);

OK.

> +
> +  return 0;
> +}
> diff --git a/nptl/pthread_attr_setsigmask_internal.c b/nptl/pthread_attr_setsigmask_internal.c
> new file mode 100644
> index 0000000000..a2941b4ee9
> --- /dev/null
> +++ b/nptl/pthread_attr_setsigmask_internal.c
> @@ -0,0 +1,45 @@
> +/* Set the signal mask in a POSIX thread attribute.  Internal variant.
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <pthreadP.h>
> +#include <internal-signals.h>
> +
> +int
> +__pthread_attr_setsigmask_internal (pthread_attr_t *attr,
> +                                    const sigset_t *sigmask)
> +{
> +  struct pthread_attr *iattr = (struct pthread_attr *) attr;
> +
> +  if (sigmask == NULL)
> +    {
> +      /* Mark the signal mask as unset if it is present.  */
> +      if (iattr->extension != NULL)
> +        iattr->extension->sigmask_set = false;
> +      return 0;

OK.

> +    }
> +
> +  int ret = __pthread_attr_extension (iattr);
> +  if (ret != 0)
> +    return ret;
> +
> +  iattr->extension->sigmask = *sigmask;
> +  iattr->extension->sigmask_set = true;
> +
> +  return 0;

OK.

> +}
> +libc_hidden_def (__pthread_attr_setsigmask_internal)
> diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
> index f6418eb5ed..35a9927cf2 100644
> --- a/nptl/pthread_create.c
> +++ b/nptl/pthread_create.c
> @@ -745,14 +745,23 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
>    sigset_t original_sigmask;
>    __libc_signal_block_all (&original_sigmask);
>  
> -  /* Conceptually, the new thread needs to inherit the signal mask of
> -     this thread.  Therefore, it needs to restore the saved signal
> -     mask of this thread, so save it in the startup information.  */
> -  pd->sigmask = original_sigmask;
> -
> -  /* Reset the cancellation signal mask in case this thread is running
> -     cancellation.  */
> -  __sigdelset (&pd->sigmask, SIGCANCEL);
> +  if (iattr->extension != NULL && iattr->extension->sigmask_set)
> +    /* Use the signal mask in the attribute.  The internal signals
> +       have already been filtered by the public
> +       pthread_attr_setsigmask_np interface.  */
> +    pd->sigmask = iattr->extension->sigmask;

OK. Very clean.

> +  else
> +    {
> +      /* Conceptually, the new thread needs to inherit the signal mask
> +	 of this thread.  Therefore, it needs to restore the saved
> +	 signal mask of this thread, so save it in the startup
> +	 information.  */
> +      pd->sigmask = original_sigmask;
> +
> +      /* Reset the cancellation signal mask in case this thread is
> +	 running cancellation.  */
> +      __sigdelset (&pd->sigmask, SIGCANCEL);

OK.

> +    }
>  
>    /* Start the thread.  */
>    if (__glibc_unlikely (report_thread_creation (pd)))
> diff --git a/nptl/tst-pthread-attr-sigmask.c b/nptl/tst-pthread-attr-sigmask.c
> new file mode 100644
> index 0000000000..8f854d8d11
> --- /dev/null
> +++ b/nptl/tst-pthread-attr-sigmask.c
> @@ -0,0 +1,204 @@
> +/* Tests for pthread_attr_setsigmask_np, pthread_attr_getsigmask_np.
> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +/* This thread uses different masked status for SIGUSR1, SIGUSR2,
> +   SIGHUP to determine if signal masks are applied to new threads as
> +   expected.  */
> +
> +#include <signal.h>
> +#include <stdbool.h>
> +#include <stddef.h>
> +#include <stdio.h>
> +#include <support/check.h>
> +#include <support/xsignal.h>
> +#include <support/xthread.h>
> +#include <threads.h>
> +
> +typedef bool signals[_NSIG];
> +
> +static const char *
> +masked_or_unmasked (bool masked)
> +{
> +  if (masked)
> +    return "masked";
> +  else
> +    return "unmasked";
> +}
> +
> +/* Report an error if ACTUAL_MASK does not match EXPECTED_MASK.
> +   CONTEXT is used in error messages.  */
> +static void
> +check_sigmask (const char *context, signals expected_mask,
> +               const sigset_t *actual_mask)
> +{
> +  for (int sig = 1; sig < _NSIG; ++sig)
> +    if (sigismember (actual_mask, sig) != expected_mask[sig])
> +      {
> +        support_record_failure ();
> +        printf ("error: %s: signal %d should be %s, but is %s\n",
> +                context, sig,
> +                masked_or_unmasked (sigismember (actual_mask, sig)),
> +                masked_or_unmasked (expected_mask[sig]));
> +      }
> +}
> +
> +/* Report an error if the current thread signal mask does not match
> +   EXPECTED_MASK.  CONTEXT is used in error messages.  */
> +static void
> +check_current_sigmask (const char *context, signals expected_mask)
> +{
> +  sigset_t actual_mask;
> +  xpthread_sigmask (SIG_SETMASK, NULL, &actual_mask);
> +  check_sigmask (context, expected_mask, &actual_mask);
> +}
> +
> +/* Thread start routine which checks the current thread signal mask
> +   against CLOSURE.  */
> +static void *
> +check_sigmask_thread_function (void *closure)
> +{
> +  check_current_sigmask ("on thread", closure);
> +  return NULL;
> +}
> +
> +/* Same for C11 threads.  */
> +static int
> +check_sigmask_thread_function_c11 (void *closure)
> +{
> +  check_current_sigmask ("on C11 thread", closure);
> +  return 0;
> +}
> +
> +/* Launch a POSIX thread with ATTR (which can be NULL) and check that
> +   it has the expected signal mask.  */
> +static void
> +check_posix_thread (pthread_attr_t *attr, signals expected_mask)
> +{
> +  xpthread_join (xpthread_create (attr, check_sigmask_thread_function,
> +                                  expected_mask));
> +}
> +
> +/* Launch a C11 thread and check that it has the expected signal
> +   mask.  */
> +static void
> +check_c11_thread (signals expected_mask)
> +{
> +  thrd_t thr;
> +  TEST_VERIFY_EXIT (thrd_create (&thr, check_sigmask_thread_function_c11,
> +                                 expected_mask) == thrd_success);
> +  TEST_VERIFY_EXIT (thrd_join (thr, NULL) == thrd_success);
> +}
> +
> +static int
> +do_test (void)
> +{
> +  check_current_sigmask ("initial mask", (signals) { false, });
> +  check_posix_thread (NULL, (signals) { false, });
> +  check_c11_thread ((signals) { false, });

OK. Defaults.

> +
> +  sigset_t set;
> +  sigemptyset (&set);
> +  sigaddset (&set, SIGUSR1);
> +  xpthread_sigmask (SIG_SETMASK, &set, NULL);
> +  check_current_sigmask ("SIGUSR1 masked", (signals) { [SIGUSR1] = true, });
> +  /* The signal mask is inherited by the new thread.  */
> +  check_posix_thread (NULL, (signals) { [SIGUSR1] = true, });
> +  check_c11_thread ((signals) { [SIGUSR1] = true, });

OK. Inherited.

> +
> +  pthread_attr_t attr;
> +  xpthread_attr_init (&attr);
> +  TEST_COMPARE (pthread_attr_getsigmask_np (&attr, &set),
> +                PTHREAD_ATTR_NO_SIGMASK_NP);
> +  /* By default, the signal mask is inherited (even with an explicit
> +     thread attribute).  */
> +  check_posix_thread (&attr, (signals) { [SIGUSR1] = true, });
> +
> +  /* Check that pthread_attr_getsigmask_np can obtain the signal
> +     mask.  */
> +  sigemptyset (&set);
> +  sigaddset (&set, SIGUSR2);
> +  TEST_COMPARE (pthread_attr_setsigmask_np (&attr, &set), 0);
> +  sigemptyset (&set);
> +  TEST_COMPARE (pthread_attr_getsigmask_np (&attr, &set), 0);
> +  check_sigmask ("pthread_attr_getsigmask_np", (signals) { [SIGUSR2] = true, },
> +                 &set);

OK. Inherited with an explicit thread attribute.

> +
> +  /* Check that a thread is launched with the configured signal
> +     mask.  */
> +  check_current_sigmask ("SIGUSR1 masked", (signals) { [SIGUSR1] = true, });
> +  check_posix_thread (&attr, (signals) { [SIGUSR2] = true, });
> +  check_current_sigmask ("SIGUSR1 masked", (signals) { [SIGUSR1] = true, });
> +
> +  /* But C11 threads remain at inheritance.  */
> +  check_c11_thread ((signals) { [SIGUSR1] = true, });
> +
> +  /* Check that filling the original signal set does not affect thread
> +     creation.  */
> +  sigfillset (&set);
> +  check_posix_thread (&attr, (signals) { [SIGUSR2] = true, });
> +
> +  /* Check that clearing the signal in the attribute restores
> +     inheritance.  */
> +  TEST_COMPARE (pthread_attr_setsigmask_np (&attr, NULL), 0);
> +  TEST_COMPARE (pthread_attr_getsigmask_np (&attr, &set),
> +                PTHREAD_ATTR_NO_SIGMASK_NP);
> +  check_posix_thread (&attr, (signals) { [SIGUSR1] = true, });
> +
> +  /* Mask SIGHUP via the default thread attribute.  */
> +  sigemptyset (&set);
> +  sigaddset (&set, SIGHUP);
> +  TEST_COMPARE (pthread_attr_setsigmask_np (&attr, &set), 0);
> +  TEST_COMPARE (pthread_setattr_default_np (&attr), 0);
> +
> +  /* Check that the mask was applied to the default attribute.  */
> +  xpthread_attr_destroy (&attr);
> +  TEST_COMPARE (pthread_getattr_default_np (&attr), 0);
> +  sigaddset (&set, SIGHUP);
> +  TEST_COMPARE (pthread_attr_getsigmask_np (&attr, &set), 0);
> +  check_sigmask ("default attribute", (signals) { [SIGHUP] = true, }, &set);
> +  xpthread_attr_destroy (&attr);
> +
> +  /* Check that the default attribute is applied.  */
> +  check_posix_thread (NULL, (signals) { [SIGHUP] = true, });
> +  check_c11_thread ((signals) { [SIGHUP] = true, });
> +
> +  /* An explicit attribute with no signal mask triggers inheritance
> +     even if the default has been changed.  */
> +  xpthread_attr_init (&attr);
> +  check_posix_thread (&attr, (signals) { [SIGUSR1] = true, });
> +
> +  /* Explicitly setting the signal mask affects the new thread even
> +     with a default attribute.  */
> +  sigemptyset (&set);
> +  sigaddset (&set, SIGUSR2);
> +  TEST_COMPARE (pthread_attr_setsigmask_np (&attr, &set), 0);
> +  check_posix_thread (&attr, (signals) { [SIGUSR2] = true, });
> +
> +  /* Resetting the default attribute brings back the old inheritance
> +     behavior.  */
> +  xpthread_attr_destroy (&attr);
> +  xpthread_attr_init (&attr);
> +  TEST_COMPARE (pthread_setattr_default_np (&attr), 0);
> +  xpthread_attr_destroy (&attr);
> +  check_posix_thread (NULL, (signals) { [SIGUSR1] = true, });
> +  check_c11_thread ((signals) { [SIGUSR1] = true, });

OK.

> +
> +  return 0;
> +}
> +
> +#include <support/test-driver.c>
> diff --git a/sysdeps/nptl/internaltypes.h b/sysdeps/nptl/internaltypes.h
> index ca57c315d4..65584cbb7e 100644
> --- a/sysdeps/nptl/internaltypes.h
> +++ b/sysdeps/nptl/internaltypes.h
> @@ -65,6 +65,9 @@ struct pthread_attr_extension
>    /* Affinity map.  */
>    cpu_set_t *cpuset;
>    size_t cpusetsize;
> +
> +  sigset_t sigmask;
> +  bool sigmask_set;

OK. Add to extension.

>  };
>  
>  /* Mutex attribute data structure.  */
> diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
> index 44dd707896..8a403cbf36 100644
> --- a/sysdeps/nptl/pthread.h
> +++ b/sysdeps/nptl/pthread.h
> @@ -27,6 +27,7 @@
>  #include <bits/setjmp.h>
>  #include <bits/wordsize.h>
>  #include <bits/types/struct_timespec.h>
> +#include <bits/types/__sigset_t.h>
>  
>  
>  /* Detach state.  */
> @@ -385,6 +386,20 @@ extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr,
>  extern int pthread_getattr_default_np (pthread_attr_t *__attr)
>       __THROW __nonnull ((1));
>  
> +/* Store *SIGMASK as the signal mask for the new thread in *ATTR.  */
> +extern int pthread_attr_setsigmask_np (pthread_attr_t *__attr,
> +				       const __sigset_t *sigmask);
> +
> +/* Store the signal mask of *ATTR in *SIGMASK.  If there is no signal
> +   mask stored, return PTHREAD_ATTR_NOSIGMASK_NP.  Return zero on
> +   success.  */
> +extern int pthread_attr_getsigmask_np (const pthread_attr_t *__attr,
> +				       __sigset_t *sigmask);
> +
> +/* Special return value from pthread_attr_getsigmask_np if the signal
> +   mask has not been set.  */
> +#define PTHREAD_ATTR_NO_SIGMASK_NP (-1)

OK.

> +
>  /* Set the default attributes to be used by pthread_create in this
>     process.  */
>  extern int pthread_setattr_default_np (const pthread_attr_t *__attr)
> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> index 6dc59b38b0..48c790b15d 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> @@ -2149,7 +2149,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> index fd628bcd28..cb70cb974f 100644
> --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> @@ -2231,7 +2231,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> index d0b1cd24c9..573eca117e 100644
> --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> @@ -133,7 +133,9 @@ GLIBC_2.30 twalk_r F
>  GLIBC_2.31 msgctl F
>  GLIBC_2.31 semctl F
>  GLIBC_2.31 shmctl F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> index 3dde0ef8bd..8a8633f0a4 100644
> --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> @@ -130,7 +130,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
> index 4db9bbd971..3042a93084 100644
> --- a/sysdeps/unix/sysv/linux/csky/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
> @@ -2093,7 +2093,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> index 52aa86b191..a02a576321 100644
> --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> @@ -2052,7 +2052,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
> index 48ee395a64..f0b9c9e070 100644
> --- a/sysdeps/unix/sysv/linux/i386/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
> @@ -2218,7 +2218,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
> index 34458f348f..1534fd7a24 100644
> --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
> @@ -2084,7 +2084,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> index 377326b12c..9a0ada4b52 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> @@ -134,7 +134,9 @@ GLIBC_2.30 twalk_r F
>  GLIBC_2.31 msgctl F
>  GLIBC_2.31 semctl F
>  GLIBC_2.31 shmctl F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> index 81eea10680..333c35bf16 100644
> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> @@ -2164,7 +2164,9 @@ GLIBC_2.30 twalk_r F
>  GLIBC_2.31 msgctl F
>  GLIBC_2.31 semctl F
>  GLIBC_2.31 shmctl F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> index ff75663747..824eceec11 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> @@ -2144,7 +2144,9 @@ GLIBC_2.30 twalk_r F
>  GLIBC_2.31 msgctl F
>  GLIBC_2.31 semctl F
>  GLIBC_2.31 shmctl F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> index e9a6375dfc..5a6dcdd21b 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> @@ -2141,7 +2141,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> index 598fc488c7..6e5dbb28f1 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> @@ -2135,7 +2135,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> index 77e8d6b155..3ee64614b2 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> @@ -2133,7 +2133,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> index a3aad2487f..dc62615524 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> @@ -2141,7 +2141,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> index c074f612f5..8cf78bcf51 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> @@ -2135,7 +2135,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> index d1c638acb9..7817aeb0e2 100644
> --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> @@ -2182,7 +2182,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> index bfc8185b0e..ca04e8f2d3 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> @@ -2191,7 +2191,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> index 9a889f1bc6..10cb895639 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> @@ -2224,7 +2224,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> index b69f4b126f..96ddc448d7 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> @@ -2054,7 +2054,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> index a07753847d..deddb53d83 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> @@ -2344,7 +2344,9 @@ GLIBC_2.32 __wcstoieee128_l F
>  GLIBC_2.32 __wprintf_chkieee128 F
>  GLIBC_2.32 __wprintfieee128 F
>  GLIBC_2.32 __wscanfieee128 F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> index 6d5a52dc1a..58217dcb13 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> @@ -2111,7 +2111,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> index ae3849d3f6..c22c29b35a 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> @@ -2189,7 +2189,9 @@ GLIBC_2.30 twalk_r F
>  GLIBC_2.31 msgctl F
>  GLIBC_2.31 semctl F
>  GLIBC_2.31 shmctl F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> index 2eb931c02c..568f1727c4 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> @@ -2090,7 +2090,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> index ce4f366fbb..d9988dae90 100644
> --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> @@ -2059,7 +2059,9 @@ GLIBC_2.30 twalk_r F
>  GLIBC_2.31 msgctl F
>  GLIBC_2.31 semctl F
>  GLIBC_2.31 shmctl F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> index f37a08ab09..39edeffe82 100644
> --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> @@ -2056,7 +2056,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> index af3a5e2618..8668e15e8c 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> @@ -2180,7 +2180,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> index 1fccc06f21..eb884afa3e 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> @@ -2107,7 +2107,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> index 03af18babb..a208fb3556 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> @@ -2065,7 +2065,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> index 2da0af70d4..3eca3493e2 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> @@ -2162,7 +2162,9 @@ GLIBC_2.30 getdents64 F
>  GLIBC_2.30 gettid F
>  GLIBC_2.30 tgkill F
>  GLIBC_2.30 twalk_r F
> +GLIBC_2.32 pthread_attr_getsigmask_np F
>  GLIBC_2.32 pthread_attr_setaffinity_np F
> +GLIBC_2.32 pthread_attr_setsigmask_np F
>  GLIBC_2.32 pthread_getaffinity_np F
>  GLIBC_2.32 pthread_getattr_np F
>  GLIBC_2.32 pthread_sigmask F
> 

OK. Update ABI.
diff mbox series

Patch

diff --git a/NEWS b/NEWS
index 141078c319..2508feb249 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,10 @@  Major new features:
   toolchains.  It is recommended to use GCC 8 or newer when testing
   this option.
 
+* On Linux, the pthread_attr_setsigmask_np and
+  pthread_attr_getsigmask_np functions have been added.  They allow to
+  specify the signal mask of a thread created with pthread_create.
+
 Deprecated and removed features, and other changes affecting compatibility:
 
 * The deprecated <sys/sysctl.h> header and the sysctl function have been
diff --git a/nptl/Makefile b/nptl/Makefile
index d6f12d0371..cd0ed97181 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -47,6 +47,7 @@  routines = \
   pthread_attr_getschedparam \
   pthread_attr_getschedpolicy \
   pthread_attr_getscope \
+  pthread_attr_getsigmask \
   pthread_attr_init \
   pthread_attr_setaffinity \
   pthread_attr_setdetachstate \
@@ -54,6 +55,8 @@  routines = \
   pthread_attr_setschedparam \
   pthread_attr_setschedpolicy \
   pthread_attr_setscope \
+  pthread_attr_setsigmask \
+  pthread_attr_setsigmask_internal \
   pthread_cond_destroy \
   pthread_cond_init \
   pthread_condattr_destroy \
@@ -330,6 +333,7 @@  tests = tst-attr2 tst-attr3 tst-default-attr \
 	tst-thread-affinity-pthread2 \
 	tst-thread-affinity-sched \
 	tst-pthread-defaultattr-free \
+	tst-pthread-attr-sigmask \
 
 
 tests-container =  tst-pthread-getattr
diff --git a/nptl/Versions b/nptl/Versions
index e4696c128f..aed118e717 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -44,7 +44,9 @@  libc {
     thrd_current; thrd_equal; thrd_sleep; thrd_yield;
   }
   GLIBC_2.32 {
+    pthread_attr_getsigmask_np;
     pthread_attr_setaffinity_np;
+    pthread_attr_setsigmask_np;
     pthread_getaffinity_np;
     pthread_getattr_np;
     pthread_sigmask;
@@ -62,6 +64,7 @@  libc {
     __pthread_attr_init; __pthread_attr_destroy;
     __pthread_attr_copy;
     __pthread_getattr_default_np;
+    __pthread_attr_setsigmask_internal;
   }
 }
 
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 7b3153594e..b48ce1f050 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -528,6 +528,16 @@  extern int __pthread_getaffinity_np (pthread_t th, size_t cpusetsize,
 				     cpu_set_t *cpuset);
 libc_hidden_proto (__pthread_getaffinity_np)
 
+/* Special internal version of pthread_attr_setsigmask_np which does
+   not filter out internal signals from *SIGMASK.  This can be used to
+   launch threads with internal symbols blocked.  */
+  extern int __pthread_attr_setsigmask_internal (pthread_attr_t *attr,
+						 const sigset_t *sigmask);
+libc_hidden_proto (__pthread_attr_setsigmask_internal)
+
+extern __typeof (pthread_attr_getsigmask_np) __pthread_attr_getsigmask_np;
+libc_hidden_proto (__pthread_attr_getsigmask_np)
+
 #if IS_IN (libpthread)
 /* Special versions which use non-exported functions.  */
 extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
diff --git a/nptl/pthread_attr_copy.c b/nptl/pthread_attr_copy.c
index eb29557505..5d0c62f65c 100644
--- a/nptl/pthread_attr_copy.c
+++ b/nptl/pthread_attr_copy.c
@@ -42,6 +42,11 @@  __pthread_attr_copy (pthread_attr_t *target, const pthread_attr_t *source)
         ret = __pthread_attr_setaffinity_np (&temp.external,
                                              isource->extension->cpusetsize,
                                              isource->extension->cpuset);
+
+      /* Propagate the signal mask information.  */
+      if (ret == 0 && isource->extension->sigmask_set)
+        ret = __pthread_attr_setsigmask_internal ((pthread_attr_t *) &temp,
+                                                  &isource->extension->sigmask);
     }
 
   if (ret != 0)
diff --git a/nptl/pthread_attr_getsigmask.c b/nptl/pthread_attr_getsigmask.c
new file mode 100644
index 0000000000..99b9812ef8
--- /dev/null
+++ b/nptl/pthread_attr_getsigmask.c
@@ -0,0 +1,38 @@ 
+/* Obtain the configured signal mask from a POSIX thread attribute.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <pthreadP.h>
+
+int
+__pthread_attr_getsigmask_np (const pthread_attr_t *attr, sigset_t *sigmask)
+{
+  struct pthread_attr *iattr = (struct pthread_attr *) attr;
+
+  if (iattr->extension == NULL || !iattr->extension->sigmask_set)
+    {
+      __sigemptyset (sigmask);
+      return PTHREAD_ATTR_NO_SIGMASK_NP;
+    }
+  else
+    {
+      *sigmask = iattr->extension->sigmask;
+      return 0;
+    }
+}
+libc_hidden_def (__pthread_attr_getsigmask_np)
+weak_alias (__pthread_attr_getsigmask_np, pthread_attr_getsigmask_np)
diff --git a/nptl/pthread_attr_setsigmask.c b/nptl/pthread_attr_setsigmask.c
new file mode 100644
index 0000000000..4574f51056
--- /dev/null
+++ b/nptl/pthread_attr_setsigmask.c
@@ -0,0 +1,34 @@ 
+/* Set the signal mask in a POSIX thread attribute.  Public variant.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <pthreadP.h>
+#include <internal-signals.h>
+
+int
+pthread_attr_setsigmask_np (pthread_attr_t *attr, const sigset_t *sigmask)
+{
+  int ret = __pthread_attr_setsigmask_internal (attr, sigmask);
+  if (ret != 0)
+    return ret;
+
+  /* Filter out internal signals.  */
+  struct pthread_attr *iattr = (struct pthread_attr *) attr;
+  __clear_internal_signals (&iattr->extension->sigmask);
+
+  return 0;
+}
diff --git a/nptl/pthread_attr_setsigmask_internal.c b/nptl/pthread_attr_setsigmask_internal.c
new file mode 100644
index 0000000000..a2941b4ee9
--- /dev/null
+++ b/nptl/pthread_attr_setsigmask_internal.c
@@ -0,0 +1,45 @@ 
+/* Set the signal mask in a POSIX thread attribute.  Internal variant.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <pthreadP.h>
+#include <internal-signals.h>
+
+int
+__pthread_attr_setsigmask_internal (pthread_attr_t *attr,
+                                    const sigset_t *sigmask)
+{
+  struct pthread_attr *iattr = (struct pthread_attr *) attr;
+
+  if (sigmask == NULL)
+    {
+      /* Mark the signal mask as unset if it is present.  */
+      if (iattr->extension != NULL)
+        iattr->extension->sigmask_set = false;
+      return 0;
+    }
+
+  int ret = __pthread_attr_extension (iattr);
+  if (ret != 0)
+    return ret;
+
+  iattr->extension->sigmask = *sigmask;
+  iattr->extension->sigmask_set = true;
+
+  return 0;
+}
+libc_hidden_def (__pthread_attr_setsigmask_internal)
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index f6418eb5ed..35a9927cf2 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -745,14 +745,23 @@  __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
   sigset_t original_sigmask;
   __libc_signal_block_all (&original_sigmask);
 
-  /* Conceptually, the new thread needs to inherit the signal mask of
-     this thread.  Therefore, it needs to restore the saved signal
-     mask of this thread, so save it in the startup information.  */
-  pd->sigmask = original_sigmask;
-
-  /* Reset the cancellation signal mask in case this thread is running
-     cancellation.  */
-  __sigdelset (&pd->sigmask, SIGCANCEL);
+  if (iattr->extension != NULL && iattr->extension->sigmask_set)
+    /* Use the signal mask in the attribute.  The internal signals
+       have already been filtered by the public
+       pthread_attr_setsigmask_np interface.  */
+    pd->sigmask = iattr->extension->sigmask;
+  else
+    {
+      /* Conceptually, the new thread needs to inherit the signal mask
+	 of this thread.  Therefore, it needs to restore the saved
+	 signal mask of this thread, so save it in the startup
+	 information.  */
+      pd->sigmask = original_sigmask;
+
+      /* Reset the cancellation signal mask in case this thread is
+	 running cancellation.  */
+      __sigdelset (&pd->sigmask, SIGCANCEL);
+    }
 
   /* Start the thread.  */
   if (__glibc_unlikely (report_thread_creation (pd)))
diff --git a/nptl/tst-pthread-attr-sigmask.c b/nptl/tst-pthread-attr-sigmask.c
new file mode 100644
index 0000000000..8f854d8d11
--- /dev/null
+++ b/nptl/tst-pthread-attr-sigmask.c
@@ -0,0 +1,204 @@ 
+/* Tests for pthread_attr_setsigmask_np, pthread_attr_getsigmask_np.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* This thread uses different masked status for SIGUSR1, SIGUSR2,
+   SIGHUP to determine if signal masks are applied to new threads as
+   expected.  */
+
+#include <signal.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <support/check.h>
+#include <support/xsignal.h>
+#include <support/xthread.h>
+#include <threads.h>
+
+typedef bool signals[_NSIG];
+
+static const char *
+masked_or_unmasked (bool masked)
+{
+  if (masked)
+    return "masked";
+  else
+    return "unmasked";
+}
+
+/* Report an error if ACTUAL_MASK does not match EXPECTED_MASK.
+   CONTEXT is used in error messages.  */
+static void
+check_sigmask (const char *context, signals expected_mask,
+               const sigset_t *actual_mask)
+{
+  for (int sig = 1; sig < _NSIG; ++sig)
+    if (sigismember (actual_mask, sig) != expected_mask[sig])
+      {
+        support_record_failure ();
+        printf ("error: %s: signal %d should be %s, but is %s\n",
+                context, sig,
+                masked_or_unmasked (sigismember (actual_mask, sig)),
+                masked_or_unmasked (expected_mask[sig]));
+      }
+}
+
+/* Report an error if the current thread signal mask does not match
+   EXPECTED_MASK.  CONTEXT is used in error messages.  */
+static void
+check_current_sigmask (const char *context, signals expected_mask)
+{
+  sigset_t actual_mask;
+  xpthread_sigmask (SIG_SETMASK, NULL, &actual_mask);
+  check_sigmask (context, expected_mask, &actual_mask);
+}
+
+/* Thread start routine which checks the current thread signal mask
+   against CLOSURE.  */
+static void *
+check_sigmask_thread_function (void *closure)
+{
+  check_current_sigmask ("on thread", closure);
+  return NULL;
+}
+
+/* Same for C11 threads.  */
+static int
+check_sigmask_thread_function_c11 (void *closure)
+{
+  check_current_sigmask ("on C11 thread", closure);
+  return 0;
+}
+
+/* Launch a POSIX thread with ATTR (which can be NULL) and check that
+   it has the expected signal mask.  */
+static void
+check_posix_thread (pthread_attr_t *attr, signals expected_mask)
+{
+  xpthread_join (xpthread_create (attr, check_sigmask_thread_function,
+                                  expected_mask));
+}
+
+/* Launch a C11 thread and check that it has the expected signal
+   mask.  */
+static void
+check_c11_thread (signals expected_mask)
+{
+  thrd_t thr;
+  TEST_VERIFY_EXIT (thrd_create (&thr, check_sigmask_thread_function_c11,
+                                 expected_mask) == thrd_success);
+  TEST_VERIFY_EXIT (thrd_join (thr, NULL) == thrd_success);
+}
+
+static int
+do_test (void)
+{
+  check_current_sigmask ("initial mask", (signals) { false, });
+  check_posix_thread (NULL, (signals) { false, });
+  check_c11_thread ((signals) { false, });
+
+  sigset_t set;
+  sigemptyset (&set);
+  sigaddset (&set, SIGUSR1);
+  xpthread_sigmask (SIG_SETMASK, &set, NULL);
+  check_current_sigmask ("SIGUSR1 masked", (signals) { [SIGUSR1] = true, });
+  /* The signal mask is inherited by the new thread.  */
+  check_posix_thread (NULL, (signals) { [SIGUSR1] = true, });
+  check_c11_thread ((signals) { [SIGUSR1] = true, });
+
+  pthread_attr_t attr;
+  xpthread_attr_init (&attr);
+  TEST_COMPARE (pthread_attr_getsigmask_np (&attr, &set),
+                PTHREAD_ATTR_NO_SIGMASK_NP);
+  /* By default, the signal mask is inherited (even with an explicit
+     thread attribute).  */
+  check_posix_thread (&attr, (signals) { [SIGUSR1] = true, });
+
+  /* Check that pthread_attr_getsigmask_np can obtain the signal
+     mask.  */
+  sigemptyset (&set);
+  sigaddset (&set, SIGUSR2);
+  TEST_COMPARE (pthread_attr_setsigmask_np (&attr, &set), 0);
+  sigemptyset (&set);
+  TEST_COMPARE (pthread_attr_getsigmask_np (&attr, &set), 0);
+  check_sigmask ("pthread_attr_getsigmask_np", (signals) { [SIGUSR2] = true, },
+                 &set);
+
+  /* Check that a thread is launched with the configured signal
+     mask.  */
+  check_current_sigmask ("SIGUSR1 masked", (signals) { [SIGUSR1] = true, });
+  check_posix_thread (&attr, (signals) { [SIGUSR2] = true, });
+  check_current_sigmask ("SIGUSR1 masked", (signals) { [SIGUSR1] = true, });
+
+  /* But C11 threads remain at inheritance.  */
+  check_c11_thread ((signals) { [SIGUSR1] = true, });
+
+  /* Check that filling the original signal set does not affect thread
+     creation.  */
+  sigfillset (&set);
+  check_posix_thread (&attr, (signals) { [SIGUSR2] = true, });
+
+  /* Check that clearing the signal in the attribute restores
+     inheritance.  */
+  TEST_COMPARE (pthread_attr_setsigmask_np (&attr, NULL), 0);
+  TEST_COMPARE (pthread_attr_getsigmask_np (&attr, &set),
+                PTHREAD_ATTR_NO_SIGMASK_NP);
+  check_posix_thread (&attr, (signals) { [SIGUSR1] = true, });
+
+  /* Mask SIGHUP via the default thread attribute.  */
+  sigemptyset (&set);
+  sigaddset (&set, SIGHUP);
+  TEST_COMPARE (pthread_attr_setsigmask_np (&attr, &set), 0);
+  TEST_COMPARE (pthread_setattr_default_np (&attr), 0);
+
+  /* Check that the mask was applied to the default attribute.  */
+  xpthread_attr_destroy (&attr);
+  TEST_COMPARE (pthread_getattr_default_np (&attr), 0);
+  sigaddset (&set, SIGHUP);
+  TEST_COMPARE (pthread_attr_getsigmask_np (&attr, &set), 0);
+  check_sigmask ("default attribute", (signals) { [SIGHUP] = true, }, &set);
+  xpthread_attr_destroy (&attr);
+
+  /* Check that the default attribute is applied.  */
+  check_posix_thread (NULL, (signals) { [SIGHUP] = true, });
+  check_c11_thread ((signals) { [SIGHUP] = true, });
+
+  /* An explicit attribute with no signal mask triggers inheritance
+     even if the default has been changed.  */
+  xpthread_attr_init (&attr);
+  check_posix_thread (&attr, (signals) { [SIGUSR1] = true, });
+
+  /* Explicitly setting the signal mask affects the new thread even
+     with a default attribute.  */
+  sigemptyset (&set);
+  sigaddset (&set, SIGUSR2);
+  TEST_COMPARE (pthread_attr_setsigmask_np (&attr, &set), 0);
+  check_posix_thread (&attr, (signals) { [SIGUSR2] = true, });
+
+  /* Resetting the default attribute brings back the old inheritance
+     behavior.  */
+  xpthread_attr_destroy (&attr);
+  xpthread_attr_init (&attr);
+  TEST_COMPARE (pthread_setattr_default_np (&attr), 0);
+  xpthread_attr_destroy (&attr);
+  check_posix_thread (NULL, (signals) { [SIGUSR1] = true, });
+  check_c11_thread ((signals) { [SIGUSR1] = true, });
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/nptl/internaltypes.h b/sysdeps/nptl/internaltypes.h
index ca57c315d4..65584cbb7e 100644
--- a/sysdeps/nptl/internaltypes.h
+++ b/sysdeps/nptl/internaltypes.h
@@ -65,6 +65,9 @@  struct pthread_attr_extension
   /* Affinity map.  */
   cpu_set_t *cpuset;
   size_t cpusetsize;
+
+  sigset_t sigmask;
+  bool sigmask_set;
 };
 
 /* Mutex attribute data structure.  */
diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
index 44dd707896..8a403cbf36 100644
--- a/sysdeps/nptl/pthread.h
+++ b/sysdeps/nptl/pthread.h
@@ -27,6 +27,7 @@ 
 #include <bits/setjmp.h>
 #include <bits/wordsize.h>
 #include <bits/types/struct_timespec.h>
+#include <bits/types/__sigset_t.h>
 
 
 /* Detach state.  */
@@ -385,6 +386,20 @@  extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr,
 extern int pthread_getattr_default_np (pthread_attr_t *__attr)
      __THROW __nonnull ((1));
 
+/* Store *SIGMASK as the signal mask for the new thread in *ATTR.  */
+extern int pthread_attr_setsigmask_np (pthread_attr_t *__attr,
+				       const __sigset_t *sigmask);
+
+/* Store the signal mask of *ATTR in *SIGMASK.  If there is no signal
+   mask stored, return PTHREAD_ATTR_NOSIGMASK_NP.  Return zero on
+   success.  */
+extern int pthread_attr_getsigmask_np (const pthread_attr_t *__attr,
+				       __sigset_t *sigmask);
+
+/* Special return value from pthread_attr_getsigmask_np if the signal
+   mask has not been set.  */
+#define PTHREAD_ATTR_NO_SIGMASK_NP (-1)
+
 /* Set the default attributes to be used by pthread_create in this
    process.  */
 extern int pthread_setattr_default_np (const pthread_attr_t *__attr)
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 6dc59b38b0..48c790b15d 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2149,7 +2149,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index fd628bcd28..cb70cb974f 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2231,7 +2231,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index d0b1cd24c9..573eca117e 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -133,7 +133,9 @@  GLIBC_2.30 twalk_r F
 GLIBC_2.31 msgctl F
 GLIBC_2.31 semctl F
 GLIBC_2.31 shmctl F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index 3dde0ef8bd..8a8633f0a4 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -130,7 +130,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 4db9bbd971..3042a93084 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2093,7 +2093,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index 52aa86b191..a02a576321 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2052,7 +2052,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index 48ee395a64..f0b9c9e070 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2218,7 +2218,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index 34458f348f..1534fd7a24 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -2084,7 +2084,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index 377326b12c..9a0ada4b52 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -134,7 +134,9 @@  GLIBC_2.30 twalk_r F
 GLIBC_2.31 msgctl F
 GLIBC_2.31 semctl F
 GLIBC_2.31 shmctl F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 81eea10680..333c35bf16 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2164,7 +2164,9 @@  GLIBC_2.30 twalk_r F
 GLIBC_2.31 msgctl F
 GLIBC_2.31 semctl F
 GLIBC_2.31 shmctl F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index ff75663747..824eceec11 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2144,7 +2144,9 @@  GLIBC_2.30 twalk_r F
 GLIBC_2.31 msgctl F
 GLIBC_2.31 semctl F
 GLIBC_2.31 shmctl F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index e9a6375dfc..5a6dcdd21b 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2141,7 +2141,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 598fc488c7..6e5dbb28f1 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2135,7 +2135,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index 77e8d6b155..3ee64614b2 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2133,7 +2133,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index a3aad2487f..dc62615524 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2141,7 +2141,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index c074f612f5..8cf78bcf51 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -2135,7 +2135,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index d1c638acb9..7817aeb0e2 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2182,7 +2182,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index bfc8185b0e..ca04e8f2d3 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2191,7 +2191,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 9a889f1bc6..10cb895639 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2224,7 +2224,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
index b69f4b126f..96ddc448d7 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -2054,7 +2054,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index a07753847d..deddb53d83 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2344,7 +2344,9 @@  GLIBC_2.32 __wcstoieee128_l F
 GLIBC_2.32 __wprintf_chkieee128 F
 GLIBC_2.32 __wprintfieee128 F
 GLIBC_2.32 __wscanfieee128 F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index 6d5a52dc1a..58217dcb13 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2111,7 +2111,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index ae3849d3f6..c22c29b35a 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2189,7 +2189,9 @@  GLIBC_2.30 twalk_r F
 GLIBC_2.31 msgctl F
 GLIBC_2.31 semctl F
 GLIBC_2.31 shmctl F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index 2eb931c02c..568f1727c4 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -2090,7 +2090,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index ce4f366fbb..d9988dae90 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2059,7 +2059,9 @@  GLIBC_2.30 twalk_r F
 GLIBC_2.31 msgctl F
 GLIBC_2.31 semctl F
 GLIBC_2.31 shmctl F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index f37a08ab09..39edeffe82 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2056,7 +2056,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index af3a5e2618..8668e15e8c 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2180,7 +2180,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 1fccc06f21..eb884afa3e 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -2107,7 +2107,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index 03af18babb..a208fb3556 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -2065,7 +2065,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 2da0af70d4..3eca3493e2 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2162,7 +2162,9 @@  GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 pthread_attr_getsigmask_np F
 GLIBC_2.32 pthread_attr_setaffinity_np F
+GLIBC_2.32 pthread_attr_setsigmask_np F
 GLIBC_2.32 pthread_getaffinity_np F
 GLIBC_2.32 pthread_getattr_np F
 GLIBC_2.32 pthread_sigmask F