[10/10] C11 threads: Move implementation to sysdeps/pthread

Message ID 20200114185255.25813-12-samuel.thibault@ens-lyon.org
State New
Headers show
Series
  • Port C11 threads to GNU/Hurd
Related show

Commit Message

Samuel Thibault Jan. 14, 2020, 6:52 p.m.
so it gets shared by nptl and htl. Also add htl versions of thrd_current and
thrd_yield.
---
 htl/Versions                                  | 16 +++++
 nptl/Makefile                                 | 14 +----
 sysdeps/htl/pt-mutex-destroy.c                |  1 +
 sysdeps/htl/pt-mutex-timedlock.c              |  1 +
 sysdeps/htl/pthreadP.h                        |  2 +
 sysdeps/htl/thrd_current.c                    | 31 +++++++++
 sysdeps/htl/threads.h                         |  1 -
 sysdeps/hurd/stdc-predef.h                    | 63 -------------------
 sysdeps/mach/htl/thrd_yield.c                 | 26 ++++++++
 sysdeps/mach/hurd/htl/pt-mutex-destroy.c      |  1 +
 sysdeps/mach/hurd/htl/pt-mutex-timedlock.c    |  1 +
 sysdeps/mach/hurd/i386/libc.abilist           |  4 ++
 sysdeps/mach/hurd/i386/libpthread.abilist     | 21 +++++++
 sysdeps/nptl/thrd_create.c                    |  2 +
 sysdeps/pthread/Makefile                      | 18 ++++++
 {nptl => sysdeps/pthread}/call_once.c         |  0
 {nptl => sysdeps/pthread}/cnd_broadcast.c     |  0
 {nptl => sysdeps/pthread}/cnd_destroy.c       |  0
 {nptl => sysdeps/pthread}/cnd_init.c          |  0
 {nptl => sysdeps/pthread}/cnd_signal.c        |  0
 {nptl => sysdeps/pthread}/cnd_timedwait.c     |  0
 {nptl => sysdeps/pthread}/cnd_wait.c          |  0
 {nptl => sysdeps/pthread}/mtx_destroy.c       |  0
 {nptl => sysdeps/pthread}/mtx_init.c          |  0
 {nptl => sysdeps/pthread}/mtx_lock.c          |  0
 {nptl => sysdeps/pthread}/mtx_timedlock.c     |  0
 {nptl => sysdeps/pthread}/mtx_trylock.c       |  0
 {nptl => sysdeps/pthread}/mtx_unlock.c        |  0
 {nptl => sysdeps/pthread}/thrd_create.c       |  4 +-
 {nptl => sysdeps/pthread}/thrd_detach.c       |  0
 {nptl => sysdeps/pthread}/thrd_equal.c        |  0
 {nptl => sysdeps/pthread}/thrd_exit.c         |  0
 {nptl => sysdeps/pthread}/thrd_join.c         |  0
 {nptl => sysdeps/pthread}/thrd_priv.h         |  0
 {nptl => sysdeps/pthread}/thrd_sleep.c        |  0
 sysdeps/{nptl => pthread}/threads.h           |  0
 {nptl => sysdeps/pthread}/tss_create.c        |  0
 {nptl => sysdeps/pthread}/tss_delete.c        |  0
 {nptl => sysdeps/pthread}/tss_get.c           |  0
 {nptl => sysdeps/pthread}/tss_set.c           |  0
 {nptl => sysdeps/pthread}/tst-call-once.c     |  0
 {nptl => sysdeps/pthread}/tst-cnd-basic.c     |  0
 {nptl => sysdeps/pthread}/tst-cnd-broadcast.c |  0
 {nptl => sysdeps/pthread}/tst-cnd-timedwait.c |  0
 {nptl => sysdeps/pthread}/tst-mtx-basic.c     |  0
 {nptl => sysdeps/pthread}/tst-mtx-recursive.c |  0
 {nptl => sysdeps/pthread}/tst-mtx-timedlock.c |  0
 {nptl => sysdeps/pthread}/tst-mtx-trylock.c   |  0
 {nptl => sysdeps/pthread}/tst-thrd-detach.c   |  0
 {nptl => sysdeps/pthread}/tst-thrd-sleep.c    |  0
 {nptl => sysdeps/pthread}/tst-tss-basic.c     |  0
 51 files changed, 129 insertions(+), 77 deletions(-)
 create mode 100644 sysdeps/htl/thrd_current.c
 delete mode 100644 sysdeps/htl/threads.h
 delete mode 100644 sysdeps/hurd/stdc-predef.h
 create mode 100644 sysdeps/mach/htl/thrd_yield.c
 create mode 100644 sysdeps/nptl/thrd_create.c
 rename {nptl => sysdeps/pthread}/call_once.c (100%)
 rename {nptl => sysdeps/pthread}/cnd_broadcast.c (100%)
 rename {nptl => sysdeps/pthread}/cnd_destroy.c (100%)
 rename {nptl => sysdeps/pthread}/cnd_init.c (100%)
 rename {nptl => sysdeps/pthread}/cnd_signal.c (100%)
 rename {nptl => sysdeps/pthread}/cnd_timedwait.c (100%)
 rename {nptl => sysdeps/pthread}/cnd_wait.c (100%)
 rename {nptl => sysdeps/pthread}/mtx_destroy.c (100%)
 rename {nptl => sysdeps/pthread}/mtx_init.c (100%)
 rename {nptl => sysdeps/pthread}/mtx_lock.c (100%)
 rename {nptl => sysdeps/pthread}/mtx_timedlock.c (100%)
 rename {nptl => sysdeps/pthread}/mtx_trylock.c (100%)
 rename {nptl => sysdeps/pthread}/mtx_unlock.c (100%)
 rename {nptl => sysdeps/pthread}/thrd_create.c (91%)
 rename {nptl => sysdeps/pthread}/thrd_detach.c (100%)
 rename {nptl => sysdeps/pthread}/thrd_equal.c (100%)
 rename {nptl => sysdeps/pthread}/thrd_exit.c (100%)
 rename {nptl => sysdeps/pthread}/thrd_join.c (100%)
 rename {nptl => sysdeps/pthread}/thrd_priv.h (100%)
 rename {nptl => sysdeps/pthread}/thrd_sleep.c (100%)
 rename sysdeps/{nptl => pthread}/threads.h (100%)
 rename {nptl => sysdeps/pthread}/tss_create.c (100%)
 rename {nptl => sysdeps/pthread}/tss_delete.c (100%)
 rename {nptl => sysdeps/pthread}/tss_get.c (100%)
 rename {nptl => sysdeps/pthread}/tss_set.c (100%)
 rename {nptl => sysdeps/pthread}/tst-call-once.c (100%)
 rename {nptl => sysdeps/pthread}/tst-cnd-basic.c (100%)
 rename {nptl => sysdeps/pthread}/tst-cnd-broadcast.c (100%)
 rename {nptl => sysdeps/pthread}/tst-cnd-timedwait.c (100%)
 rename {nptl => sysdeps/pthread}/tst-mtx-basic.c (100%)
 rename {nptl => sysdeps/pthread}/tst-mtx-recursive.c (100%)
 rename {nptl => sysdeps/pthread}/tst-mtx-timedlock.c (100%)
 rename {nptl => sysdeps/pthread}/tst-mtx-trylock.c (100%)
 rename {nptl => sysdeps/pthread}/tst-thrd-detach.c (100%)
 rename {nptl => sysdeps/pthread}/tst-thrd-sleep.c (100%)
 rename {nptl => sysdeps/pthread}/tst-tss-basic.c (100%)

-- 
2.24.1

Comments

Adhemerval Zanella Jan. 21, 2020, 12:39 p.m. | #1
On 14/01/2020 15:52, Samuel Thibault wrote:
> so it gets shared by nptl and htl. Also add htl versions of thrd_current and

> thrd_yield.


LGTM with a small nit below.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>


> ---

>  htl/Versions                                  | 16 +++++

>  nptl/Makefile                                 | 14 +----

