[02/19] nptl: Replace some stubs with the Linux implementation

Message ID 1b4b8b9cf969a8ac5d1af30f0f8eb862552b2641.1589884403.git.fweimer@redhat.com
State New
Headers show
Series
  • Signal mask for timer helper thread
Related show

Commit Message

Adhemerval Zanella via Libc-alpha May 19, 2020, 10:44 a.m.
The stubs for pthread_getaffinity_np, pthread_getname_np,
pthread_setaffinity_np, pthread_setname_np are replaced, and corresponding
tests are moved.

After the removal of the NaCl port, nptl is Linux-specific, and the stubs
are no longer needed.  This effectively reverts commit
c76d1ff5149bd03210f2bb8cd64446c51618d016 ("NPTL: Add stubs for Linux-only
extension functions.").
---
 nptl/Makefile                                 |  9 ++-
 nptl/pthread_getaffinity.c                    | 42 ++++++++---
 nptl/pthread_getname.c                        | 49 +++++++++++--
 nptl/pthread_setaffinity.c                    | 37 +++++++---
 nptl/pthread_setname.c                        | 43 ++++++++++--
 .../unix/sysv/linux => nptl}/tst-setgetname.c |  0
 .../tst-thread-affinity-pthread.c             |  0
 .../tst-thread-affinity-pthread2.c            |  0
 .../tst-thread-affinity-sched.c               |  0
 sysdeps/unix/sysv/linux/Makefile              |  5 +-
 sysdeps/unix/sysv/linux/pthread_getaffinity.c | 58 ----------------
 sysdeps/unix/sysv/linux/pthread_getname.c     | 69 -------------------
 sysdeps/unix/sysv/linux/pthread_setaffinity.c | 53 --------------
 sysdeps/unix/sysv/linux/pthread_setname.c     | 63 -----------------
 14 files changed, 151 insertions(+), 277 deletions(-)
 rename {sysdeps/unix/sysv/linux => nptl}/tst-setgetname.c (100%)
 rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-pthread.c (100%)
 rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-pthread2.c (100%)
 rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-sched.c (100%)
 delete mode 100644 sysdeps/unix/sysv/linux/pthread_getaffinity.c
 delete mode 100644 sysdeps/unix/sysv/linux/pthread_getname.c
 delete mode 100644 sysdeps/unix/sysv/linux/pthread_setaffinity.c
 delete mode 100644 sysdeps/unix/sysv/linux/pthread_setname.c

-- 
2.25.4

Comments

Adhemerval Zanella via Libc-alpha May 20, 2020, 1:27 p.m. | #1
On 5/19/20 6:44 AM, Florian Weimer via Libc-alpha wrote:
> The stubs for pthread_getaffinity_np, pthread_getname_np,

> pthread_setaffinity_np, pthread_setname_np are replaced, and corresponding

> tests are moved.

> 

> After the removal of the NaCl port, nptl is Linux-specific, and the stubs

> are no longer needed.  This effectively reverts commit

> c76d1ff5149bd03210f2bb8cd64446c51618d016 ("NPTL: Add stubs for Linux-only

> extension functions.").


Reviewed with `git difftool -t meld -d HEAD~18..HEAD~17` and the move looks good.

OK for master.

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



> ---

>  nptl/Makefile                                 |  9 ++-

>  nptl/pthread_getaffinity.c                    | 42 ++++++++---

>  nptl/pthread_getname.c                        | 49 +++++++++++--

>  nptl/pthread_setaffinity.c                    | 37 +++++++---

>  nptl/pthread_setname.c                        | 43 ++++++++++--

>  .../unix/sysv/linux => nptl}/tst-setgetname.c |  0

>  .../tst-thread-affinity-pthread.c             |  0

>  .../tst-thread-affinity-pthread2.c            |  0

>  .../tst-thread-affinity-sched.c               |  0

>  sysdeps/unix/sysv/linux/Makefile              |  5 +-

>  sysdeps/unix/sysv/linux/pthread_getaffinity.c | 58 ----------------

>  sysdeps/unix/sysv/linux/pthread_getname.c     | 69 -------------------

>  sysdeps/unix/sysv/linux/pthread_setaffinity.c | 53 --------------

>  sysdeps/unix/sysv/linux/pthread_setname.c     | 63 -----------------

>  14 files changed, 151 insertions(+), 277 deletions(-)

>  rename {sysdeps/unix/sysv/linux => nptl}/tst-setgetname.c (100%)

>  rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-pthread.c (100%)

>  rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-pthread2.c (100%)

>  rename {sysdeps/unix/sysv/linux => nptl}/tst-thread-affinity-sched.c (100%)

>  delete mode 100644 sysdeps/unix/sysv/linux/pthread_getaffinity.c

>  delete mode 100644 sysdeps/unix/sysv/linux/pthread_getname.c

>  delete mode 100644 sysdeps/unix/sysv/linux/pthread_setaffinity.c

>  delete mode 100644 sysdeps/unix/sysv/linux/pthread_setname.c

> 

> diff --git a/nptl/Makefile b/nptl/Makefile

> index ef9a6eb561..5fc45b224b 100644

> --- a/nptl/Makefile

> +++ b/nptl/Makefile

> @@ -321,14 +321,19 @@ tests = tst-attr2 tst-attr3 tst-default-attr \

>  	tst-thread-exit-clobber tst-minstack-cancel tst-minstack-exit \

>  	tst-minstack-throw \

>  	tst-rwlock-pwn \

> -	tst-unwind-thread

> +	tst-unwind-thread \

> +	tst-thread-affinity-pthread \

> +	tst-thread-affinity-pthread2 \

> +	tst-thread-affinity-sched \

> +

>  

>  tests-container =  tst-pthread-getattr

>  

>  tests-internal := tst-robustpi8 tst-rwlock19 tst-rwlock20 \

>  		  tst-sem11 tst-sem12 tst-sem13 \

>  		  tst-barrier5 tst-signal7 tst-mutex8 tst-mutex8-static \

> -		  tst-mutexpi8 tst-mutexpi8-static tst-cancel25

> +		  tst-mutexpi8 tst-mutexpi8-static tst-cancel25 \

> +		  tst-setgetname \

>  

>  xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \

>  	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10

> diff --git a/nptl/pthread_getaffinity.c b/nptl/pthread_getaffinity.c

> index 2ba05b5b92..cf6ecfe01f 100644

> --- a/nptl/pthread_getaffinity.c

> +++ b/nptl/pthread_getaffinity.c

> @@ -1,6 +1,6 @@

> -/* Get the processor affinity of a thread.  Stub version.

> -   Copyright (C) 2014-2020 Free Software Foundation, Inc.

> +/* Copyright (C) 2003-2020 Free Software Foundation, Inc.

>     This file is part of the GNU C Library.

> +   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.

>  

>     The GNU C Library is free software; you can redistribute it and/or

>     modify it under the terms of the GNU Lesser General Public

> @@ -16,17 +16,43 @@

>     License along with the GNU C Library; if not, see

>     <https://www.gnu.org/licenses/>.  */

>  

> +#include <errno.h>

> +#include <limits.h>

>  #include <pthreadP.h>

> +#include <string.h>

> +#include <sysdep.h>

> +#include <sys/param.h>

> +#include <sys/types.h>

> +#include <shlib-compat.h>

> +

>  

>  int

> -__pthread_getaffinity_np (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset)

> +__pthread_getaffinity_new (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset)

>  {

>    const struct pthread *pd = (const struct pthread *) th;

>  

> -  if (INVALID_TD_P (pd))

> -    return ESRCH;

> +  int res = INTERNAL_SYSCALL_CALL (sched_getaffinity, pd->tid,

> +				   MIN (INT_MAX, cpusetsize), cpuset);

> +  if (INTERNAL_SYSCALL_ERROR_P (res))

> +    return INTERNAL_SYSCALL_ERRNO (res);

> +

> +  /* Clean the rest of the memory the kernel didn't do.  */

> +  memset ((char *) cpuset + res, '\0', cpusetsize - res);

> +

> +  return 0;

> +}

> +strong_alias (__pthread_getaffinity_new, __pthread_getaffinity_np)

> +versioned_symbol (libpthread, __pthread_getaffinity_new,

> +		  pthread_getaffinity_np, GLIBC_2_3_4);

>  

> -  return ENOSYS;

> +

> +#if SHLIB_COMPAT (libpthread, GLIBC_2_3_3, GLIBC_2_3_4)

> +int

> +__pthread_getaffinity_old (pthread_t th, cpu_set_t *cpuset)

> +{

> +  /* The old interface by default assumed a 1024 processor bitmap.  */

> +  return __pthread_getaffinity_new (th, 128, cpuset);

>  }

> -weak_alias (__pthread_getaffinity_np, pthread_getaffinity_np)

> -stub_warning (pthread_getaffinity_np)

> +compat_symbol (libpthread, __pthread_getaffinity_old, pthread_getaffinity_np,

> +	       GLIBC_2_3_3);

> +#endif

> diff --git a/nptl/pthread_getname.c b/nptl/pthread_getname.c

> index b771f2ef76..c78cccffd4 100644

> --- a/nptl/pthread_getname.c

> +++ b/nptl/pthread_getname.c

> @@ -1,5 +1,5 @@

> -/* pthread_getname_np -- Get thread name.  Stub version.

> -   Copyright (C) 2014-2020 Free Software Foundation, Inc.

> +/* pthread_getname_np -- Get  thread name.  Linux version

> +   Copyright (C) 2010-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

> @@ -17,16 +17,53 @@

>     not, see <https://www.gnu.org/licenses/>.  */

>  

>  #include <errno.h>

> +#include <fcntl.h>

>  #include <pthreadP.h>

> +#include <stdio.h>

> +#include <string.h>

> +#include <unistd.h>

> +#include <sys/prctl.h>

> +

> +#include <not-cancel.h>

> +

>  

>  int

>  pthread_getname_np (pthread_t th, char *buf, size_t len)

>  {

>    const struct pthread *pd = (const struct pthread *) th;

>  

> -  if (INVALID_TD_P (pd))

> -    return ESRCH;

> +  /* Unfortunately the kernel headers do not export the TASK_COMM_LEN

> +     macro.  So we have to define it here.  */

> +#define TASK_COMM_LEN 16

> +  if (len < TASK_COMM_LEN)

> +    return ERANGE;

> +

> +  if (pd == THREAD_SELF)

> +    return prctl (PR_GET_NAME, buf) ? errno : 0;

> +

> +#define FMT "/proc/self/task/%u/comm"

> +  char fname[sizeof (FMT) + 8];

> +  sprintf (fname, FMT, (unsigned int) pd->tid);

> +

> +  int fd = __open64_nocancel (fname, O_RDONLY);

> +  if (fd == -1)

> +    return errno;

> +

> +  int res = 0;

> +  ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, len));

> +  if (n < 0)

> +    res = errno;

> +  else

> +    {

> +      if (buf[n - 1] == '\n')

> +	buf[n - 1] = '\0';

> +      else if (n == len)

> +	res = ERANGE;

> +      else

> +	buf[n] = '\0';

> +    }