>  sysdeps/htl/pt-mutex-destroy.c                |  1 +

>  sysdeps/htl/pt-mutex-timedlock.c              |  1 +

>  sysdeps/htl/pthreadP.h                        |  2 +

>  sysdeps/htl/thrd_current.c                    | 31 +++++++++

>  sysdeps/htl/threads.h                         |  1 -

>  sysdeps/hurd/stdc-predef.h                    | 63 -------------------

>  sysdeps/mach/htl/thrd_yield.c                 | 26 ++++++++

>  sysdeps/mach/hurd/htl/pt-mutex-destroy.c      |  1 +

>  sysdeps/mach/hurd/htl/pt-mutex-timedlock.c    |  1 +

>  sysdeps/mach/hurd/i386/libc.abilist           |  4 ++

>  sysdeps/mach/hurd/i386/libpthread.abilist     | 21 +++++++

>  sysdeps/nptl/thrd_create.c                    |  2 +

>  sysdeps/pthread/Makefile                      | 18 ++++++

>  {nptl => sysdeps/pthread}/call_once.c         |  0

>  {nptl => sysdeps/pthread}/cnd_broadcast.c     |  0

>  {nptl => sysdeps/pthread}/cnd_destroy.c       |  0

>  {nptl => sysdeps/pthread}/cnd_init.c          |  0

>  {nptl => sysdeps/pthread}/cnd_signal.c        |  0

>  {nptl => sysdeps/pthread}/cnd_timedwait.c     |  0

>  {nptl => sysdeps/pthread}/cnd_wait.c          |  0

>  {nptl => sysdeps/pthread}/mtx_destroy.c       |  0

>  {nptl => sysdeps/pthread}/mtx_init.c          |  0

>  {nptl => sysdeps/pthread}/mtx_lock.c          |  0

>  {nptl => sysdeps/pthread}/mtx_timedlock.c     |  0

>  {nptl => sysdeps/pthread}/mtx_trylock.c       |  0

>  {nptl => sysdeps/pthread}/mtx_unlock.c        |  0

>  {nptl => sysdeps/pthread}/thrd_create.c       |  4 +-

>  {nptl => sysdeps/pthread}/thrd_detach.c       |  0

>  {nptl => sysdeps/pthread}/thrd_equal.c        |  0

>  {nptl => sysdeps/pthread}/thrd_exit.c         |  0

>  {nptl => sysdeps/pthread}/thrd_join.c         |  0

>  {nptl => sysdeps/pthread}/thrd_priv.h         |  0

>  {nptl => sysdeps/pthread}/thrd_sleep.c        |  0

>  sysdeps/{nptl => pthread}/threads.h           |  0

>  {nptl => sysdeps/pthread}/tss_create.c        |  0

>  {nptl => sysdeps/pthread}/tss_delete.c        |  0

>  {nptl => sysdeps/pthread}/tss_get.c           |  0

>  {nptl => sysdeps/pthread}/tss_set.c           |  0

>  {nptl => sysdeps/pthread}/tst-call-once.c     |  0

>  {nptl => sysdeps/pthread}/tst-cnd-basic.c     |  0

>  {nptl => sysdeps/pthread}/tst-cnd-broadcast.c |  0

>  {nptl => sysdeps/pthread}/tst-cnd-timedwait.c |  0

>  {nptl => sysdeps/pthread}/tst-mtx-basic.c     |  0

>  {nptl => sysdeps/pthread}/tst-mtx-recursive.c |  0

>  {nptl => sysdeps/pthread}/tst-mtx-timedlock.c |  0

>  {nptl => sysdeps/pthread}/tst-mtx-trylock.c   |  0

>  {nptl => sysdeps/pthread}/tst-thrd-detach.c   |  0

>  {nptl => sysdeps/pthread}/tst-thrd-sleep.c    |  0

>  {nptl => sysdeps/pthread}/tst-tss-basic.c     |  0

>  51 files changed, 129 insertions(+), 77 deletions(-)

>  create mode 100644 sysdeps/htl/thrd_current.c

>  delete mode 100644 sysdeps/htl/threads.h

>  delete mode 100644 sysdeps/hurd/stdc-predef.h

>  create mode 100644 sysdeps/mach/htl/thrd_yield.c

>  create mode 100644 sysdeps/nptl/thrd_create.c

>  rename {nptl => sysdeps/pthread}/call_once.c (100%)

>  rename {nptl => sysdeps/pthread}/cnd_broadcast.c (100%)

>  rename {nptl => sysdeps/pthread}/cnd_destroy.c (100%)

>  rename {nptl => sysdeps/pthread}/cnd_init.c (100%)

>  rename {nptl => sysdeps/pthread}/cnd_signal.c (100%)

>  rename {nptl => sysdeps/pthread}/cnd_timedwait.c (100%)

>  rename {nptl => sysdeps/pthread}/cnd_wait.c (100%)

>  rename {nptl => sysdeps/pthread}/mtx_destroy.c (100%)

>  rename {nptl => sysdeps/pthread}/mtx_init.c (100%)

>  rename {nptl => sysdeps/pthread}/mtx_lock.c (100%)

>  rename {nptl => sysdeps/pthread}/mtx_timedlock.c (100%)

>  rename {nptl => sysdeps/pthread}/mtx_trylock.c (100%)

>  rename {nptl => sysdeps/pthread}/mtx_unlock.c (100%)

>  rename {nptl => sysdeps/pthread}/thrd_create.c (91%)

>  rename {nptl => sysdeps/pthread}/thrd_detach.c (100%)

>  rename {nptl => sysdeps/pthread}/thrd_equal.c (100%)

>  rename {nptl => sysdeps/pthread}/thrd_exit.c (100%)

>  rename {nptl => sysdeps/pthread}/thrd_join.c (100%)

>  rename {nptl => sysdeps/pthread}/thrd_priv.h (100%)

>  rename {nptl => sysdeps/pthread}/thrd_sleep.c (100%)

>  rename sysdeps/{nptl => pthread}/threads.h (100%)

>  rename {nptl => sysdeps/pthread}/tss_create.c (100%)

>  rename {nptl => sysdeps/pthread}/tss_delete.c (100%)

>  rename {nptl => sysdeps/pthread}/tss_get.c (100%)

>  rename {nptl => sysdeps/pthread}/tss_set.c (100%)

>  rename {nptl => sysdeps/pthread}/tst-call-once.c (100%)

>  rename {nptl => sysdeps/pthread}/tst-cnd-basic.c (100%)

>  rename {nptl => sysdeps/pthread}/tst-cnd-broadcast.c (100%)

>  rename {nptl => sysdeps/pthread}/tst-cnd-timedwait.c (100%)

>  rename {nptl => sysdeps/pthread}/tst-mtx-basic.c (100%)

>  rename {nptl => sysdeps/pthread}/tst-mtx-recursive.c (100%)

>  rename {nptl => sysdeps/pthread}/tst-mtx-timedlock.c (100%)

>  rename {nptl => sysdeps/pthread}/tst-mtx-trylock.c (100%)

>  rename {nptl => sysdeps/pthread}/tst-thrd-detach.c (100%)

>  rename {nptl => sysdeps/pthread}/tst-thrd-sleep.c (100%)

>  rename {nptl => sysdeps/pthread}/tst-tss-basic.c (100%)

> 

> diff --git a/htl/Versions b/htl/Versions

> index 3ae4b5c17d..c44507c21d 100644

> --- a/htl/Versions

> +++ b/htl/Versions