> +

> +  __close_nocancel_nostatus (fd);

>  

> -  return ENOSYS;

> +  return res;

>  }

> -stub_warning (pthread_getname_np)

> diff --git a/nptl/pthread_setaffinity.c b/nptl/pthread_setaffinity.c

> index 29bbfb4fb2..b0bd90c324 100644

> --- a/nptl/pthread_setaffinity.c

> +++ b/nptl/pthread_setaffinity.c

> @@ -1,6 +1,6 @@

> -/* Set the processor affinity of a thread.  Stub version.

> -   Copyright (C) 2014-2020 Free Software Foundation, Inc.

> +/* Copyright (C) 2003-2020 Free Software Foundation, Inc.

>     This file is part of the GNU C Library.

> +   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.

>  

>     The GNU C Library is free software; you can redistribute it and/or

>     modify it under the terms of the GNU Lesser General Public

> @@ -16,17 +16,38 @@

>     License along with the GNU C Library; if not, see

>     <https://www.gnu.org/licenses/>.  */

>  

> +#include <errno.h>

>  #include <pthreadP.h>

> +#include <sysdep.h>

> +#include <sys/types.h>

> +#include <shlib-compat.h>

> +

>  

>  int

> -pthread_setaffinity_np (pthread_t th,

> -                        size_t cpusetsize, const cpu_set_t *cpuset)

> +__pthread_setaffinity_new (pthread_t th, size_t cpusetsize,

> +			   const cpu_set_t *cpuset)

>  {

>    const struct pthread *pd = (const struct pthread *) th;

> +  int res;

> +

> +  res = INTERNAL_SYSCALL_CALL (sched_setaffinity, pd->tid, cpusetsize,

> +			       cpuset);

> +

> +  return (INTERNAL_SYSCALL_ERROR_P (res)

> +	  ? INTERNAL_SYSCALL_ERRNO (res)

> +	  : 0);

> +}

> +versioned_symbol (libpthread, __pthread_setaffinity_new,

> +		  pthread_setaffinity_np, GLIBC_2_3_4);

>  

> -  if (INVALID_TD_P (pd))

> -    return ESRCH;

>  

> -  return ENOSYS;

> +#if SHLIB_COMPAT (libpthread, GLIBC_2_3_3, GLIBC_2_3_4)

> +int

> +__pthread_setaffinity_old (pthread_t th, cpu_set_t *cpuset)

> +{

> +  /* The old interface by default assumed a 1024 processor bitmap.  */

> +  return __pthread_setaffinity_new (th, 128, cpuset);

>  }

> -stub_warning (pthread_setaffinity_np)

> +compat_symbol (libpthread, __pthread_setaffinity_old, pthread_setaffinity_np,

> +	       GLIBC_2_3_3);

> +#endif

> diff --git a/nptl/pthread_setname.c b/nptl/pthread_setname.c

> index adfb3e828f..29df46b77c 100644

> --- a/nptl/pthread_setname.c

> +++ b/nptl/pthread_setname.c

> @@ -1,5 +1,5 @@

> -/* pthread_setname_np -- Set thread name.  Stub version.

> -   Copyright (C) 2014-2020 Free Software Foundation, Inc.

> +/* pthread_setname_np -- Set  thread name.  Linux version

> +   Copyright (C) 2010-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

> @@ -17,16 +17,47 @@

>     not, see <https://www.gnu.org/licenses/>.  */

>  

>  #include <errno.h>

> +#include <fcntl.h>

>  #include <pthreadP.h>

> +#include <stdio.h>

> +#include <string.h>

> +#include <unistd.h>

> +#include <sys/prctl.h>

> +

> +#include <not-cancel.h>

> +

>  

>  int

>  pthread_setname_np (pthread_t th, const char *name)

>  {

>    const struct pthread *pd = (const struct pthread *) th;

>  

> -  if (INVALID_TD_P (pd))

> -    return ESRCH;

> +  /* Unfortunately the kernel headers do not export the TASK_COMM_LEN

> +     macro.  So we have to define it here.  */

> +#define TASK_COMM_LEN 16

> +  size_t name_len = strlen (name);

> +  if (name_len >= TASK_COMM_LEN)

> +    return ERANGE;

> +

> +  if (pd == THREAD_SELF)

> +    return prctl (PR_SET_NAME, name) ? errno : 0;

> +

> +#define FMT "/proc/self/task/%u/comm"

> +  char fname[sizeof (FMT) + 8];

> +  sprintf (fname, FMT, (unsigned int) pd->tid);

> +

> +  int fd = __open64_nocancel (fname, O_RDWR);

> +  if (fd == -1)

> +    return errno;

> +

> +  int res = 0;

> +  ssize_t n = TEMP_FAILURE_RETRY (__write_nocancel (fd, name, name_len));

> +  if (n < 0)

> +    res = errno;

> +  else if (n != name_len)

> +    res = EIO;

> +

> +  __close_nocancel_nostatus (fd);

>  

> -  return ENOSYS;

> +  return res;

>  }

> -stub_warning (pthread_setname_np)

> diff --git a/sysdeps/unix/sysv/linux/tst-setgetname.c b/nptl/tst-setgetname.c

> similarity index 100%

> rename from sysdeps/unix/sysv/linux/tst-setgetname.c

> rename to nptl/tst-setgetname.c

> diff --git a/sysdeps/unix/sysv/linux/tst-thread-affinity-pthread.c b/nptl/tst-thread-affinity-pthread.c

> similarity index 100%

> rename from sysdeps/unix/sysv/linux/tst-thread-affinity-pthread.c

> rename to nptl/tst-thread-affinity-pthread.c

> diff --git a/sysdeps/unix/sysv/linux/tst-thread-affinity-pthread2.c b/nptl/tst-thread-affinity-pthread2.c

> similarity index 100%

> rename from sysdeps/unix/sysv/linux/tst-thread-affinity-pthread2.c

> rename to nptl/tst-thread-affinity-pthread2.c

> diff --git a/sysdeps/unix/sysv/linux/tst-thread-affinity-sched.c b/nptl/tst-thread-affinity-sched.c

> similarity index 100%

> rename from sysdeps/unix/sysv/linux/tst-thread-affinity-sched.c

> rename to nptl/tst-thread-affinity-sched.c

> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile

> index 0326f92c40..0060435a92 100644

> --- a/sysdeps/unix/sysv/linux/Makefile

> +++ b/sysdeps/unix/sysv/linux/Makefile

> @@ -299,8 +299,5 @@ CFLAGS-gai.c += -DNEED_NETLINK

>  endif

>  

>  ifeq ($(subdir),nptl)

> -tests += tst-align-clone tst-getpid1 \

> -	tst-thread-affinity-pthread tst-thread-affinity-pthread2 \

> -	tst-thread-affinity-sched

> -tests-internal += tst-setgetname

> +tests += tst-align-clone tst-getpid1

>  endif

> diff --git a/sysdeps/unix/sysv/linux/pthread_getaffinity.c b/sysdeps/unix/sysv/linux/pthread_getaffinity.c

> deleted file mode 100644

> index cf6ecfe01f..0000000000

> --- a/sysdeps/unix/sysv/linux/pthread_getaffinity.c

> +++ /dev/null

> @@ -1,58 +0,0 @@

> -/* Copyright (C) 2003-2020 Free Software Foundation, Inc.

> -   This file is part of the GNU C Library.

> -   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.

> -

> -   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 <errno.h>

> -#include <limits.h>

> -#include <pthreadP.h>

> -#include <string.h>

> -#include <sysdep.h>

> -#include <sys/param.h>

> -#include <sys/types.h>

> -#include <shlib-compat.h>

> -

> -

> -int

> -__pthread_getaffinity_new (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset)

> -{

> -  const struct pthread *pd = (const struct pthread *) th;

> -

> -  int res = INTERNAL_SYSCALL_CALL (sched_getaffinity, pd->tid,

> -				   MIN (INT_MAX, cpusetsize), cpuset);

> -  if (INTERNAL_SYSCALL_ERROR_P (res))

> -    return INTERNAL_SYSCALL_ERRNO (res);

> -

> -  /* Clean the rest of the memory the kernel didn't do.  */

> -  memset ((char *) cpuset + res, '\0', cpusetsize - res);

> -

> -  return 0;

> -}

> -strong_alias (__pthread_getaffinity_new, __pthread_getaffinity_np)

> -versioned_symbol (libpthread, __pthread_getaffinity_new,

> -		  pthread_getaffinity_np, GLIBC_2_3_4);

> -

> -

> -#if SHLIB_COMPAT (libpthread, GLIBC_2_3_3, GLIBC_2_3_4)

> -int

> -__pthread_getaffinity_old (pthread_t th, cpu_set_t *cpuset)

> -{

> -  /* The old interface by default assumed a 1024 processor bitmap.  */

> -  return __pthread_getaffinity_new (th, 128, cpuset);

> -}

> -compat_symbol (libpthread, __pthread_getaffinity_old, pthread_getaffinity_np,

> -	       GLIBC_2_3_3);

> -#endif

> diff --git a/sysdeps/unix/sysv/linux/pthread_getname.c b/sysdeps/unix/sysv/linux/pthread_getname.c

> deleted file mode 100644

> index c78cccffd4..0000000000

> --- a/sysdeps/unix/sysv/linux/pthread_getname.c

> +++ /dev/null

> @@ -1,69 +0,0 @@

> -/* pthread_getname_np -- Get  thread name.  Linux version

> -   Copyright (C) 2010-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; see the file COPYING.LIB.  If

> -   not, see <https://www.gnu.org/licenses/>.  */

> -

> -#include <errno.h>

> -#include <fcntl.h>

> -#include <pthreadP.h>

> -#include <stdio.h>

> -#include <string.h>

> -#include <unistd.h>

> -#include <sys/prctl.h>

> -

> -#include <not-cancel.h>

> -

> -

> -int

> -pthread_getname_np (pthread_t th, char *buf, size_t len)

> -{

> -  const struct pthread *pd = (const struct pthread *) th;

> -

> -  /* Unfortunately the kernel headers do not export the TASK_COMM_LEN

> -     macro.  So we have to define it here.  */

> -#define TASK_COMM_LEN 16

> -  if (len < TASK_COMM_LEN)

> -    return ERANGE;

> -

> -  if (pd == THREAD_SELF)

> -    return prctl (PR_GET_NAME, buf) ? errno : 0;

> -

> -#define FMT "/proc/self/task/%u/comm"

> -  char fname[sizeof (FMT) + 8];

> -  sprintf (fname, FMT, (unsigned int) pd->tid);

> -

> -  int fd = __open64_nocancel (fname, O_RDONLY);

> -  if (fd == -1)

> -    return errno;

> -

> -  int res = 0;

> -  ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, len));

> -  if (n < 0)

> -    res = errno;

> -  else

> -    {

> -      if (buf[n - 1] == '\n')

> -	buf[n - 1] = '\0';

> -      else if (n == len)

> -	res = ERANGE;

> -      else

> -	buf[n] = '\0';

> -    }