> @@ -20,6 +20,12 @@ libc {

>    GLIBC_2.22 {

>      __register_atfork;

>    }

> +

> +  # C11 thread symbols.

> +  GLIBC_2.32 {

> +    thrd_current; thrd_equal; thrd_sleep; thrd_yield;

> +  }

> +

>    GLIBC_PRIVATE {

>      __libc_alloca_cutoff;

>      __libc_pthread_init;



Ok.

> @@ -142,6 +148,16 @@ libpthread {

>      pthread_hurd_cond_wait_np;

>      pthread_hurd_cond_timedwait_np;

>    }

> +

> +  # C11 thread symbols.

> +  GLIBC_2.32 {

> +    thrd_create; thrd_detach; thrd_exit; thrd_join;

> +    mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; mtx_unlock; mtx_destroy;

> +    call_once;

> +    cnd_broadcast; cnd_destroy; cnd_init; cnd_signal; cnd_timedwait; cnd_wait;

> +    tss_create; tss_delete; tss_get; tss_set;

> +  }

> +

>    GLIBC_PRIVATE {

>      __shm_directory;

>      __pthread_threads;


Ok.

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

> index 584e0ffd96..820b757692 100644

> --- a/nptl/Makefile

> +++ b/nptl/Makefile

> @@ -22,7 +22,7 @@ subdir	:= nptl

>  

>  include ../Makeconfig

>  

> -headers := pthread.h semaphore.h bits/semaphore.h threads.h \

> +headers := pthread.h semaphore.h bits/semaphore.h \

>  	   bits/struct_mutex.h bits/struct_rwlock.h

>  

>  extra-libs := libpthread

> @@ -30,8 +30,7 @@ extra-libs-others := $(extra-libs)

>  

>  routines = alloca_cutoff forward libc-lowlevellock libc-cancellation \

>  	   libc-cleanup libc_pthread_init libc_multiple_threads \

> -	   register-atfork pthread_atfork pthread_self thrd_current \

> -	   thrd_equal thrd_sleep thrd_yield pthread_equal \

> +	   register-atfork pthread_atfork pthread_self pthread_equal \

>  	   pthread_attr_destroy pthread_attr_init pthread_attr_getdetachstate \

>  	   pthread_attr_setdetachstate pthread_attr_getinheritsched \

>  	   pthread_attr_setinheritsched pthread_attr_getschedparam \


Ok.

> @@ -141,11 +140,7 @@ libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \

>  		      pthread_mutex_setprioceiling \

>  		      pthread_setname pthread_getname \

>  		      pthread_setattr_default_np pthread_getattr_default_np \

> -		      thrd_create thrd_detach thrd_exit thrd_join \

> -		      mtx_destroy mtx_init mtx_lock mtx_timedlock \

> -		      mtx_trylock mtx_unlock call_once cnd_broadcast \

> -		      cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait \

> -		      tss_create tss_delete tss_get tss_set pthread_mutex_conf \

> +		      pthread_mutex_conf \

>  		      libpthread-compat

>  #		      pthread_setuid pthread_seteuid pthread_setreuid \

>  #		      pthread_setresuid \


Ok.

> @@ -319,9 +314,6 @@ tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \

>  	tst-robust-fork tst-create-detached tst-memstream \

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

>  	tst-minstack-throw \

> -	tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \

> -	tst-cnd-timedwait tst-thrd-detach tst-mtx-basic tst-thrd-sleep \

> -	tst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock \

>  	tst-rwlock-pwn \

>  	tst-rwlock-tryrdlock-stall tst-rwlock-trywrlock-stall \

>  	tst-unwind-thread


Ok.

> diff --git a/sysdeps/htl/pt-mutex-destroy.c b/sysdeps/htl/pt-mutex-destroy.c

> index 796fc11b8d..6a3b5be874 100644

> --- a/sysdeps/htl/pt-mutex-destroy.c

> +++ b/sysdeps/htl/pt-mutex-destroy.c

> @@ -36,3 +36,4 @@ __pthread_mutex_destroy (pthread_mutex_t *mutex)

>  }

>  

>  strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy);

> +hidden_def (__pthread_mutex_destroy)


Ok.

> diff --git a/sysdeps/htl/pt-mutex-timedlock.c b/sysdeps/htl/pt-mutex-timedlock.c

> index 0e50f38ef2..81013984a6 100644

> --- a/sysdeps/htl/pt-mutex-timedlock.c

> +++ b/sysdeps/htl/pt-mutex-timedlock.c

> @@ -195,3 +195,4 @@ __pthread_mutex_timedlock (struct __pthread_mutex *mutex,

>    return __pthread_mutex_timedlock_internal (mutex, abstime);

>  }

>  strong_alias (__pthread_mutex_timedlock, pthread_mutex_timedlock)

> +hidden_def (__pthread_mutex_timedlock)


Ok.

> diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h

> index fc8c9bc591..fd1e697e39 100644

> --- a/sysdeps/htl/pthreadP.h

> +++ b/sysdeps/htl/pthreadP.h

> @@ -91,6 +91,8 @@ hidden_proto (__pthread_key_create)

>  hidden_proto (__pthread_getspecific)

>  hidden_proto (__pthread_setspecific)

>  hidden_proto (__pthread_mutex_init)

> +hidden_proto (__pthread_mutex_destroy)

> +hidden_proto (__pthread_mutex_timedlock)

>  #endif

>  

>  #define ASSERT_TYPE_SIZE(type, size) 	


OK
				\
> diff --git a/sysdeps/htl/thrd_current.c b/sysdeps/htl/thrd_current.c

> new file mode 100644

> index 0000000000..efc0d11b5d

> --- /dev/null

> +++ b/sysdeps/htl/thrd_current.c

> @@ -0,0 +1,31 @@

> +/* C11 threads current thread implementation.

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


I think this is new file.

> +   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 "thrd_priv.h"

> +

> +#pragma weak __pthread_self

> +#pragma weak __pthread_threads

> +

> +thrd_t

> +thrd_current (void)

> +{

> +  if (__pthread_threads)

> +    return (thrd_t) __pthread_self ();

> +

> +  return (thrd_t) 0;

> +}


Ok.

> diff --git a/sysdeps/htl/threads.h b/sysdeps/htl/threads.h

> deleted file mode 100644

> index 3c04fbcc79..0000000000

> --- a/sysdeps/htl/threads.h

> +++ /dev/null

> @@ -1 +0,0 @@

> -#error "HTL does not implement ISO C threads"


Ok.

> diff --git a/sysdeps/hurd/stdc-predef.h b/sysdeps/hurd/stdc-predef.h

> deleted file mode 100644

> index a7bb5f7c5f..0000000000

> --- a/sysdeps/hurd/stdc-predef.h

> +++ /dev/null

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

> -/* Copyright (C) 2018-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/>.  */

> -

> -#ifndef	_STDC_PREDEF_H

> -#define	_STDC_PREDEF_H	1

> -

> -/* This header is separate from features.h so that the compiler can

> -   include it implicitly at the start of every compilation.  It must

> -   not itself include <features.h> or any other header that includes

> -   <features.h> because the implicit include comes before any feature

> -   test macros that may be defined in a source file before it first

> -   explicitly includes a system header.  GCC knows the name of this

> -   header in order to preinclude it.  */

> -

> -/* glibc's intent is to support the IEC 559 math functionality, real

> -   and complex.  If the GCC (4.9 and later) predefined macros

> -   specifying compiler intent are available, use them to determine

> -   whether the overall intent is to support these features; otherwise,

> -   presume an older compiler has intent to support these features and

> -   define these macros by default.  */

> -

> -#ifdef __GCC_IEC_559

> -# if __GCC_IEC_559 > 0

> -#  define __STDC_IEC_559__		1

> -# endif

> -#else

> -# define __STDC_IEC_559__		1

> -#endif

> -

> -#ifdef __GCC_IEC_559_COMPLEX

> -# if __GCC_IEC_559_COMPLEX > 0

> -#  define __STDC_IEC_559_COMPLEX__	1

> -# endif

> -#else

> -# define __STDC_IEC_559_COMPLEX__	1

> -#endif

> -

> -/* wchar_t uses Unicode 10.0.0.  Version 10.0 of the Unicode Standard is

> -   synchronized with ISO/IEC 10646:2017, fifth edition, plus

> -   the following additions from Amendment 1 to the fifth edition:

> -   - 56 emoji characters

> -   - 285 hentaigana

> -   - 3 additional Zanabazar Square characters */

> -#define __STDC_ISO_10646__		201706L

> -

> -/* We do not support C11 <threads.h>.  */

> -#define __STDC_NO_THREADS__		1

> -

> -#endif


Ok.

> diff --git a/sysdeps/mach/htl/thrd_yield.c b/sysdeps/mach/htl/thrd_yield.c

> new file mode 100644

> index 0000000000..09e218cf2e

> --- /dev/null

> +++ b/sysdeps/mach/htl/thrd_yield.c

> @@ -0,0 +1,26 @@

> +/* sched_yield -- yield the processor.  Mach version.

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


I think this is new file (even though it is based on sched_yield).

> +   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 <mach.h>

> +#include "thrd_priv.h"

> +

> +void

> +thrd_yield (void)

> +{

> +  (void) __swtch ();

> +}


Ok.

> diff --git a/sysdeps/mach/hurd/htl/pt-mutex-destroy.c b/sysdeps/mach/hurd/htl/pt-mutex-destroy.c

> index a8a0adc03f..a5bfaddcb2 100644

> --- a/sysdeps/mach/hurd/htl/pt-mutex-destroy.c

> +++ b/sysdeps/mach/hurd/htl/pt-mutex-destroy.c

> @@ -35,3 +35,4 @@ __pthread_mutex_destroy (pthread_mutex_t *mtxp)

>  }

>  

>  strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy)

> +hidden_def (__pthread_mutex_destroy)


Ok.

> diff --git a/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c b/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c

> index e83bc57875..3aa7d798b2 100644

> --- a/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c

> +++ b/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c

> @@ -77,3 +77,4 @@ __pthread_mutex_timedlock (pthread_mutex_t *mtxp, const struct timespec *tsp)

>    return ret;

>  }

>  strong_alias (__pthread_mutex_timedlock, pthread_mutex_timedlock)

> +hidden_def (__pthread_mutex_timedlock)


Ok.

> diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist

> index 7c2cb2b05a..dd0d3c7317 100644

> --- a/sysdeps/mach/hurd/i386/libc.abilist

> +++ b/sysdeps/mach/hurd/i386/libc.abilist

> @@ -2181,6 +2181,10 @@ GLIBC_2.3.4 setsourcefilter F

>  GLIBC_2.3.4 xdr_quad_t F

>  GLIBC_2.3.4 xdr_u_quad_t F

>  GLIBC_2.30 twalk_r F

> +GLIBC_2.32 thrd_current F

> +GLIBC_2.32 thrd_equal F

> +GLIBC_2.32 thrd_sleep F

> +GLIBC_2.32 thrd_yield F

>  GLIBC_2.4 __confstr_chk F

>  GLIBC_2.4 __fgets_chk F

>  GLIBC_2.4 __fgets_unlocked_chk F


Ok.

> diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist

> index cda8755960..0b90f9bf63 100644

> --- a/sysdeps/mach/hurd/i386/libpthread.abilist

> +++ b/sysdeps/mach/hurd/i386/libpthread.abilist

> @@ -147,3 +147,24 @@ GLIBC_2.2.6 __errno_location F

>  GLIBC_2.2.6 __h_errno_location F

>  GLIBC_2.21 pthread_hurd_cond_timedwait_np F

>  GLIBC_2.21 pthread_hurd_cond_wait_np F

> +GLIBC_2.32 call_once F

> +GLIBC_2.32 cnd_broadcast F

> +GLIBC_2.32 cnd_destroy F

> +GLIBC_2.32 cnd_init F

> +GLIBC_2.32 cnd_signal F

> +GLIBC_2.32 cnd_timedwait F

> +GLIBC_2.32 cnd_wait F

> +GLIBC_2.32 mtx_destroy F

> +GLIBC_2.32 mtx_init F

> +GLIBC_2.32 mtx_lock F

> +GLIBC_2.32 mtx_timedlock F

> +GLIBC_2.32 mtx_trylock F

> +GLIBC_2.32 mtx_unlock F

> +GLIBC_2.32 thrd_create F

> +GLIBC_2.32 thrd_detach F

> +GLIBC_2.32 thrd_exit F

> +GLIBC_2.32 thrd_join F

> +GLIBC_2.32 tss_create F

> +GLIBC_2.32 tss_delete F

> +GLIBC_2.32 tss_get F

> +GLIBC_2.32 tss_set F


Ok.

> diff --git a/sysdeps/nptl/thrd_create.c b/sysdeps/nptl/thrd_create.c

> new file mode 100644

> index 0000000000..a9219db7bc

> --- /dev/null

> +++ b/sysdeps/nptl/thrd_create.c

> @@ -0,0 +1,2 @@

> +#define __pthread_create __pthread_create_2_1

> +#include "../pthread/thrd_create.c"


I think it better to include fall path instead of relative one.

> diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile

> index 7f9eadd0e2..889f10d8b1 100644

> --- a/sysdeps/pthread/Makefile

> +++ b/sysdeps/pthread/Makefile

> @@ -25,3 +25,21 @@ $(objpfx)tst-timer: $(objpfx)librt.a $(static-thread-library)

>  endif

>  

>  endif

> +

> +ifneq (,$(filter $(subdir),htl nptl))

> +headers += threads.h

> +

> +routines += thrd_current thrd_equal thrd_sleep thrd_yield

> +

> +libpthread-routines += thrd_create thrd_detach thrd_exit thrd_join \

> +		       call_once \

> +		       mtx_destroy mtx_init mtx_lock mtx_timedlock \

> +		       mtx_trylock mtx_unlock \

> +		       cnd_broadcast \

> +		       cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait \

> +		       tss_create tss_delete tss_get tss_set

> +

> +tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \

> +	 tst-cnd-timedwait tst-thrd-detach tst-mtx-basic tst-thrd-sleep \

> +	 tst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock

> +endif


Ok.

> diff --git a/nptl/call_once.c b/sysdeps/pthread/call_once.c

> similarity index 100%

> rename from nptl/call_once.c

> rename to sysdeps/pthread/call_once.c


Ok.

> diff --git a/nptl/cnd_broadcast.c b/sysdeps/pthread/cnd_broadcast.c

> similarity index 100%

> rename from nptl/cnd_broadcast.c

> rename to sysdeps/pthread/cnd_broadcast.c


Ok.

> diff --git a/nptl/cnd_destroy.c b/sysdeps/pthread/cnd_destroy.c

> similarity index 100%

> rename from nptl/cnd_destroy.c

> rename to sysdeps/pthread/cnd_destroy.c


Ok.

> diff --git a/nptl/cnd_init.c b/sysdeps/pthread/cnd_init.c

> similarity index 100%

> rename from nptl/cnd_init.c

> rename to sysdeps/pthread/cnd_init.c


Ok.

> diff --git a/nptl/cnd_signal.c b/sysdeps/pthread/cnd_signal.c

> similarity index 100%

> rename from nptl/cnd_signal.c

> rename to sysdeps/pthread/cnd_signal.c


Ok.

> diff --git a/nptl/cnd_timedwait.c b/sysdeps/pthread/cnd_timedwait.c

> similarity index 100%

> rename from nptl/cnd_timedwait.c

> rename to sysdeps/pthread/cnd_timedwait.c


Ok.

> diff --git a/nptl/cnd_wait.c b/sysdeps/pthread/cnd_wait.c

> similarity index 100%

> rename from nptl/cnd_wait.c

> rename to sysdeps/pthread/cnd_wait.c


Ok.

> diff --git a/nptl/mtx_destroy.c b/sysdeps/pthread/mtx_destroy.c

> similarity index 100%

> rename from nptl/mtx_destroy.c

> rename to sysdeps/pthread/mtx_destroy.c


Ok.

> diff --git a/nptl/mtx_init.c b/sysdeps/pthread/mtx_init.c

> similarity index 100%

> rename from nptl/mtx_init.c

> rename to sysdeps/pthread/mtx_init.c


Ok.

> diff --git a/nptl/mtx_lock.c b/sysdeps/pthread/mtx_lock.c

> similarity index 100%

> rename from nptl/mtx_lock.c

> rename to sysdeps/pthread/mtx_lock.c


Ok.

> diff --git a/nptl/mtx_timedlock.c b/sysdeps/pthread/mtx_timedlock.c

> similarity index 100%

> rename from nptl/mtx_timedlock.c

> rename to sysdeps/pthread/mtx_timedlock.c


Ok.

> diff --git a/nptl/mtx_trylock.c b/sysdeps/pthread/mtx_trylock.c

> similarity index 100%

> rename from nptl/mtx_trylock.c

> rename to sysdeps/pthread/mtx_trylock.c


Ok.

> diff --git a/nptl/mtx_unlock.c b/sysdeps/pthread/mtx_unlock.c

> similarity index 100%

> rename from nptl/mtx_unlock.c

> rename to sysdeps/pthread/mtx_unlock.c


Ok.

> diff --git a/nptl/thrd_create.c b/sysdeps/pthread/thrd_create.c

> similarity index 91%

> rename from nptl/thrd_create.c

> rename to sysdeps/pthread/thrd_create.c


Ok.

> index fe08e22973..25af955419 100644

> --- a/nptl/thrd_create.c

> +++ b/sysdeps/pthread/thrd_create.c

> @@ -24,7 +24,7 @@ thrd_create (thrd_t *thr, thrd_start_t func, void *arg)

>    _Static_assert (sizeof (*thr) == sizeof (pthread_t),

>  		  "sizeof (*thr) != sizeof (pthread_t)");

>  

> -  int err_code = __pthread_create_2_1 (thr, ATTR_C11_THREAD,

> -				       (void* (*) (void*))func, arg);

> +  int err_code = __pthread_create (thr, ATTR_C11_THREAD,

> +				   (void* (*) (void*))func, arg);

>    return thrd_err_map (err_code);

>  }


Ok.

> diff --git a/nptl/thrd_detach.c b/sysdeps/pthread/thrd_detach.c

> similarity index 100%

> rename from nptl/thrd_detach.c

> rename to sysdeps/pthread/thrd_detach.c


Ok.

> diff --git a/nptl/thrd_equal.c b/sysdeps/pthread/thrd_equal.c

> similarity index 100%

> rename from nptl/thrd_equal.c

> rename to sysdeps/pthread/thrd_equal.c


Ok.

> diff --git a/nptl/thrd_exit.c b/sysdeps/pthread/thrd_exit.c

> similarity index 100%

> rename from nptl/thrd_exit.c

> rename to sysdeps/pthread/thrd_exit.c


Ok.

> diff --git a/nptl/thrd_join.c b/sysdeps/pthread/thrd_join.c

> similarity index 100%

> rename from nptl/thrd_join.c

> rename to sysdeps/pthread/thrd_join.c


Ok.

> diff --git a/nptl/thrd_priv.h b/sysdeps/pthread/thrd_priv.h

> similarity index 100%

> rename from nptl/thrd_priv.h

> rename to sysdeps/pthread/thrd_priv.h


Ok.

> diff --git a/nptl/thrd_sleep.c b/sysdeps/pthread/thrd_sleep.c

> similarity index 100%

> rename from nptl/thrd_sleep.c

> rename to sysdeps/pthread/thrd_sleep.c


Ok.

> diff --git a/sysdeps/nptl/threads.h b/sysdeps/pthread/threads.h

> similarity index 100%

> rename from sysdeps/nptl/threads.h

> rename to sysdeps/pthread/threads.h


Ok.

> diff --git a/nptl/tss_create.c b/sysdeps/pthread/tss_create.c

> similarity index 100%

> rename from nptl/tss_create.c

> rename to sysdeps/pthread/tss_create.c


Ok.

> diff --git a/nptl/tss_delete.c b/sysdeps/pthread/tss_delete.c

> similarity index 100%

> rename from nptl/tss_delete.c

> rename to sysdeps/pthread/tss_delete.c


Ok.

> diff --git a/nptl/tss_get.c b/sysdeps/pthread/tss_get.c

> similarity index 100%

> rename from nptl/tss_get.c

> rename to sysdeps/pthread/tss_get.c


Ok.

> diff --git a/nptl/tss_set.c b/sysdeps/pthread/tss_set.c

> similarity index 100%

> rename from nptl/tss_set.c

> rename to sysdeps/pthread/tss_set.c


Ok.

> diff --git a/nptl/tst-call-once.c b/sysdeps/pthread/tst-call-once.c

> similarity index 100%

> rename from nptl/tst-call-once.c

> rename to sysdeps/pthread/tst-call-once.c


Ok.

> diff --git a/nptl/tst-cnd-basic.c b/sysdeps/pthread/tst-cnd-basic.c

> similarity index 100%

> rename from nptl/tst-cnd-basic.c

> rename to sysdeps/pthread/tst-cnd-basic.c


Ok.

> diff --git a/nptl/tst-cnd-broadcast.c b/sysdeps/pthread/tst-cnd-broadcast.c

> similarity index 100%

> rename from nptl/tst-cnd-broadcast.c

> rename to sysdeps/pthread/tst-cnd-broadcast.c


Ok.

> diff --git a/nptl/tst-cnd-timedwait.c b/sysdeps/pthread/tst-cnd-timedwait.c

> similarity index 100%

> rename from nptl/tst-cnd-timedwait.c


Ok.

> rename to sysdeps/pthread/tst-cnd-timedwait.c

> diff --git a/nptl/tst-mtx-basic.c b/sysdeps/pthread/tst-mtx-basic.c

> similarity index 100%

> rename from nptl/tst-mtx-basic.c

> rename to sysdeps/pthread/tst-mtx-basic.c


Ok.

> diff --git a/nptl/tst-mtx-recursive.c b/sysdeps/pthread/tst-mtx-recursive.c

> similarity index 100%

> rename from nptl/tst-mtx-recursive.c

> rename to sysdeps/pthread/tst-mtx-recursive.c


Ok.

> diff --git a/nptl/tst-mtx-timedlock.c b/sysdeps/pthread/tst-mtx-timedlock.c

> similarity index 100%

> rename from nptl/tst-mtx-timedlock.c

> rename to sysdeps/pthread/tst-mtx-timedlock.c


Ok.

> diff --git a/nptl/tst-mtx-trylock.c b/sysdeps/pthread/tst-mtx-trylock.c

> similarity index 100%

> rename from nptl/tst-mtx-trylock.c

> rename to sysdeps/pthread/tst-mtx-trylock.c


Ok.

> diff --git a/nptl/tst-thrd-detach.c b/sysdeps/pthread/tst-thrd-detach.c

> similarity index 100%

> rename from nptl/tst-thrd-detach.c

> rename to sysdeps/pthread/tst-thrd-detach.c


Ok.

> diff --git a/nptl/tst-thrd-sleep.c b/sysdeps/pthread/tst-thrd-sleep.c

> similarity index 100%

> rename from nptl/tst-thrd-sleep.c

> rename to sysdeps/pthread/tst-thrd-sleep.c


Ok.

> diff --git a/nptl/tst-tss-basic.c b/sysdeps/pthread/tst-tss-basic.c

> similarity index 100%

> rename from nptl/tst-tss-basic.c

> rename to sysdeps/pthread/tst-tss-basic.c

> 


Ok.
Samuel Thibault Jan. 21, 2020, 10:01 p.m. | #2
Adhemerval Zanella, le mar. 21 janv. 2020 09:39:31 -0300, a ecrit:
> LGTM with a small nit below.

> 

> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

> 

> > --- /dev/null

> > +++ b/sysdeps/htl/thrd_current.c

> > @@ -0,0 +1,31 @@

> > +/* C11 threads current thread implementation.

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

> 

> I think this is new file.


Right, I did copy from another file, but nothing copyrightable was kept
from the original file.

> > diff --git a/sysdeps/mach/htl/thrd_yield.c b/sysdeps/mach/htl/thrd_yield.c

> > new file mode 100644

> > index 0000000000..09e218cf2e

> > --- /dev/null

> > +++ b/sysdeps/mach/htl/thrd_yield.c

> > @@ -0,0 +1,26 @@

> > +/* sched_yield -- yield the processor.  Mach version.

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

> 

> I think this is new file (even though it is based on sched_yield).


Ditto, not really something copyrightable.

> > diff --git a/sysdeps/nptl/thrd_create.c b/sysdeps/nptl/thrd_create.c

> > new file mode 100644

> > index 0000000000..a9219db7bc

> > --- /dev/null

> > +++ b/sysdeps/nptl/thrd_create.c

> > @@ -0,0 +1,2 @@

> > +#define __pthread_create __pthread_create_2_1

> > +#include "../pthread/thrd_create.c"

> 

> I think it better to include fall path instead of relative one.


Do you mean using #include_next ? That does not work, gcc warns that it's
discouraged in primary source file.

Samuel
Adhemerval Zanella Jan. 22, 2020, 12:36 p.m. | #3
On 21/01/2020 19:01, Samuel Thibault wrote:
> 

>>> diff --git a/sysdeps/nptl/thrd_create.c b/sysdeps/nptl/thrd_create.c

>>> new file mode 100644

>>> index 0000000000..a9219db7bc

>>> --- /dev/null

>>> +++ b/sysdeps/nptl/thrd_create.c

>>> @@ -0,0 +1,2 @@

>>> +#define __pthread_create __pthread_create_2_1

>>> +#include "../pthread/thrd_create.c"

>>

>> I think it better to include fall path instead of relative one.

> 

> Do you mean using #include_next ? That does not work, gcc warns that it's

> discouraged in primary source file.


I meant 

#include <sysdeps/pthread/thrd_create.c>

I think it is clearly at source level to which file it refers and
require less change if the file is moved.

Patch

diff --git a/htl/Versions b/htl/Versions
index 3ae4b5c17d..c44507c21d 100644
--- a/htl/Versions
+++ b/htl/Versions
@@ -20,6 +20,12 @@  libc {
   GLIBC_2.22 {
     __register_atfork;
   }
+
+  # C11 thread symbols.
+  GLIBC_2.32 {
+    thrd_current; thrd_equal; thrd_sleep; thrd_yield;
+  }
+
   GLIBC_PRIVATE {
     __libc_alloca_cutoff;
     __libc_pthread_init;
@@ -142,6 +148,16 @@  libpthread {
     pthread_hurd_cond_wait_np;
     pthread_hurd_cond_timedwait_np;
   }
+
+  # C11 thread symbols.
+  GLIBC_2.32 {
+    thrd_create; thrd_detach; thrd_exit; thrd_join;
+    mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; mtx_unlock; mtx_destroy;
+    call_once;
+    cnd_broadcast; cnd_destroy; cnd_init; cnd_signal; cnd_timedwait; cnd_wait;
+    tss_create; tss_delete; tss_get; tss_set;
+  }
+
   GLIBC_PRIVATE {
     __shm_directory;
     __pthread_threads;
diff --git a/nptl/Makefile b/nptl/Makefile
index 584e0ffd96..820b757692 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -22,7 +22,7 @@  subdir	:= nptl
 
 include ../Makeconfig
 
-headers := pthread.h semaphore.h bits/semaphore.h threads.h \
+headers := pthread.h semaphore.h bits/semaphore.h \
 	   bits/struct_mutex.h bits/struct_rwlock.h
 
 extra-libs := libpthread
@@ -30,8 +30,7 @@  extra-libs-others := $(extra-libs)
 
 routines = alloca_cutoff forward libc-lowlevellock libc-cancellation \
 	   libc-cleanup libc_pthread_init libc_multiple_threads \
-	   register-atfork pthread_atfork pthread_self thrd_current \
-	   thrd_equal thrd_sleep thrd_yield pthread_equal \
+	   register-atfork pthread_atfork pthread_self pthread_equal \
 	   pthread_attr_destroy pthread_attr_init pthread_attr_getdetachstate \
 	   pthread_attr_setdetachstate pthread_attr_getinheritsched \
 	   pthread_attr_setinheritsched pthread_attr_getschedparam \
@@ -141,11 +140,7 @@  libpthread-routines = nptl-init nptlfreeres vars events version pt-interp \
 		      pthread_mutex_setprioceiling \
 		      pthread_setname pthread_getname \
 		      pthread_setattr_default_np pthread_getattr_default_np \
-		      thrd_create thrd_detach thrd_exit thrd_join \
-		      mtx_destroy mtx_init mtx_lock mtx_timedlock \
-		      mtx_trylock mtx_unlock call_once cnd_broadcast \
-		      cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait \
-		      tss_create tss_delete tss_get tss_set pthread_mutex_conf \
+		      pthread_mutex_conf \
 		      libpthread-compat
 #		      pthread_setuid pthread_seteuid pthread_setreuid \
 #		      pthread_setresuid \
@@ -319,9 +314,6 @@  tests = tst-attr1 tst-attr2 tst-attr3 tst-default-attr \
 	tst-robust-fork tst-create-detached tst-memstream \
 	tst-thread-exit-clobber tst-minstack-cancel tst-minstack-exit \
 	tst-minstack-throw \
-	tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
-	tst-cnd-timedwait tst-thrd-detach tst-mtx-basic tst-thrd-sleep \
-	tst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock \
 	tst-rwlock-pwn \
 	tst-rwlock-tryrdlock-stall tst-rwlock-trywrlock-stall \
 	tst-unwind-thread
diff --git a/sysdeps/htl/pt-mutex-destroy.c b/sysdeps/htl/pt-mutex-destroy.c
index 796fc11b8d..6a3b5be874 100644
--- a/sysdeps/htl/pt-mutex-destroy.c
+++ b/sysdeps/htl/pt-mutex-destroy.c
@@ -36,3 +36,4 @@  __pthread_mutex_destroy (pthread_mutex_t *mutex)
 }
 
 strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy);
+hidden_def (__pthread_mutex_destroy)
diff --git a/sysdeps/htl/pt-mutex-timedlock.c b/sysdeps/htl/pt-mutex-timedlock.c
index 0e50f38ef2..81013984a6 100644
--- a/sysdeps/htl/pt-mutex-timedlock.c
+++ b/sysdeps/htl/pt-mutex-timedlock.c
@@ -195,3 +195,4 @@  __pthread_mutex_timedlock (struct __pthread_mutex *mutex,
   return __pthread_mutex_timedlock_internal (mutex, abstime);
 }
 strong_alias (__pthread_mutex_timedlock, pthread_mutex_timedlock)
+hidden_def (__pthread_mutex_timedlock)
diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h
index fc8c9bc591..fd1e697e39 100644
--- a/sysdeps/htl/pthreadP.h
+++ b/sysdeps/htl/pthreadP.h
@@ -91,6 +91,8 @@  hidden_proto (__pthread_key_create)
 hidden_proto (__pthread_getspecific)
 hidden_proto (__pthread_setspecific)
 hidden_proto (__pthread_mutex_init)
+hidden_proto (__pthread_mutex_destroy)
+hidden_proto (__pthread_mutex_timedlock)
 #endif
 
 #define ASSERT_TYPE_SIZE(type, size) 					\
diff --git a/sysdeps/htl/thrd_current.c b/sysdeps/htl/thrd_current.c
new file mode 100644
index 0000000000..efc0d11b5d
--- /dev/null
+++ b/sysdeps/htl/thrd_current.c
@@ -0,0 +1,31 @@ 
+/* C11 threads current thread implementation.
+   Copyright (C) 2018-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 "thrd_priv.h"
+
+#pragma weak __pthread_self
+#pragma weak __pthread_threads
+
+thrd_t
+thrd_current (void)
+{
+  if (__pthread_threads)
+    return (thrd_t) __pthread_self ();
+
+  return (thrd_t) 0;
+}
diff --git a/sysdeps/htl/threads.h b/sysdeps/htl/threads.h
deleted file mode 100644
index 3c04fbcc79..0000000000
--- a/sysdeps/htl/threads.h
+++ /dev/null
@@ -1 +0,0 @@ 
-#error "HTL does not implement ISO C threads"
diff --git a/sysdeps/hurd/stdc-predef.h b/sysdeps/hurd/stdc-predef.h
deleted file mode 100644
index a7bb5f7c5f..0000000000
--- a/sysdeps/hurd/stdc-predef.h
+++ /dev/null
@@ -1,63 +0,0 @@ 
-/* Copyright (C) 2018-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/>.  */
-
-#ifndef	_STDC_PREDEF_H
-#define	_STDC_PREDEF_H	1
-
-/* This header is separate from features.h so that the compiler can
-   include it implicitly at the start of every compilation.  It must
-   not itself include <features.h> or any other header that includes
-   <features.h> because the implicit include comes before any feature
-   test macros that may be defined in a source file before it first
-   explicitly includes a system header.  GCC knows the name of this
-   header in order to preinclude it.  */
-
-/* glibc's intent is to support the IEC 559 math functionality, real
-   and complex.  If the GCC (4.9 and later) predefined macros
-   specifying compiler intent are available, use them to determine
-   whether the overall intent is to support these features; otherwise,
-   presume an older compiler has intent to support these features and
-   define these macros by default.  */
-
-#ifdef __GCC_IEC_559
-# if __GCC_IEC_559 > 0
-#  define __STDC_IEC_559__		1
-# endif
-#else
-# define __STDC_IEC_559__		1
-#endif
-
-#ifdef __GCC_IEC_559_COMPLEX
-# if __GCC_IEC_559_COMPLEX > 0
-#  define __STDC_IEC_559_COMPLEX__	1
-# endif
-#else
-# define __STDC_IEC_559_COMPLEX__	1
-#endif
-
-/* wchar_t uses Unicode 10.0.0.  Version 10.0 of the Unicode Standard is
-   synchronized with ISO/IEC 10646:2017, fifth edition, plus
-   the following additions from Amendment 1 to the fifth edition:
-   - 56 emoji characters
-   - 285 hentaigana
-   - 3 additional Zanabazar Square characters */
-#define __STDC_ISO_10646__		201706L
-
-/* We do not support C11 <threads.h>.  */
-#define __STDC_NO_THREADS__		1
-
-#endif
diff --git a/sysdeps/mach/htl/thrd_yield.c b/sysdeps/mach/htl/thrd_yield.c
new file mode 100644
index 0000000000..09e218cf2e
--- /dev/null
+++ b/sysdeps/mach/htl/thrd_yield.c
@@ -0,0 +1,26 @@ 
+/* sched_yield -- yield the processor.  Mach version.
+   Copyright (C) 2000-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 <mach.h>
+#include "thrd_priv.h"
+
+void
+thrd_yield (void)
+{
+  (void) __swtch ();
+}
diff --git a/sysdeps/mach/hurd/htl/pt-mutex-destroy.c b/sysdeps/mach/hurd/htl/pt-mutex-destroy.c
index a8a0adc03f..a5bfaddcb2 100644
--- a/sysdeps/mach/hurd/htl/pt-mutex-destroy.c
+++ b/sysdeps/mach/hurd/htl/pt-mutex-destroy.c
@@ -35,3 +35,4 @@  __pthread_mutex_destroy (pthread_mutex_t *mtxp)
 }
 
 strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy)
+hidden_def (__pthread_mutex_destroy)
diff --git a/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c b/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c
index e83bc57875..3aa7d798b2 100644
--- a/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c
+++ b/sysdeps/mach/hurd/htl/pt-mutex-timedlock.c
@@ -77,3 +77,4 @@  __pthread_mutex_timedlock (pthread_mutex_t *mtxp, const struct timespec *tsp)
   return ret;
 }
 strong_alias (__pthread_mutex_timedlock, pthread_mutex_timedlock)
+hidden_def (__pthread_mutex_timedlock)
diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist
index 7c2cb2b05a..dd0d3c7317 100644
--- a/sysdeps/mach/hurd/i386/libc.abilist
+++ b/sysdeps/mach/hurd/i386/libc.abilist
@@ -2181,6 +2181,10 @@  GLIBC_2.3.4 setsourcefilter F
 GLIBC_2.3.4 xdr_quad_t F
 GLIBC_2.3.4 xdr_u_quad_t F
 GLIBC_2.30 twalk_r F
+GLIBC_2.32 thrd_current F
+GLIBC_2.32 thrd_equal F
+GLIBC_2.32 thrd_sleep F
+GLIBC_2.32 thrd_yield F
 GLIBC_2.4 __confstr_chk F
 GLIBC_2.4 __fgets_chk F
 GLIBC_2.4 __fgets_unlocked_chk F
diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist
index cda8755960..0b90f9bf63 100644
--- a/sysdeps/mach/hurd/i386/libpthread.abilist
+++ b/sysdeps/mach/hurd/i386/libpthread.abilist
@@ -147,3 +147,24 @@  GLIBC_2.2.6 __errno_location F
 GLIBC_2.2.6 __h_errno_location F
 GLIBC_2.21 pthread_hurd_cond_timedwait_np F
 GLIBC_2.21 pthread_hurd_cond_wait_np F
+GLIBC_2.32 call_once F
+GLIBC_2.32 cnd_broadcast F
+GLIBC_2.32 cnd_destroy F
+GLIBC_2.32 cnd_init F
+GLIBC_2.32 cnd_signal F
+GLIBC_2.32 cnd_timedwait F
+GLIBC_2.32 cnd_wait F
+GLIBC_2.32 mtx_destroy F
+GLIBC_2.32 mtx_init F
+GLIBC_2.32 mtx_lock F
+GLIBC_2.32 mtx_timedlock F
+GLIBC_2.32 mtx_trylock F
+GLIBC_2.32 mtx_unlock F
+GLIBC_2.32 thrd_create F
+GLIBC_2.32 thrd_detach F
+GLIBC_2.32 thrd_exit F
+GLIBC_2.32 thrd_join F
+GLIBC_2.32 tss_create F
+GLIBC_2.32 tss_delete F
+GLIBC_2.32 tss_get F
+GLIBC_2.32 tss_set F
diff --git a/sysdeps/nptl/thrd_create.c b/sysdeps/nptl/thrd_create.c
new file mode 100644
index 0000000000..a9219db7bc
--- /dev/null
+++ b/sysdeps/nptl/thrd_create.c
@@ -0,0 +1,2 @@ 
+#define __pthread_create __pthread_create_2_1
+#include "../pthread/thrd_create.c"
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index 7f9eadd0e2..889f10d8b1 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -25,3 +25,21 @@  $(objpfx)tst-timer: $(objpfx)librt.a $(static-thread-library)
 endif
 
 endif
+
+ifneq (,$(filter $(subdir),htl nptl))
+headers += threads.h
+
+routines += thrd_current thrd_equal thrd_sleep thrd_yield
+
+libpthread-routines += thrd_create thrd_detach thrd_exit thrd_join \
+		       call_once \
+		       mtx_destroy mtx_init mtx_lock mtx_timedlock \
+		       mtx_trylock mtx_unlock \
+		       cnd_broadcast \
+		       cnd_destroy cnd_init cnd_signal cnd_timedwait cnd_wait \
+		       tss_create tss_delete tss_get tss_set
+
+tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
+	 tst-cnd-timedwait tst-thrd-detach tst-mtx-basic tst-thrd-sleep \
+	 tst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock
+endif
diff --git a/nptl/call_once.c b/sysdeps/pthread/call_once.c
similarity index 100%
rename from nptl/call_once.c
rename to sysdeps/pthread/call_once.c
diff --git a/nptl/cnd_broadcast.c b/sysdeps/pthread/cnd_broadcast.c
similarity index 100%
rename from nptl/cnd_broadcast.c
rename to sysdeps/pthread/cnd_broadcast.c
diff --git a/nptl/cnd_destroy.c b/sysdeps/pthread/cnd_destroy.c
similarity index 100%
rename from nptl/cnd_destroy.c
rename to sysdeps/pthread/cnd_destroy.c
diff --git a/nptl/cnd_init.c b/sysdeps/pthread/cnd_init.c
similarity index 100%
rename from nptl/cnd_init.c
rename to sysdeps/pthread/cnd_init.c
diff --git a/nptl/cnd_signal.c b/sysdeps/pthread/cnd_signal.c
similarity index 100%
rename from nptl/cnd_signal.c
rename to sysdeps/pthread/cnd_signal.c
diff --git a/nptl/cnd_timedwait.c b/sysdeps/pthread/cnd_timedwait.c
similarity index 100%
rename from nptl/cnd_timedwait.c
rename to sysdeps/pthread/cnd_timedwait.c
diff --git a/nptl/cnd_wait.c b/sysdeps/pthread/cnd_wait.c
similarity index 100%
rename from nptl/cnd_wait.c
rename to sysdeps/pthread/cnd_wait.c
diff --git a/nptl/mtx_destroy.c b/sysdeps/pthread/mtx_destroy.c
similarity index 100%
rename from nptl/mtx_destroy.c
rename to sysdeps/pthread/mtx_destroy.c
diff --git a/nptl/mtx_init.c b/sysdeps/pthread/mtx_init.c
similarity index 100%
rename from nptl/mtx_init.c
rename to sysdeps/pthread/mtx_init.c
diff --git a/nptl/mtx_lock.c b/sysdeps/pthread/mtx_lock.c
similarity index 100%
rename from nptl/mtx_lock.c
rename to sysdeps/pthread/mtx_lock.c
diff --git a/nptl/mtx_timedlock.c b/sysdeps/pthread/mtx_timedlock.c
similarity index 100%
rename from nptl/mtx_timedlock.c
rename to sysdeps/pthread/mtx_timedlock.c
diff --git a/nptl/mtx_trylock.c b/sysdeps/pthread/mtx_trylock.c
similarity index 100%
rename from nptl/mtx_trylock.c
rename to sysdeps/pthread/mtx_trylock.c
diff --git a/nptl/mtx_unlock.c b/sysdeps/pthread/mtx_unlock.c
similarity index 100%
rename from nptl/mtx_unlock.c
rename to sysdeps/pthread/mtx_unlock.c
diff --git a/nptl/thrd_create.c b/sysdeps/pthread/thrd_create.c
similarity index 91%
rename from nptl/thrd_create.c
rename to sysdeps/pthread/thrd_create.c
index fe08e22973..25af955419 100644
--- a/nptl/thrd_create.c
+++ b/sysdeps/pthread/thrd_create.c
@@ -24,7 +24,7 @@  thrd_create (thrd_t *thr, thrd_start_t func, void *arg)
   _Static_assert (sizeof (*thr) == sizeof (pthread_t),
 		  "sizeof (*thr) != sizeof (pthread_t)");
 
-  int err_code = __pthread_create_2_1 (thr, ATTR_C11_THREAD,
-				       (void* (*) (void*))func, arg);
+  int err_code = __pthread_create (thr, ATTR_C11_THREAD,
+				   (void* (*) (void*))func, arg);
   return thrd_err_map (err_code);
 }
diff --git a/nptl/thrd_detach.c b/sysdeps/pthread/thrd_detach.c
similarity index 100%
rename from nptl/thrd_detach.c
rename to sysdeps/pthread/thrd_detach.c
diff --git a/nptl/thrd_equal.c b/sysdeps/pthread/thrd_equal.c
similarity index 100%
rename from nptl/thrd_equal.c
rename to sysdeps/pthread/thrd_equal.c
diff --git a/nptl/thrd_exit.c b/sysdeps/pthread/thrd_exit.c
similarity index 100%
rename from nptl/thrd_exit.c
rename to sysdeps/pthread/thrd_exit.c
diff --git a/nptl/thrd_join.c b/sysdeps/pthread/thrd_join.c
similarity index 100%
rename from nptl/thrd_join.c
rename to sysdeps/pthread/thrd_join.c
diff --git a/nptl/thrd_priv.h b/sysdeps/pthread/thrd_priv.h
similarity index 100%
rename from nptl/thrd_priv.h
rename to sysdeps/pthread/thrd_priv.h
diff --git a/nptl/thrd_sleep.c b/sysdeps/pthread/thrd_sleep.c
similarity index 100%
rename from nptl/thrd_sleep.c
rename to sysdeps/pthread/thrd_sleep.c
diff --git a/sysdeps/nptl/threads.h b/sysdeps/pthread/threads.h
similarity index 100%
rename from sysdeps/nptl/threads.h
rename to sysdeps/pthread/threads.h
diff --git a/nptl/tss_create.c b/sysdeps/pthread/tss_create.c
similarity index 100%
rename from nptl/tss_create.c
rename to sysdeps/pthread/tss_create.c
diff --git a/nptl/tss_delete.c b/sysdeps/pthread/tss_delete.c
similarity index 100%
rename from nptl/tss_delete.c
rename to sysdeps/pthread/tss_delete.c
diff --git a/nptl/tss_get.c b/sysdeps/pthread/tss_get.c
similarity index 100%
rename from nptl/tss_get.c
rename to sysdeps/pthread/tss_get.c
diff --git a/nptl/tss_set.c b/sysdeps/pthread/tss_set.c
similarity index 100%
rename from nptl/tss_set.c
rename to sysdeps/pthread/tss_set.c
diff --git a/nptl/tst-call-once.c b/sysdeps/pthread/tst-call-once.c
similarity index 100%
rename from nptl/tst-call-once.c
rename to sysdeps/pthread/tst-call-once.c
diff --git a/nptl/tst-cnd-basic.c b/sysdeps/pthread/tst-cnd-basic.c
similarity index 100%
rename from nptl/tst-cnd-basic.c
rename to sysdeps/pthread/tst-cnd-basic.c
diff --git a/nptl/tst-cnd-broadcast.c b/sysdeps/pthread/tst-cnd-broadcast.c
similarity index 100%
rename from nptl/tst-cnd-broadcast.c
rename to sysdeps/pthread/tst-cnd-broadcast.c
diff --git a/nptl/tst-cnd-timedwait.c b/sysdeps/pthread/tst-cnd-timedwait.c
similarity index 100%
rename from nptl/tst-cnd-timedwait.c
rename to sysdeps/pthread/tst-cnd-timedwait.c
diff --git a/nptl/tst-mtx-basic.c b/sysdeps/pthread/tst-mtx-basic.c
similarity index 100%
rename from nptl/tst-mtx-basic.c
rename to sysdeps/pthread/tst-mtx-basic.c
diff --git a/nptl/tst-mtx-recursive.c b/sysdeps/pthread/tst-mtx-recursive.c
similarity index 100%
rename from nptl/tst-mtx-recursive.c
rename to sysdeps/pthread/tst-mtx-recursive.c
diff --git a/nptl/tst-mtx-timedlock.c b/sysdeps/pthread/tst-mtx-timedlock.c
similarity index 100%
rename from nptl/tst-mtx-timedlock.c
rename to sysdeps/pthread/tst-mtx-timedlock.c
diff --git a/nptl/tst-mtx-trylock.c b/sysdeps/pthread/tst-mtx-trylock.c
similarity index 100%
rename from nptl/tst-mtx-trylock.c
rename to sysdeps/pthread/tst-mtx-trylock.c
diff --git a/nptl/tst-thrd-detach.c b/sysdeps/pthread/tst-thrd-detach.c
similarity index 100%
rename from nptl/tst-thrd-detach.c
rename to sysdeps/pthread/tst-thrd-detach.c
diff --git a/nptl/tst-thrd-sleep.c b/sysdeps/pthread/tst-thrd-sleep.c
similarity index 100%
rename from nptl/tst-thrd-sleep.c
rename to sysdeps/pthread/tst-thrd-sleep.c
diff --git a/nptl/tst-tss-basic.c b/sysdeps/pthread/tst-tss-basic.c
similarity index 100%
rename from nptl/tst-tss-basic.c
rename to sysdeps/pthread/tst-tss-basic.c