> -

> -  __close_nocancel_nostatus (fd);

> -

> -  return res;

> -}

> diff --git a/sysdeps/unix/sysv/linux/pthread_setaffinity.c b/sysdeps/unix/sysv/linux/pthread_setaffinity.c

> deleted file mode 100644

> index b0bd90c324..0000000000

> --- a/sysdeps/unix/sysv/linux/pthread_setaffinity.c

> +++ /dev/null

> @@ -1,53 +0,0 @@

> -/* Copyright (C) 2003-2020 Free Software Foundation, Inc.

> -   This file is part of the GNU C Library.

> -   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.

> -

> -   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 <errno.h>

> -#include <pthreadP.h>

> -#include <sysdep.h>

> -#include <sys/types.h>

> -#include <shlib-compat.h>

> -

> -

> -int

> -__pthread_setaffinity_new (pthread_t th, size_t cpusetsize,

> -			   const cpu_set_t *cpuset)

> -{

> -  const struct pthread *pd = (const struct pthread *) th;

> -  int res;

> -

> -  res = INTERNAL_SYSCALL_CALL (sched_setaffinity, pd->tid, cpusetsize,

> -			       cpuset);

> -

> -  return (INTERNAL_SYSCALL_ERROR_P (res)

> -	  ? INTERNAL_SYSCALL_ERRNO (res)

> -	  : 0);

> -}

> -versioned_symbol (libpthread, __pthread_setaffinity_new,

> -		  pthread_setaffinity_np, GLIBC_2_3_4);

> -

> -

> -#if SHLIB_COMPAT (libpthread, GLIBC_2_3_3, GLIBC_2_3_4)

> -int

> -__pthread_setaffinity_old (pthread_t th, cpu_set_t *cpuset)

> -{

> -  /* The old interface by default assumed a 1024 processor bitmap.  */

> -  return __pthread_setaffinity_new (th, 128, cpuset);

> -}

> -compat_symbol (libpthread, __pthread_setaffinity_old, pthread_setaffinity_np,

> -	       GLIBC_2_3_3);

> -#endif

> diff --git a/sysdeps/unix/sysv/linux/pthread_setname.c b/sysdeps/unix/sysv/linux/pthread_setname.c

> deleted file mode 100644

> index 29df46b77c..0000000000

> --- a/sysdeps/unix/sysv/linux/pthread_setname.c

> +++ /dev/null

> @@ -1,63 +0,0 @@

> -/* pthread_setname_np -- Set  thread name.  Linux version

> -   Copyright (C) 2010-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; see the file COPYING.LIB.  If

> -   not, see <https://www.gnu.org/licenses/>.  */

> -

> -#include <errno.h>

> -#include <fcntl.h>

> -#include <pthreadP.h>

> -#include <stdio.h>

> -#include <string.h>

> -#include <unistd.h>

> -#include <sys/prctl.h>

> -

> -#include <not-cancel.h>

> -

> -

> -int

> -pthread_setname_np (pthread_t th, const char *name)

> -{

> -  const struct pthread *pd = (const struct pthread *) th;

> -

> -  /* Unfortunately the kernel headers do not export the TASK_COMM_LEN

> -     macro.  So we have to define it here.  */

> -#define TASK_COMM_LEN 16

> -  size_t name_len = strlen (name);

> -  if (name_len >= TASK_COMM_LEN)

> -    return ERANGE;

> -

> -  if (pd == THREAD_SELF)

> -    return prctl (PR_SET_NAME, name) ? errno : 0;

> -

> -#define FMT "/proc/self/task/%u/comm"

> -  char fname[sizeof (FMT) + 8];

> -  sprintf (fname, FMT, (unsigned int) pd->tid);

> -

> -  int fd = __open64_nocancel (fname, O_RDWR);

> -  if (fd == -1)

> -    return errno;

> -

> -  int res = 0;

> -  ssize_t n = TEMP_FAILURE_RETRY (__write_nocancel (fd, name, name_len));

> -  if (n < 0)

> -    res = errno;

> -  else if (n != name_len)

> -    res = EIO;

> -

> -  __close_nocancel_nostatus (fd);

> -

> -  return res;

> -}

> 



-- 
Cheers,
Carlos.

Patch

diff --git a/nptl/Makefile b/nptl/Makefile
index ef9a6eb561..5fc45b224b 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -321,14 +321,19 @@  tests = tst-attr2 tst-attr3 tst-default-attr \
 	tst-thread-exit-clobber tst-minstack-cancel tst-minstack-exit \
 	tst-minstack-throw \
 	tst-rwlock-pwn \
-	tst-unwind-thread
+	tst-unwind-thread \
+	tst-thread-affinity-pthread \
+	tst-thread-affinity-pthread2 \
+	tst-thread-affinity-sched \
+
 
 tests-container =  tst-pthread-getattr
 
 tests-internal := tst-robustpi8 tst-rwlock19 tst-rwlock20 \
 		  tst-sem11 tst-sem12 tst-sem13 \
 		  tst-barrier5 tst-signal7 tst-mutex8 tst-mutex8-static \
-		  tst-mutexpi8 tst-mutexpi8-static tst-cancel25
+		  tst-mutexpi8 tst-mutexpi8-static tst-cancel25 \
+		  tst-setgetname \
 
 xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10
diff --git a/nptl/pthread_getaffinity.c b/nptl/pthread_getaffinity.c
index 2ba05b5b92..cf6ecfe01f 100644
--- a/nptl/pthread_getaffinity.c
+++ b/nptl/pthread_getaffinity.c
@@ -1,6 +1,6 @@ 
-/* Get the processor affinity of a thread.  Stub version.
-   Copyright (C) 2014-2020 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -16,17 +16,43 @@ 
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <errno.h>
+#include <limits.h>
 #include <pthreadP.h>
+#include <string.h>
+#include <sysdep.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <shlib-compat.h>
+
 
 int
-__pthread_getaffinity_np (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset)
+__pthread_getaffinity_new (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset)
 {
   const struct pthread *pd = (const struct pthread *) th;
 
-  if (INVALID_TD_P (pd))
-    return ESRCH;
+  int res = INTERNAL_SYSCALL_CALL (sched_getaffinity, pd->tid,
+				   MIN (INT_MAX, cpusetsize), cpuset);
+  if (INTERNAL_SYSCALL_ERROR_P (res))
+    return INTERNAL_SYSCALL_ERRNO (res);
+
+  /* Clean the rest of the memory the kernel didn't do.  */
+  memset ((char *) cpuset + res, '\0', cpusetsize - res);
+
+  return 0;
+}
+strong_alias (__pthread_getaffinity_new, __pthread_getaffinity_np)
+versioned_symbol (libpthread, __pthread_getaffinity_new,
+		  pthread_getaffinity_np, GLIBC_2_3_4);
 
-  return ENOSYS;
+
+#if SHLIB_COMPAT (libpthread, GLIBC_2_3_3, GLIBC_2_3_4)
+int
+__pthread_getaffinity_old (pthread_t th, cpu_set_t *cpuset)
+{
+  /* The old interface by default assumed a 1024 processor bitmap.  */
+  return __pthread_getaffinity_new (th, 128, cpuset);
 }
-weak_alias (__pthread_getaffinity_np, pthread_getaffinity_np)
-stub_warning (pthread_getaffinity_np)
+compat_symbol (libpthread, __pthread_getaffinity_old, pthread_getaffinity_np,
+	       GLIBC_2_3_3);
+#endif
diff --git a/nptl/pthread_getname.c b/nptl/pthread_getname.c
index b771f2ef76..c78cccffd4 100644
--- a/nptl/pthread_getname.c
+++ b/nptl/pthread_getname.c
@@ -1,5 +1,5 @@ 
-/* pthread_getname_np -- Get thread name.  Stub version.
-   Copyright (C) 2014-2020 Free Software Foundation, Inc.
+/* pthread_getname_np -- Get  thread name.  Linux version
+   Copyright (C) 2010-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
@@ -17,16 +17,53 @@ 
    not, see <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
+#include <fcntl.h>
 #include <pthreadP.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/prctl.h>
+
+#include <not-cancel.h>
+
 
 int
 pthread_getname_np (pthread_t th, char *buf, size_t len)
 {
   const struct pthread *pd = (const struct pthread *) th;
 
-  if (INVALID_TD_P (pd))
-    return ESRCH;
+  /* Unfortunately the kernel headers do not export the TASK_COMM_LEN
+     macro.  So we have to define it here.  */
+#define TASK_COMM_LEN 16
+  if (len < TASK_COMM_LEN)
+    return ERANGE;
+
+  if (pd == THREAD_SELF)
+    return prctl (PR_GET_NAME, buf) ? errno : 0;
+
+#define FMT "/proc/self/task/%u/comm"
+  char fname[sizeof (FMT) + 8];
+  sprintf (fname, FMT, (unsigned int) pd->tid);
+
+  int fd = __open64_nocancel (fname, O_RDONLY);
+  if (fd == -1)
+    return errno;
+
+  int res = 0;
+  ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, len));
+  if (n < 0)
+    res = errno;
+  else
+    {
+      if (buf[n - 1] == '\n')
+	buf[n - 1] = '\0';
+      else if (n == len)
+	res = ERANGE;
+      else
+	buf[n] = '\0';
+    }
+
+  __close_nocancel_nostatus (fd);
 
-  return ENOSYS;
+  return res;
 }
-stub_warning (pthread_getname_np)
diff --git a/nptl/pthread_setaffinity.c b/nptl/pthread_setaffinity.c
index 29bbfb4fb2..b0bd90c324 100644
--- a/nptl/pthread_setaffinity.c
+++ b/nptl/pthread_setaffinity.c
@@ -1,6 +1,6 @@ 
-/* Set the processor affinity of a thread.  Stub version.
-   Copyright (C) 2014-2020 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -16,17 +16,38 @@ 
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <errno.h>
 #include <pthreadP.h>
+#include <sysdep.h>
+#include <sys/types.h>
+#include <shlib-compat.h>
+
 
 int
-pthread_setaffinity_np (pthread_t th,
-                        size_t cpusetsize, const cpu_set_t *cpuset)
+__pthread_setaffinity_new (pthread_t th, size_t cpusetsize,
+			   const cpu_set_t *cpuset)
 {
   const struct pthread *pd = (const struct pthread *) th;
+  int res;
+
+  res = INTERNAL_SYSCALL_CALL (sched_setaffinity, pd->tid, cpusetsize,
+			       cpuset);
+
+  return (INTERNAL_SYSCALL_ERROR_P (res)
+	  ? INTERNAL_SYSCALL_ERRNO (res)
+	  : 0);
+}
+versioned_symbol (libpthread, __pthread_setaffinity_new,
+		  pthread_setaffinity_np, GLIBC_2_3_4);
 
-  if (INVALID_TD_P (pd))
-    return ESRCH;
 
-  return ENOSYS;
+#if SHLIB_COMPAT (libpthread, GLIBC_2_3_3, GLIBC_2_3_4)
+int
+__pthread_setaffinity_old (pthread_t th, cpu_set_t *cpuset)
+{
+  /* The old interface by default assumed a 1024 processor bitmap.  */
+  return __pthread_setaffinity_new (th, 128, cpuset);
 }
-stub_warning (pthread_setaffinity_np)
+compat_symbol (libpthread, __pthread_setaffinity_old, pthread_setaffinity_np,
+	       GLIBC_2_3_3);
+#endif
diff --git a/nptl/pthread_setname.c b/nptl/pthread_setname.c
index adfb3e828f..29df46b77c 100644
--- a/nptl/pthread_setname.c
+++ b/nptl/pthread_setname.c
@@ -1,5 +1,5 @@ 
-/* pthread_setname_np -- Set thread name.  Stub version.
-   Copyright (C) 2014-2020 Free Software Foundation, Inc.
+/* pthread_setname_np -- Set  thread name.  Linux version
+   Copyright (C) 2010-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
@@ -17,16 +17,47 @@ 
    not, see <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
+#include <fcntl.h>
 #include <pthreadP.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/prctl.h>
+
+#include <not-cancel.h>
+
 
 int
 pthread_setname_np (pthread_t th, const char *name)
 {
   const struct pthread *pd = (const struct pthread *) th;
 
-  if (INVALID_TD_P (pd))
-    return ESRCH;
+  /* Unfortunately the kernel headers do not export the TASK_COMM_LEN
+     macro.  So we have to define it here.  */
+#define TASK_COMM_LEN 16
+  size_t name_len = strlen (name);
+  if (name_len >= TASK_COMM_LEN)
+    return ERANGE;
+
+  if (pd == THREAD_SELF)
+    return prctl (PR_SET_NAME, name) ? errno : 0;
+
+#define FMT "/proc/self/task/%u/comm"
+  char fname[sizeof (FMT) + 8];
+  sprintf (fname, FMT, (unsigned int) pd->tid);
+
+  int fd = __open64_nocancel (fname, O_RDWR);
+  if (fd == -1)
+    return errno;
+
+  int res = 0;
+  ssize_t n = TEMP_FAILURE_RETRY (__write_nocancel (fd, name, name_len));
+  if (n < 0)
+    res = errno;
+  else if (n != name_len)
+    res = EIO;
+
+  __close_nocancel_nostatus (fd);
 
-  return ENOSYS;
+  return res;
 }
-stub_warning (pthread_setname_np)
diff --git a/sysdeps/unix/sysv/linux/tst-setgetname.c b/nptl/tst-setgetname.c
similarity index 100%
rename from sysdeps/unix/sysv/linux/tst-setgetname.c
rename to nptl/tst-setgetname.c
diff --git a/sysdeps/unix/sysv/linux/tst-thread-affinity-pthread.c b/nptl/tst-thread-affinity-pthread.c
similarity index 100%
rename from sysdeps/unix/sysv/linux/tst-thread-affinity-pthread.c
rename to nptl/tst-thread-affinity-pthread.c
diff --git a/sysdeps/unix/sysv/linux/tst-thread-affinity-pthread2.c b/nptl/tst-thread-affinity-pthread2.c
similarity index 100%
rename from sysdeps/unix/sysv/linux/tst-thread-affinity-pthread2.c
rename to nptl/tst-thread-affinity-pthread2.c
diff --git a/sysdeps/unix/sysv/linux/tst-thread-affinity-sched.c b/nptl/tst-thread-affinity-sched.c
similarity index 100%
rename from sysdeps/unix/sysv/linux/tst-thread-affinity-sched.c
rename to nptl/tst-thread-affinity-sched.c
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 0326f92c40..0060435a92 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -299,8 +299,5 @@  CFLAGS-gai.c += -DNEED_NETLINK
 endif
 
 ifeq ($(subdir),nptl)
-tests += tst-align-clone tst-getpid1 \
-	tst-thread-affinity-pthread tst-thread-affinity-pthread2 \
-	tst-thread-affinity-sched
-tests-internal += tst-setgetname
+tests += tst-align-clone tst-getpid1
 endif
diff --git a/sysdeps/unix/sysv/linux/pthread_getaffinity.c b/sysdeps/unix/sysv/linux/pthread_getaffinity.c
deleted file mode 100644
index cf6ecfe01f..0000000000
--- a/sysdeps/unix/sysv/linux/pthread_getaffinity.c
+++ /dev/null
@@ -1,58 +0,0 @@ 
-/* Copyright (C) 2003-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
-
-   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 <errno.h>
-#include <limits.h>
-#include <pthreadP.h>
-#include <string.h>
-#include <sysdep.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <shlib-compat.h>
-
-
-int
-__pthread_getaffinity_new (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset)
-{
-  const struct pthread *pd = (const struct pthread *) th;
-
-  int res = INTERNAL_SYSCALL_CALL (sched_getaffinity, pd->tid,
-				   MIN (INT_MAX, cpusetsize), cpuset);
-  if (INTERNAL_SYSCALL_ERROR_P (res))
-    return INTERNAL_SYSCALL_ERRNO (res);
-
-  /* Clean the rest of the memory the kernel didn't do.  */
-  memset ((char *) cpuset + res, '\0', cpusetsize - res);
-
-  return 0;
-}
-strong_alias (__pthread_getaffinity_new, __pthread_getaffinity_np)
-versioned_symbol (libpthread, __pthread_getaffinity_new,
-		  pthread_getaffinity_np, GLIBC_2_3_4);
-
-
-#if SHLIB_COMPAT (libpthread, GLIBC_2_3_3, GLIBC_2_3_4)
-int
-__pthread_getaffinity_old (pthread_t th, cpu_set_t *cpuset)
-{
-  /* The old interface by default assumed a 1024 processor bitmap.  */
-  return __pthread_getaffinity_new (th, 128, cpuset);
-}
-compat_symbol (libpthread, __pthread_getaffinity_old, pthread_getaffinity_np,
-	       GLIBC_2_3_3);
-#endif
diff --git a/sysdeps/unix/sysv/linux/pthread_getname.c b/sysdeps/unix/sysv/linux/pthread_getname.c
deleted file mode 100644
index c78cccffd4..0000000000
--- a/sysdeps/unix/sysv/linux/pthread_getname.c
+++ /dev/null
@@ -1,69 +0,0 @@ 
-/* pthread_getname_np -- Get  thread name.  Linux version
-   Copyright (C) 2010-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; see the file COPYING.LIB.  If
-   not, see <https://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthreadP.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/prctl.h>
-
-#include <not-cancel.h>
-
-
-int
-pthread_getname_np (pthread_t th, char *buf, size_t len)
-{
-  const struct pthread *pd = (const struct pthread *) th;
-
-  /* Unfortunately the kernel headers do not export the TASK_COMM_LEN
-     macro.  So we have to define it here.  */
-#define TASK_COMM_LEN 16
-  if (len < TASK_COMM_LEN)
-    return ERANGE;
-
-  if (pd == THREAD_SELF)
-    return prctl (PR_GET_NAME, buf) ? errno : 0;
-
-#define FMT "/proc/self/task/%u/comm"
-  char fname[sizeof (FMT) + 8];
-  sprintf (fname, FMT, (unsigned int) pd->tid);
-
-  int fd = __open64_nocancel (fname, O_RDONLY);
-  if (fd == -1)
-    return errno;
-
-  int res = 0;
-  ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, len));
-  if (n < 0)
-    res = errno;
-  else
-    {
-      if (buf[n - 1] == '\n')
-	buf[n - 1] = '\0';
-      else if (n == len)
-	res = ERANGE;
-      else
-	buf[n] = '\0';
-    }
-
-  __close_nocancel_nostatus (fd);
-
-  return res;
-}
diff --git a/sysdeps/unix/sysv/linux/pthread_setaffinity.c b/sysdeps/unix/sysv/linux/pthread_setaffinity.c
deleted file mode 100644
index b0bd90c324..0000000000
--- a/sysdeps/unix/sysv/linux/pthread_setaffinity.c
+++ /dev/null
@@ -1,53 +0,0 @@ 
-/* Copyright (C) 2003-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
-
-   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 <errno.h>
-#include <pthreadP.h>
-#include <sysdep.h>
-#include <sys/types.h>
-#include <shlib-compat.h>
-
-
-int
-__pthread_setaffinity_new (pthread_t th, size_t cpusetsize,
-			   const cpu_set_t *cpuset)
-{
-  const struct pthread *pd = (const struct pthread *) th;
-  int res;
-
-  res = INTERNAL_SYSCALL_CALL (sched_setaffinity, pd->tid, cpusetsize,
-			       cpuset);
-
-  return (INTERNAL_SYSCALL_ERROR_P (res)
-	  ? INTERNAL_SYSCALL_ERRNO (res)
-	  : 0);
-}
-versioned_symbol (libpthread, __pthread_setaffinity_new,
-		  pthread_setaffinity_np, GLIBC_2_3_4);
-
-
-#if SHLIB_COMPAT (libpthread, GLIBC_2_3_3, GLIBC_2_3_4)
-int
-__pthread_setaffinity_old (pthread_t th, cpu_set_t *cpuset)
-{
-  /* The old interface by default assumed a 1024 processor bitmap.  */
-  return __pthread_setaffinity_new (th, 128, cpuset);
-}
-compat_symbol (libpthread, __pthread_setaffinity_old, pthread_setaffinity_np,
-	       GLIBC_2_3_3);
-#endif
diff --git a/sysdeps/unix/sysv/linux/pthread_setname.c b/sysdeps/unix/sysv/linux/pthread_setname.c
deleted file mode 100644
index 29df46b77c..0000000000
--- a/sysdeps/unix/sysv/linux/pthread_setname.c
+++ /dev/null
@@ -1,63 +0,0 @@ 
-/* pthread_setname_np -- Set  thread name.  Linux version
-   Copyright (C) 2010-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; see the file COPYING.LIB.  If
-   not, see <https://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthreadP.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/prctl.h>
-
-#include <not-cancel.h>
-
-
-int
-pthread_setname_np (pthread_t th, const char *name)
-{
-  const struct pthread *pd = (const struct pthread *) th;
-
-  /* Unfortunately the kernel headers do not export the TASK_COMM_LEN
-     macro.  So we have to define it here.  */
-#define TASK_COMM_LEN 16
-  size_t name_len = strlen (name);
-  if (name_len >= TASK_COMM_LEN)
-    return ERANGE;
-
-  if (pd == THREAD_SELF)
-    return prctl (PR_SET_NAME, name) ? errno : 0;
-
-#define FMT "/proc/self/task/%u/comm"
-  char fname[sizeof (FMT) + 8];
-  sprintf (fname, FMT, (unsigned int) pd->tid);
-
-  int fd = __open64_nocancel (fname, O_RDWR);
-  if (fd == -1)
-    return errno;
-
-  int res = 0;
-  ssize_t n = TEMP_FAILURE_RETRY (__write_nocancel (fd, name, name_len));
-  if (n < 0)
-    res = errno;
-  else if (n != name_len)
-    res = EIO;
-
-  __close_nocancel_nostatus (fd);
-
-  return res;
-}