public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/6] Move mutex and condition variable definition to common header
  2017-03-21 13:40 [PATCH v3 0/6] Add support for ISO C11 threads.h Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2017-03-21 13:40 ` [PATCH 3/6] Clean pthread functions namespaces for C11 threads Adhemerval Zanella
@ 2017-03-21 13:40 ` Adhemerval Zanella
  2017-03-22 22:59   ` Ivo Raisr
  2017-03-27 13:43   ` Torvald Riegel
  2017-03-21 13:40 ` [PATCH 5/6] Add test cases for ISO C11 threads Adhemerval Zanella
  2017-03-21 16:25 ` [PATCH v3 0/6] Add support for ISO C11 threads.h Joseph Myers
  6 siblings, 2 replies; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-21 13:40 UTC (permalink / raw)
  To: libc-alpha

This patch sorts out pthread_mutex_t and pthread_cond_t in new files,
so new C11 types could be based on pthread types without corrupting
namespaces and exposing pthread symbols.

Common pthread types like pthread_mutex_t and pthread_cond_t are now
defined in arch specific bits/pthreadtypes-common.h headers, while the
internal implementation is moved to bits/thread-shared-types.h.  File
pthreadtypes.h is cleaned up of those definitions and some related macros
and structures.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, hppa-linux-gnu, i386-linux-gnu, ia64-linux-gnu,
m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

	Adhemerval Zanella  <adhemerval.zanella@linaro.org>
	Juan Manuel Torres Palma  <jmtorrespalma@gmail.com>

	* posix/Makefile (headers): Add files bits/pthreadtypes-common.h
	and bits/thread-shared-types.h to this variable.
	* bits/pthreadtypes-common.h: New file.
	* bits/thread-shared-types.: Likewise.
	* sysdeps/aarch64/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/alpha/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/arm/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/hppa/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/ia64/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/m68k/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/microblaze/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/mips/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/nios2/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/powerpc/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/s390/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/sh/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/sparc/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/tile/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/x86/nptl/bits/thread-shared-types.h: Likewise.
	* sysdeps/aarch64/nptl/bits/pthreadtypes.h: Move mutex and condition
	variable definition to platform specific thread-shared-types header.
	* sysdeps/alpha/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/arm/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/hppa/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/ia64/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/m68k/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/microblaze/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/mips/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/nios2/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/powerpc/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/s390/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/sh/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/sparc/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/tile/nptl/bits/pthreadtypes.h: Likewise.
	* sysdeps/x86/nptl/bits/pthreadtypes.h: Likewise.
---
 ChangeLog                                          |  39 ++++++
 bits/thread-shared-types.h                         |  36 ++++++
 posix/Makefile                                     |   3 +-
 sysdeps/aarch64/nptl/bits/pthreadtypes.h           |  67 +---------
 sysdeps/aarch64/nptl/bits/thread-shared-types.h    |  94 ++++++++++++++
 sysdeps/alpha/nptl/bits/pthreadtypes.h             |  63 +---------
 sysdeps/alpha/nptl/bits/thread-shared-types.h      |  90 ++++++++++++++
 sysdeps/arm/nptl/bits/pthreadtypes.h               |  67 +---------
 sysdeps/arm/nptl/bits/thread-shared-types.h        |  92 ++++++++++++++
 sysdeps/hppa/nptl/bits/pthreadtypes.h              |  83 +------------
 sysdeps/hppa/nptl/bits/thread-shared-types.h       | 102 +++++++++++++++
 sysdeps/ia64/nptl/bits/pthreadtypes.h              |  67 +---------
 sysdeps/ia64/nptl/bits/thread-shared-types.h       |  92 ++++++++++++++
 sysdeps/m68k/nptl/bits/pthreadtypes.h              |  68 +---------
 sysdeps/m68k/nptl/bits/thread-shared-types.h       |  97 +++++++++++++++
 sysdeps/microblaze/nptl/bits/pthreadtypes.h        |  61 +--------
 sysdeps/microblaze/nptl/bits/thread-shared-types.h |  93 ++++++++++++++
 sysdeps/mips/nptl/bits/pthreadtypes.h              |  83 +------------
 sysdeps/mips/nptl/bits/thread-shared-types.h       | 114 +++++++++++++++++
 sysdeps/nios2/nptl/bits/pthreadtypes.h             |  67 +---------
 sysdeps/nios2/nptl/bits/thread-shared-types.h      |  90 ++++++++++++++
 sysdeps/nptl/bits/pthreadtypes-common.h            |  44 +++++++
 sysdeps/powerpc/nptl/bits/pthreadtypes.h           | 100 +--------------
 sysdeps/powerpc/nptl/bits/thread-shared-types.h    | 118 ++++++++++++++++++
 sysdeps/s390/nptl/bits/pthreadtypes.h              | 103 +---------------
 sysdeps/s390/nptl/bits/thread-shared-types.h       | 137 +++++++++++++++++++++
 sysdeps/sh/nptl/bits/pthreadtypes.h                |  63 +---------
 sysdeps/sh/nptl/bits/thread-shared-types.h         |  94 ++++++++++++++
 sysdeps/sparc/nptl/bits/pthreadtypes.h             |  82 +-----------
 sysdeps/sparc/nptl/bits/thread-shared-types.h      | 115 +++++++++++++++++
 sysdeps/tile/nptl/bits/pthreadtypes.h              |  95 +-------------
 sysdeps/tile/nptl/bits/thread-shared-types.h       | 114 +++++++++++++++++
 sysdeps/x86/nptl/bits/pthreadtypes.h               | 104 +---------------
 sysdeps/x86/nptl/bits/thread-shared-types.h        | 117 ++++++++++++++++++
 34 files changed, 1710 insertions(+), 1144 deletions(-)
 create mode 100644 bits/thread-shared-types.h
 create mode 100644 sysdeps/aarch64/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/alpha/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/arm/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/hppa/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/ia64/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/m68k/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/microblaze/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/mips/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/nios2/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/nptl/bits/pthreadtypes-common.h
 create mode 100644 sysdeps/powerpc/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/s390/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/sh/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/sparc/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/tile/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/x86/nptl/bits/thread-shared-types.h

diff --git a/bits/thread-shared-types.h b/bits/thread-shared-types.h
new file mode 100644
index 0000000..98f2084
--- /dev/null
+++ b/bits/thread-shared-types.h
@@ -0,0 +1,36 @@
+/* Common thread definition for pthread and c11 threads.  Generic version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This file is required to have a shared types definition
+   between POSIX threads and C11 threads. It allows to
+   header files like pthread.h and thread.h to define their types
+   with the same size and fields without corrupting namespaces.
+
+   The interface is as follows:
+
+   - bits/thread-shared-types.h. Defines structures for mutex and condvar,
+     shared by threads.h and pthread.h. The macros defined are
+     __PTHREAD_MUTEX_T_CONTENT and __PTHREAD_COND_T_CONTENT
+
+   - bits/pthreadtypes-common.h. Works as a generic file that defines
+     common pthread types like pthread_mutex_t and pthread_cond_t
+     based on the macros included from thread-shared-types.h.
+
+   - bits/pthreadtypes.h. Include pthreadtypes-common.h to have access
+     to pthread types and expose them for the other types and functions
+     that require it. */
diff --git a/posix/Makefile b/posix/Makefile
index ae17646..2dcc3ae 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -29,7 +29,8 @@ headers	:= sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h	      \
 	   bits/local_lim.h tar.h bits/utsname.h bits/confname.h	      \
 	   bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h	      \
 	   bits/sched.h re_comp.h wait.h bits/environments.h cpio.h	      \
-	   spawn.h bits/unistd.h
+	   spawn.h bits/unistd.h 					      \
+	   bits/thread-shared-types.h bits/pthreadtypes-common.h
 
 routines :=								      \
 	uname								      \
diff --git a/sysdeps/aarch64/nptl/bits/pthreadtypes.h b/sysdeps/aarch64/nptl/bits/pthreadtypes.h
index 97d9407..3384e42 100644
--- a/sysdeps/aarch64/nptl/bits/pthreadtypes.h
+++ b/sysdeps/aarch64/nptl/bits/pthreadtypes.h
@@ -20,12 +20,11 @@
 #define _BITS_PTHREADTYPES_H	1
 
 #include <endian.h>
+#include <bits/pthreadtypes-common.h>
 
 #ifdef __ILP32__
 # define __SIZEOF_PTHREAD_ATTR_T        32
-# define __SIZEOF_PTHREAD_MUTEX_T       32
 # define __SIZEOF_PTHREAD_MUTEXATTR_T    4
-# define __SIZEOF_PTHREAD_COND_T        48
 # define __SIZEOF_PTHREAD_COND_COMPAT_T 48
 # define __SIZEOF_PTHREAD_CONDATTR_T     4
 # define __SIZEOF_PTHREAD_RWLOCK_T      48
@@ -34,9 +33,7 @@
 # define __SIZEOF_PTHREAD_BARRIERATTR_T  4
 #else
 # define __SIZEOF_PTHREAD_ATTR_T        64
-# define __SIZEOF_PTHREAD_MUTEX_T       48
 # define __SIZEOF_PTHREAD_MUTEXATTR_T    8
-# define __SIZEOF_PTHREAD_COND_T        48
 # define __SIZEOF_PTHREAD_COND_COMPAT_T 48
 # define __SIZEOF_PTHREAD_CONDATTR_T     8
 # define __SIZEOF_PTHREAD_RWLOCK_T      56
@@ -62,36 +59,6 @@ typedef union pthread_attr_t pthread_attr_t;
 # define __have_pthread_attr_t1
 #endif
 
-typedef struct __pthread_internal_list
-{
-  struct __pthread_internal_list *__prev;
-  struct __pthread_internal_list *__next;
-} __pthread_list_t;
-
-
-/* Data structures for mutex handling.  The structure of the attribute
-   type is not exposed on purpose.  */
-typedef union
-{
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-    unsigned int __nusers;
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-    int __spins;
-    __pthread_list_t __list;
-#define __PTHREAD_MUTEX_HAVE_PREV	1
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
-/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#define __PTHREAD_SPINS 0
 
 typedef union
 {
@@ -100,38 +67,6 @@ typedef union
 } pthread_mutexattr_t;
 
 
-/* Data structure for conditional variable handling.  The structure of
-   the attribute type is not exposed on purpose.  */
-typedef union
-{
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
diff --git a/sysdeps/aarch64/nptl/bits/thread-shared-types.h b/sysdeps/aarch64/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..bb361d7
--- /dev/null
+++ b/sysdeps/aarch64/nptl/bits/thread-shared-types.h
@@ -0,0 +1,94 @@
+/* Common thread definition for pthread and c11 threads.  Linux/AArch64
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for the declaration of
+   pthread_mutex_t and pthread_cond_t, both needed by C11 types mtx_t and
+   cnd_t. */
+
+#ifndef _BITS_PTHREAD_SHARED_TYPES_H
+# define _BITS_PTHREAD_SHARED_TYPES_H	1
+
+#ifdef __ILP32__
+# define __SIZEOF_PTHREAD_MUTEX_T       32
+#else
+# define __SIZEOF_PTHREAD_MUTEX_T       48
+#endif
+#define __SIZEOF_PTHREAD_COND_T         48
+
+typedef struct __pthread_internal_list
+{
+  struct __pthread_internal_list *__prev;
+  struct __pthread_internal_list *__next;
+} __pthread_list_t;
+
+#define __PTHREAD_MUTEX_HAVE_PREV	1
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+/* Data structure for mutex handling. */
+
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+  unsigned int __nusers;
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility.  */
+  int __kind;
+  short __spins;
+  __pthread_list_t __list;
+};
+
+#define __PTHREAD_MUTEX_T_CONTENT		\
+  struct __pthread_mutex_s __data;		\
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];	\
+  long int __align;
+
+
+/* Data structure for conditional variable handling */
+#define __PTHREAD_COND_T_CONTENT                          	\
+  struct							\
+  {								\
+    __extension__ union						\
+    { 								\
+      __extension__ unsigned long long int __wseq;		\
+      struct {							\
+        unsigned int __low;					\
+        unsigned int __high;					\
+      } __wseq32;						\
+    };								\
+    __extension__ union						\
+    { 								\
+      __extension__ unsigned long long int __g1_start;		\
+      struct {							\
+        unsigned int __low;					\
+        unsigned int __high;					\
+      } __g1_start32;						\
+    };								\
+    unsigned int __g_refs[2];					\
+    unsigned int __g_size[2];					\
+    unsigned int __g1_orig_size;				\
+    unsigned int __wrefs;					\
+    unsigned int __g_signals[2];				\
+  } __data;							\
+  char __size[__SIZEOF_PTHREAD_COND_T];				\
+  __extension__ long long int __align;
+
+#endif
diff --git a/sysdeps/alpha/nptl/bits/pthreadtypes.h b/sysdeps/alpha/nptl/bits/pthreadtypes.h
index 1beaf10..9b2c7be 100644
--- a/sysdeps/alpha/nptl/bits/pthreadtypes.h
+++ b/sysdeps/alpha/nptl/bits/pthreadtypes.h
@@ -19,10 +19,10 @@
 #ifndef _BITS_PTHREADTYPES_H
 #define _BITS_PTHREADTYPES_H	1
 
+#include <bits/pthreadtypes-common.h>
+
 #define __SIZEOF_PTHREAD_ATTR_T		56
-#define __SIZEOF_PTHREAD_MUTEX_T	40
 #define __SIZEOF_PTHREAD_MUTEXATTR_T	4
-#define __SIZEOF_PTHREAD_COND_T		48
 #define __SIZEOF_PTHREAD_CONDATTR_T	4
 #define __SIZEOF_PTHREAD_RWLOCK_T	56
 #define __SIZEOF_PTHREAD_RWLOCKATTR_T	8
@@ -45,39 +45,10 @@ typedef union pthread_attr_t pthread_attr_t;
 # define __have_pthread_attr_t	1
 #endif
 
-typedef struct __pthread_internal_list
-{
-  struct __pthread_internal_list *__prev;
-  struct __pthread_internal_list *__next;
-} __pthread_list_t;
-
-
 /* Data structures for mutex handling.  The structure of the attribute
    type is deliberately not exposed.  */
 typedef union
 {
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-    unsigned int __nusers;
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-    int __spins;
-    __pthread_list_t __list;
-#define __PTHREAD_MUTEX_HAVE_PREV	1
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
-/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#define __PTHREAD_SPINS 0
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
   int __align;
 } pthread_mutexattr_t;
@@ -87,36 +58,6 @@ typedef union
    the attribute type is not exposed on purpose.  */
 typedef union
 {
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
   int __align;
 } pthread_condattr_t;
diff --git a/sysdeps/alpha/nptl/bits/thread-shared-types.h b/sysdeps/alpha/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..b3c8505
--- /dev/null
+++ b/sysdeps/alpha/nptl/bits/thread-shared-types.h
@@ -0,0 +1,90 @@
+/* Common thread definition for pthread and c11 threads.  Linux/alpha
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for the declaration of
+   pthread_mutex_t and pthread_cond_t, both needed by C11 types mtx_t and
+   cnd_t. */
+
+#ifndef _BITS_PTHREAD_SHARED_TYPES_H
+# define _BITS_PTHREAD_SHARED_TYPES_H	1
+
+#define __SIZEOF_PTHREAD_MUTEX_T 40
+#define __SIZEOF_PTHREAD_COND_T 48
+
+
+typedef struct __pthread_internal_list
+{
+  struct __pthread_internal_list *__prev;
+  struct __pthread_internal_list *__next;
+} __pthread_list_t;
+
+
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+  unsigned int __nusers;
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility with static initializers.  */
+  int __kind;
+  int __spins;
+  __pthread_list_t __list;
+#define __PTHREAD_MUTEX_HAVE_PREV	1
+};
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+#define __PTHREAD_MUTEX_T_CONTENT		\
+  struct __pthread_mutex_s  __data;		\
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];	\
+  long int __align;
+
+
+/* Data structure for conditional variable handling */
+#define __PTHREAD_COND_T_CONTENT			\
+  struct						\
+  {							\
+    __extension__ union					\
+    { 							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+#endif
diff --git a/sysdeps/arm/nptl/bits/pthreadtypes.h b/sysdeps/arm/nptl/bits/pthreadtypes.h
index dae7bc4..ece5d13 100644
--- a/sysdeps/arm/nptl/bits/pthreadtypes.h
+++ b/sysdeps/arm/nptl/bits/pthreadtypes.h
@@ -19,11 +19,10 @@
 #define _BITS_PTHREADTYPES_H	1
 
 #include <endian.h>
+#include <bits/pthreadtypes-common.h>
 
 #define __SIZEOF_PTHREAD_ATTR_T 36
-#define __SIZEOF_PTHREAD_MUTEX_T 24
 #define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-#define __SIZEOF_PTHREAD_COND_T 48
 #define __SIZEOF_PTHREAD_COND_COMPAT_T 12
 #define __SIZEOF_PTHREAD_CONDATTR_T 4
 #define __SIZEOF_PTHREAD_RWLOCK_T 32
@@ -48,38 +47,6 @@ typedef union pthread_attr_t pthread_attr_t;
 #endif
 
 
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-
-
-/* Data structures for mutex handling.  The structure of the attribute
-   type is not exposed on purpose.  */
-typedef union
-{
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-    unsigned int __nusers;
-    __extension__ union
-    {
-      int __spins;
-      __pthread_slist_t __list;
-    };
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
-/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#define __PTHREAD_SPINS 0
-
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
@@ -87,38 +54,6 @@ typedef union
 } pthread_mutexattr_t;
 
 
-/* Data structure for conditional variable handling.  The structure of
-   the attribute type is not exposed on purpose.  */
-typedef union
-{
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
diff --git a/sysdeps/arm/nptl/bits/thread-shared-types.h b/sysdeps/arm/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..2475792
--- /dev/null
+++ b/sysdeps/arm/nptl/bits/thread-shared-types.h
@@ -0,0 +1,92 @@
+/* Common thread definition for pthread and c11 threads.  Linux/arm
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for
+   the declaration of pthread_mutex_t and pthread_cond_t,
+   both needed by C11 types mtx_t and cnd_t. */
+
+#ifndef _BITS_THREAD_SHARED_TYPES_H
+# define _BITS_THREAD_SHARED_TYPES_H	1
+
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_COND_T 48
+
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+/* Data structure for mutex handling. */
+
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility.  */
+  int __kind;
+  unsigned int __nusers;
+  __extension__ union
+  {
+    int __spins;
+    __pthread_slist_t __list;
+  };
+};
+
+#define __PTHREAD_MUTEX_T_CONTENT         \
+  struct __pthread_mutex_s __data;        \
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];  \
+  long int __align;
+
+
+/* Data structure for conditional variable handling */
+
+#define __PTHREAD_COND_T_CONTENT                        \
+  struct						\
+  {							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    { 							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+#endif
diff --git a/sysdeps/hppa/nptl/bits/pthreadtypes.h b/sysdeps/hppa/nptl/bits/pthreadtypes.h
index e37111a..dd89e12 100644
--- a/sysdeps/hppa/nptl/bits/pthreadtypes.h
+++ b/sysdeps/hppa/nptl/bits/pthreadtypes.h
@@ -18,6 +18,8 @@
 #ifndef _BITS_PTHREADTYPES_H
 #define _BITS_PTHREADTYPES_H	1
 
+#include <bits/pthreadtypes-common.h>
+
 /* Linuxthread type sizes (bytes):
    sizeof(pthread_attr_t) = 0x24 (36)
    sizeof(pthread_barrier_t) = 0x30 (48)
@@ -33,9 +35,7 @@
 #define __SIZEOF_PTHREAD_ATTR_T 36
 #define __SIZEOF_PTHREAD_BARRIER_T 48
 #define __SIZEOF_PTHREAD_BARRIERATTR_T 4
-#define __SIZEOF_PTHREAD_COND_T 48
 #define __SIZEOF_PTHREAD_CONDATTR_T 4
-#define __SIZEOF_PTHREAD_MUTEX_T 48
 #define __SIZEOF_PTHREAD_MUTEXATTR_T 4
 #define __SIZEOF_PTHREAD_RWLOCK_T 64
 #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
@@ -55,48 +55,6 @@ typedef union pthread_attr_t pthread_attr_t;
 #endif
 
 
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-
-
-/* Data structures for mutex handling.  The structure of the attribute
-   type is not exposed on purpose.  */
-typedef union
-{
-  struct __pthread_mutex_s
-  {
-    int __lock __attribute__ ((__aligned__(16)));
-    unsigned int __count;
-    int __owner;
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-    /* The old 4-word 16-byte aligned lock. This is initalized
-       to all ones by the Linuxthreads PTHREAD_MUTEX_INITIALIZER.
-       Unused in NPTL.  */
-    int __compat_padding[4];
-    /* In the old structure there are 4 words left due to alignment.
-       In NPTL two words are used.  */
-    unsigned int __nusers;
-    __extension__ union
-    {
-      int __spins;
-      __pthread_slist_t __list;
-    };
-    /* Two more words are left before the NPTL
-       pthread_mutex_t is larger than Linuxthreads.  */
-    int __reserved1;
-    int __reserved2;
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
-/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#define __PTHREAD_SPINS 0
-
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
@@ -104,43 +62,6 @@ typedef union
 } pthread_mutexattr_t;
 
 
-/* Data structure for conditional variable handling.  The structure of
-   the attribute type is not exposed on purpose. However, this structure
-   is exposed via PTHREAD_COND_INITIALIZER, and because of this, the
-   Linuxthreads version sets the first four ints to one. In the NPTL
-   version we must check, in every function using pthread_cond_t,
-   for the static Linuxthreads initializer and clear the appropriate
-   words. */
-typedef union
-{
-  struct
-  {
-    /* In the old Linuxthreads pthread_cond_t, this is the
-       start of the 4-word lock structure, the next four words
-       are set all to 1 by the Linuxthreads
-       PTHREAD_COND_INITIALIZER.  */
-    int __lock __attribute__ ((__aligned__(16)));
-    /* Tracks the initialization of this structure:
-       0  initialized with NPTL PTHREAD_COND_INITIALIZER.
-       1  initialized with Linuxthreads PTHREAD_COND_INITIALIZER.
-       2  initialization in progress.  */
-    int __initializer;
-    unsigned int __futex;
-    void *__mutex;
-    /* In the old Linuxthreads this would have been the start
-       of the pthread_fastlock status word.  */
-    __extension__ unsigned long long int __total_seq;
-    __extension__ unsigned long long int __wakeup_seq;
-    __extension__ unsigned long long int __woken_seq;
-    unsigned int __nwaiters;
-    unsigned int __broadcast_seq;
-    /* The NPTL pthread_cond_t is exactly the same size as
-       the Linuxthreads version, there are no words to spare.  */
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
diff --git a/sysdeps/hppa/nptl/bits/thread-shared-types.h b/sysdeps/hppa/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..2a6d7d9
--- /dev/null
+++ b/sysdeps/hppa/nptl/bits/thread-shared-types.h
@@ -0,0 +1,102 @@
+/* Common thread definition for pthread and c11 threads.  Linux/HPPA
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for
+   the declaration of pthread_mutex_t and pthread_cond_t,
+   both needed by C11 types mtx_t and cnd_t. */
+
+#ifndef _BITS_THREAD_SHARED_TYPES_H
+# define _BITS_THREAD_SHARED_TYPES_H	1
+
+#define __SIZEOF_PTHREAD_MUTEX_T 48
+#define __SIZEOF_PTHREAD_COND_T 48
+
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+/* Data structure for mutex handling. */
+
+struct __pthread_mutex_s
+{
+  int __lock __attribute__ ((__aligned__(16)));
+  unsigned int __count;
+  int __owner;
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility.  */
+  int __kind;
+  /* The old 4-word 16-byte aligned lock. This is initalized
+     to all ones by the Linuxthreads PTHREAD_MUTEX_INITIALIZER.
+     Unused in NPTL.  */
+  int __compat_padding[4];
+  /* In the old structure there are 4 words left due to alignment.
+     In NPTL two words are used.  */
+  unsigned int __nusers;
+  __extension__ union
+  {
+    int __spins;
+    __pthread_slist_t __list;
+  };
+  /* Two more words are left before the NPTL
+     pthread_mutex_t is larger than Linuxthreads.  */
+  int __reserved1;
+  int __reserved2;
+};
+
+#define __PTHREAD_MUTEX_T_CONTENT         \
+  struct __pthread_mutex_s __data;        \
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];  \
+  long int __align;
+
+
+/* Data structure for conditional variable handling */
+
+#define __PTHREAD_COND_T_CONTENT          \
+  struct                                  \
+  {                                       \
+    /* In the old Linuxthreads pthread_cond_t, this is the
+       start of the 4-word lock structure, the next four words
+       are set all to 1 by the Linuxthreads
+       PTHREAD_COND_INITIALIZER.  */      \
+    int __lock __attribute__ ((__aligned__(16)));  \
+    /* Tracks the initialization of this structure:
+       0  initialized with NPTL PTHREAD_COND_INITIALIZER.
+       1  initialized with Linuxthreads PTHREAD_COND_INITIALIZER.
+       2  initialization in progress.  */ \
+    int __initializer;                    \
+    unsigned int __futex;                 \
+    void *__mutex;                        \
+    /* In the old Linuxthreads this would have been the start
+       of the pthread_fastlock status word.  */ \
+    __extension__ unsigned long long int __total_seq; \
+    __extension__ unsigned long long int __wakeup_seq; \
+    __extension__ unsigned long long int __woken_seq; \
+    unsigned int __nwaiters;              \
+    unsigned int __broadcast_seq;         \
+    /* The NPTL pthread_cond_t is exactly the same size as
+       the Linuxthreads version, there are no words to spare.  */ \
+  } __data;                               \
+  char __size[__SIZEOF_PTHREAD_COND_T];   \
+  __extension__ long long int __align;
+
+#endif
diff --git a/sysdeps/ia64/nptl/bits/pthreadtypes.h b/sysdeps/ia64/nptl/bits/pthreadtypes.h
index c67ee86..a34c9d6 100644
--- a/sysdeps/ia64/nptl/bits/pthreadtypes.h
+++ b/sysdeps/ia64/nptl/bits/pthreadtypes.h
@@ -19,10 +19,10 @@
 #ifndef _BITS_PTHREADTYPES_H
 #define _BITS_PTHREADTYPES_H	1
 
+#include <bits/pthreadtypes-common.h>
+
 #define __SIZEOF_PTHREAD_ATTR_T 56
-#define __SIZEOF_PTHREAD_MUTEX_T 40
 #define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-#define __SIZEOF_PTHREAD_COND_T 48
 #define __SIZEOF_PTHREAD_CONDATTR_T 4
 #define __SIZEOF_PTHREAD_RWLOCK_T 56
 #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
@@ -46,37 +46,6 @@ typedef union pthread_attr_t pthread_attr_t;
 #endif
 
 
-typedef struct __pthread_internal_list
-{
-  struct __pthread_internal_list *__prev;
-  struct __pthread_internal_list *__next;
-} __pthread_list_t;
-
-
-/* Data structures for mutex handling.  The structure of the attribute
-   type is not exposed on purpose.  */
-typedef union
-{
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-    unsigned int __nusers;
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-    int __spins;
-    __pthread_list_t __list;
-#define __PTHREAD_MUTEX_HAVE_PREV	1
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
-/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#define __PTHREAD_SPINS 0
-
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
@@ -84,38 +53,6 @@ typedef union
 } pthread_mutexattr_t;
 
 
-/* Data structure for conditional variable handling.  The structure of
-   the attribute type is not exposed on purpose.  */
-typedef union
-{
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
diff --git a/sysdeps/ia64/nptl/bits/thread-shared-types.h b/sysdeps/ia64/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..f318236
--- /dev/null
+++ b/sysdeps/ia64/nptl/bits/thread-shared-types.h
@@ -0,0 +1,92 @@
+/* Common thread definition for pthread and c11 threads.  Linux/IA64
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for
+   the declaration of pthread_mutex_t and pthread_cond_t,
+   both needed by C11 types mtx_t and cnd_t. */
+
+#ifndef _BITS_THREAD_SHARED_TYPES_H
+# define _BITS_THREAD_SHARED_TYPES_H	1
+
+#define __SIZEOF_PTHREAD_MUTEX_T 40
+#define __SIZEOF_PTHREAD_COND_T 48
+
+typedef struct __pthread_internal_list
+{
+  struct __pthread_internal_list *__prev;
+  struct __pthread_internal_list *__next;
+} __pthread_list_t;
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+/* Data structure for mutex handling. */
+
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+  unsigned int __nusers;
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility.  */
+  int __kind;
+  int __spins;
+  __pthread_list_t __list;
+#define __PTHREAD_MUTEX_HAVE_PREV	1
+};
+
+#define __PTHREAD_MUTEX_T_CONTENT             \
+  struct __pthread_mutex_s __data;            \
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];      \
+  long int __align;
+
+
+/* Data structure for conditional variable handling */
+
+#define __PTHREAD_COND_T_CONTENT                        \
+  struct						\
+  {							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    { 							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+
+#endif
diff --git a/sysdeps/m68k/nptl/bits/pthreadtypes.h b/sysdeps/m68k/nptl/bits/pthreadtypes.h
index 9a16bbf..a7fa6e7 100644
--- a/sysdeps/m68k/nptl/bits/pthreadtypes.h
+++ b/sysdeps/m68k/nptl/bits/pthreadtypes.h
@@ -20,11 +20,10 @@
 #define _BITS_PTHREADTYPES_H	1
 
 #include <endian.h>
+#include <bits/pthreadtypes-common.h>
 
 #define __SIZEOF_PTHREAD_ATTR_T 36
-#define __SIZEOF_PTHREAD_MUTEX_T 24
 #define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-#define __SIZEOF_PTHREAD_COND_T 48
 #define __SIZEOF_PTHREAD_CONDATTR_T 4
 #define __SIZEOF_PTHREAD_RWLOCK_T 32
 #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
@@ -48,38 +47,6 @@ typedef union pthread_attr_t pthread_attr_t;
 #endif
 
 
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-
-
-/* Data structures for mutex handling.  The structure of the attribute
-   type is deliberately not exposed.  */
-typedef union
-{
-  struct __pthread_mutex_s
-  {
-    int __lock __attribute__ ((__aligned__ (4)));
-    unsigned int __count;
-    int __owner;
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-    unsigned int __nusers;
-    __extension__ union
-    {
-      int __spins;
-      __pthread_slist_t __list;
-    };
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
-/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#define __PTHREAD_SPINS 0
-
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
@@ -87,39 +54,6 @@ typedef union
 } pthread_mutexattr_t;
 
 
-/* Data structure for conditional variable handling.  The structure of
-   the attribute type is not exposed on purpose.  */
-typedef union
-{
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    /* Enforce proper alignment of fields used as futex words.  */
-    unsigned int __g_refs[2] __attribute__ ((__aligned__ (4)));
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
diff --git a/sysdeps/m68k/nptl/bits/thread-shared-types.h b/sysdeps/m68k/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..ab6f05f
--- /dev/null
+++ b/sysdeps/m68k/nptl/bits/thread-shared-types.h
@@ -0,0 +1,97 @@
+/* Common thread definition for pthread and c11 threads.  Linux/m68k
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for
+   the declaration of pthread_mutex_t and pthread_cond_t,
+   both needed by C11 types mtx_t and cnd_t. */
+
+#ifndef _BITS_THREAD_SHARED_TYPES_H
+# define _BITS_THREAD_SHARED_TYPES_H	1
+
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_COND_T 48
+
+
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+/* Data structure for mutex handling. */
+
+struct __pthread_mutex_s
+{
+  int __lock __attribute__ ((__aligned__ (4)));
+  unsigned int __count;
+  int __owner;
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility.  */
+  int __kind;
+  unsigned int __nusers;
+  __extension__ union
+  {
+    int __spins;
+    __pthread_slist_t __list;
+  };
+};
+
+
+#define __PTHREAD_MUTEX_T_CONTENT         \
+  struct __pthread_mutex_s __data;        \
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];  \
+  long int __align;
+
+
+/* Data structure for conditional variable handling */
+
+/* Enforce proper alignment of field (starting from __g_refs) used as futex
+   words.  */
+#define __PTHREAD_COND_T_CONTENT					\
+  struct								\
+  { 									\
+    __extension__ union							\
+    {									\
+      __extension__ unsigned long long int __wseq;			\
+      struct {								\
+        unsigned int __low;						\
+        unsigned int __high;						\
+      } __wseq32;							\
+    };									\
+    __extension__ union							\
+    { 									\
+      __extension__ unsigned long long int __g1_start;			\
+      struct {								\
+        unsigned int __low;						\
+        unsigned int __high;						\
+      } __g1_start32;							\
+    };									\
+    unsigned int __g_refs[2] __attribute__ ((__aligned__ (4)));		\
+    unsigned int __g_size[2];						\
+    unsigned int __g1_orig_size;					\
+    unsigned int __wrefs;						\
+    unsigned int __g_signals[2];					\
+  } __data;								\
+  char __size[__SIZEOF_PTHREAD_COND_T];					\
+  __extension__ long long int __align;
+
+
+#endif
diff --git a/sysdeps/microblaze/nptl/bits/pthreadtypes.h b/sysdeps/microblaze/nptl/bits/pthreadtypes.h
index 7c5db6b..efa70c8 100644
--- a/sysdeps/microblaze/nptl/bits/pthreadtypes.h
+++ b/sysdeps/microblaze/nptl/bits/pthreadtypes.h
@@ -20,11 +20,10 @@
 # define _BITS_PTHREADTYPES_H	1
 
 # include <endian.h>
+# include <bits/pthreadtypes-common.h>
 
 # define __SIZEOF_PTHREAD_ATTR_T         36
-# define __SIZEOF_PTHREAD_MUTEX_T        24
 # define __SIZEOF_PTHREAD_MUTEXATTR_T     4
-# define __SIZEOF_PTHREAD_COND_T         48
 # define __SIZEOF_PTHREAD_COND_COMPAT_T  12
 # define __SIZEOF_PTHREAD_CONDATTR_T      4
 # define __SIZEOF_PTHREAD_RWLOCK_T       32
@@ -48,33 +47,6 @@ typedef union pthread_attr_t pthread_attr_t;
 #  define __have_pthread_attr_t	1
 # endif
 
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-
-/* Data structures for mutex handling.  The structure of the attribute
-   type is not exposed on purpose.  */
-typedef union
-{
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-    unsigned int __nusers;
-    __extension__ union
-    {
-      int __spins;
-      __pthread_slist_t __list;
-    };
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
 
 /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
 #define __PTHREAD_SPINS 0
@@ -85,37 +57,6 @@ typedef union
   int __align;
 } pthread_mutexattr_t;
 
-/* Data structure for conditional variable handling.  The structure of
-   the attribute type is not exposed on purpose.  */
-typedef union
-{
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
 
 typedef union
 {
diff --git a/sysdeps/microblaze/nptl/bits/thread-shared-types.h b/sysdeps/microblaze/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..91d14b6
--- /dev/null
+++ b/sysdeps/microblaze/nptl/bits/thread-shared-types.h
@@ -0,0 +1,93 @@
+/* Common thread definition for pthread and c11 threads.  Linux/microblaze
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for
+   the declaration of pthread_mutex_t and pthread_cond_t,
+   both needed by C11 types mtx_t and cnd_t. */
+
+#ifndef _BITS_THREAD_SHARED_TYPES_H
+#define _BITS_THREAD_SHARED_TYPES_H	1
+
+#define __SIZEOF_PTHREAD_MUTEX_T        24
+#define __SIZEOF_PTHREAD_COND_T         48
+
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+/* Data structure for mutex handling. */
+
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility.  */
+  int __kind;
+  unsigned int __nusers;
+  __extension__ union
+  {
+    int __spins;
+    __pthread_slist_t __list;
+  };
+};
+
+
+#define __PTHREAD_MUTEX_T_CONTENT         \
+  struct __pthread_mutex_s __data;        \
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];  \
+  long int __align;
+
+
+/* Data structure for conditional variable handling */
+
+#define __PTHREAD_COND_T_CONTENT			\
+  struct						\
+  {							\
+    __extension__ union					\
+    { 							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+#endif
diff --git a/sysdeps/mips/nptl/bits/pthreadtypes.h b/sysdeps/mips/nptl/bits/pthreadtypes.h
index b1ebf4e..51f04fe 100644
--- a/sysdeps/mips/nptl/bits/pthreadtypes.h
+++ b/sysdeps/mips/nptl/bits/pthreadtypes.h
@@ -20,12 +20,11 @@
 #define _BITS_PTHREADTYPES_H	1
 
 #include <endian.h>
+#include <bits/pthreadtypes-common.h>
 
 #if _MIPS_SIM == _ABI64
 # define __SIZEOF_PTHREAD_ATTR_T 56
-# define __SIZEOF_PTHREAD_MUTEX_T 40
 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
 # define __SIZEOF_PTHREAD_CONDATTR_T 4
 # define __SIZEOF_PTHREAD_RWLOCK_T 56
 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
@@ -33,9 +32,7 @@
 # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 #else
 # define __SIZEOF_PTHREAD_ATTR_T 36
-# define __SIZEOF_PTHREAD_MUTEX_T 24
 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
 # define __SIZEOF_PTHREAD_CONDATTR_T 4
 # define __SIZEOF_PTHREAD_RWLOCK_T 32
 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
@@ -60,52 +57,6 @@ typedef union pthread_attr_t pthread_attr_t;
 #endif
 
 
-#if _MIPS_SIM == _ABI64
-typedef struct __pthread_internal_list
-{
-  struct __pthread_internal_list *__prev;
-  struct __pthread_internal_list *__next;
-} __pthread_list_t;
-#else
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-#endif
-
-
-/* Data structures for mutex handling.  The structure of the attribute
-   type is deliberately not exposed.  */
-typedef union
-{
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-#if _MIPS_SIM == _ABI64
-    unsigned int __nusers;
-#endif
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-#if _MIPS_SIM == _ABI64
-    int __spins;
-    __pthread_list_t __list;
-# define __PTHREAD_MUTEX_HAVE_PREV	1
-#else
-    unsigned int __nusers;
-    __extension__ union
-    {
-      int __spins;
-      __pthread_slist_t __list;
-    };
-#endif
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
 /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
 #define __PTHREAD_SPINS 0
 
@@ -116,38 +67,6 @@ typedef union
 } pthread_mutexattr_t;
 
 
-/* Data structure for conditional variable handling.  The structure of
-   the attribute type is not exposed on purpose.  */
-typedef union
-{
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
diff --git a/sysdeps/mips/nptl/bits/thread-shared-types.h b/sysdeps/mips/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..a34b816
--- /dev/null
+++ b/sysdeps/mips/nptl/bits/thread-shared-types.h
@@ -0,0 +1,114 @@
+/* Common thread definition for pthread and c11 threads.  Linux/mips
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for
+   the declaration of pthread_mutex_t and pthread_cond_t,
+   both needed by C11 types mtx_t and cnd_t. */
+
+#ifndef _BITS_THREAD_SHARED_TYPES_H
+#define _BITS_THREAD_SHARED_TYPES_H	1
+
+#if _MIPS_SIM == _ABI64
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+# define __SIZEOF_PTHREAD_COND_T 48
+#else
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+# define __SIZEOF_PTHREAD_COND_T 48
+#endif
+
+#if _MIPS_SIM == _ABI64
+typedef struct __pthread_internal_list
+{
+  struct __pthread_internal_list *__prev;
+  struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+/* Data structures for mutex handling.  The structure of the attribute
+   type is deliberately not exposed.  */
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+#if _MIPS_SIM == _ABI64
+  unsigned int __nusers;
+#endif
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility with static initializers.  */
+  int __kind;
+#if _MIPS_SIM == _ABI64
+  int __spins;
+  __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV      1
+#else
+  unsigned int __nusers;
+  __extension__ union
+  {
+    int __spins;
+    __pthread_slist_t __list;
+  };
+#endif
+};
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+#define __PTHREAD_MUTEX_T_CONTENT   \
+  struct __pthread_mutex_s __data;        \
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];  \
+  long int __align;
+
+  
+/* Data structure for conditional variable handling.  The structure of
+   the attribute type is deliberately not exposed.  */
+#define __PTHREAD_COND_T_CONTENT			\
+  struct						\
+  { 							\
+    __extension__ union					\
+    { 							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+#endif
diff --git a/sysdeps/nios2/nptl/bits/pthreadtypes.h b/sysdeps/nios2/nptl/bits/pthreadtypes.h
index 8247013..4d0f413 100644
--- a/sysdeps/nios2/nptl/bits/pthreadtypes.h
+++ b/sysdeps/nios2/nptl/bits/pthreadtypes.h
@@ -20,11 +20,10 @@
 #define _BITS_PTHREADTYPES_H	1
 
 #include <endian.h>
+#include <bits/pthreadtypes-common.h>
 
 #define __SIZEOF_PTHREAD_ATTR_T 36
-#define __SIZEOF_PTHREAD_MUTEX_T 24
 #define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-#define __SIZEOF_PTHREAD_COND_T 48
 #define __SIZEOF_PTHREAD_CONDATTR_T 4
 #define __SIZEOF_PTHREAD_RWLOCK_T 32
 #define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
@@ -48,76 +47,12 @@ typedef union pthread_attr_t pthread_attr_t;
 #endif
 
 
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-
-
-/* Data structures for mutex handling.  The structure of the attribute
-   type is deliberately not exposed.  */
-typedef union
-{
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-    unsigned int __nusers;
-    __extension__ union
-    {
-      int __spins;
-      __pthread_slist_t __list;
-    };
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
 typedef union
 {
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
   long int __align;
 } pthread_mutexattr_t;
 
-/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#define __PTHREAD_SPINS 0
-
-
-/* Data structure for conditional variable handling.  The structure of
-   the attribute type is not exposed on purpose.  */
-typedef union
-{
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
 
 typedef union
 {
diff --git a/sysdeps/nios2/nptl/bits/thread-shared-types.h b/sysdeps/nios2/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..8904239
--- /dev/null
+++ b/sysdeps/nios2/nptl/bits/thread-shared-types.h
@@ -0,0 +1,90 @@
+/* Common thread definition for pthread and c11 threads.  Linux/nios2
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for
+   the declaration of pthread_mutex_t and pthread_cond_t,
+   both needed by C11 types mtx_t and cnd_t. */
+
+#ifndef _BITS_THREAD_SHARED_TYPES_H
+#define _BITS_THREAD_SHARED_TYPES_H	1
+
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_COND_T 48
+
+
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility with static initializers.  */
+  int __kind;
+  unsigned int __nusers;
+  __extension__ union
+  {
+    int __spins;
+    __pthread_slist_t __list;
+  };
+} __data;
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+#define __PTHREAD_MUTEX_T_CONTENT         \
+  struct __pthread_mutex_s __data;        \
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];  \
+  long int __align;
+
+/* Data structure for conditional variable handling */
+
+#define __PTHREAD_COND_T_CONTENT			\
+  struct						\
+  { 							\
+    __extension__ union					\
+    { 							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+#endif
diff --git a/sysdeps/nptl/bits/pthreadtypes-common.h b/sysdeps/nptl/bits/pthreadtypes-common.h
new file mode 100644
index 0000000..7905000
--- /dev/null
+++ b/sysdeps/nptl/bits/pthreadtypes-common.h
@@ -0,0 +1,44 @@
+/* Default pthread common types definitions.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+
+/* Declaration of common pthread types for all architectures.
+   Macros *_CONTENT are architecture dependent and defined in
+   bits/thread-shared-types.h */
+
+#ifndef _BITS_PTHREADTYPES_COMMON_H
+# define _BITS_PTHREADTYPES_COMMON_H	1
+
+#include <bits/thread-shared-types.h>
+
+/* Common definition of pthread_mutex_t. */
+
+typedef union
+{
+  __PTHREAD_MUTEX_T_CONTENT
+} pthread_mutex_t;
+
+
+/* Common definition of pthread_cond_t. */
+
+typedef union
+{
+  __PTHREAD_COND_T_CONTENT
+} pthread_cond_t;
+
+#endif
diff --git a/sysdeps/powerpc/nptl/bits/pthreadtypes.h b/sysdeps/powerpc/nptl/bits/pthreadtypes.h
index e5cda79..342bec9 100644
--- a/sysdeps/powerpc/nptl/bits/pthreadtypes.h
+++ b/sysdeps/powerpc/nptl/bits/pthreadtypes.h
@@ -20,28 +20,21 @@
 #define _BITS_PTHREADTYPES_H	1
 
 #include <bits/wordsize.h>
+#include <bits/pthreadtypes-common.h>
 
 #if __WORDSIZE == 64
 # define __SIZEOF_PTHREAD_ATTR_T 56
-# define __SIZEOF_PTHREAD_MUTEX_T 40
-# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
-# define __SIZEOF_PTHREAD_CONDATTR_T 4
 # define __SIZEOF_PTHREAD_RWLOCK_T 56
-# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
 # define __SIZEOF_PTHREAD_BARRIER_T 32
-# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 #else
 # define __SIZEOF_PTHREAD_ATTR_T 36
-# define __SIZEOF_PTHREAD_MUTEX_T 24
-# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
-# define __SIZEOF_PTHREAD_CONDATTR_T 4
 # define __SIZEOF_PTHREAD_RWLOCK_T 32
-# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
 # define __SIZEOF_PTHREAD_BARRIER_T 20
-# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 #endif
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 
 
 /* Thread identifiers.  The structure of the attribute type is
@@ -60,63 +53,10 @@ typedef union pthread_attr_t pthread_attr_t;
 #endif
 
 
-#if __WORDSIZE == 64
-typedef struct __pthread_internal_list
-{
-  struct __pthread_internal_list *__prev;
-  struct __pthread_internal_list *__next;
-} __pthread_list_t;
-#else
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-#endif
-
-
 /* Data structures for mutex handling.  The structure of the attribute
    type is deliberately not exposed.  */
 typedef union
 {
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-#if __WORDSIZE == 64
-    unsigned int __nusers;
-#endif
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-#if __WORDSIZE == 64
-    short __spins;
-    short __elision;
-    __pthread_list_t __list;
-# define __PTHREAD_MUTEX_HAVE_PREV	1
-# define __PTHREAD_SPINS             0, 0
-#else
-    unsigned int __nusers;
-    __extension__ union
-    {
-      struct
-      {
-	short __espins;
-	short __elision;
-# define __spins __elision_data.__espins
-# define __elision __elision_data.__elision
-# define __PTHREAD_SPINS         { 0, 0 }
-      } __elision_data;
-      __pthread_slist_t __list;
-    };
-#endif
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
   int __align;
 } pthread_mutexattr_t;
@@ -126,36 +66,6 @@ typedef union
    the attribute type is not exposed on purpose.  */
 typedef union
 {
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
   int __align;
 } pthread_condattr_t;
diff --git a/sysdeps/powerpc/nptl/bits/thread-shared-types.h b/sysdeps/powerpc/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..3653f83
--- /dev/null
+++ b/sysdeps/powerpc/nptl/bits/thread-shared-types.h
@@ -0,0 +1,118 @@
+/* Common thread definition for pthread and c11 threads.  Linux/powerpc
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for the declaration of
+   pthread_mutex_t and pthread_cond_t, both needed by C11 types mtx_t and
+   cnd_t. */
+
+#ifndef _BITS_PTHREAD_SHARED_TYPES_H
+# define _BITS_PTHREAD_SHARED_TYPES_H	1
+
+#if __WORDSIZE == 64
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+#else
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+#endif
+#define __SIZEOF_PTHREAD_COND_T 48
+
+
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+  struct __pthread_internal_list *__prev;
+  struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+#if __WORDSIZE == 64
+  unsigned int __nusers;
+#endif
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility with static initializers.  */
+  int __kind;
+#if __WORDSIZE == 64
+  short __spins;
+  short __elision;
+  __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV	1
+# define __PTHREAD_SPINS             0, 0
+#else
+  unsigned int __nusers;
+  __extension__ union
+  {
+    struct
+    {
+      short __espins;
+      short __elision;
+# define __spins __elision_data.__espins
+# define __elision __elision_data.__elision
+# define __PTHREAD_SPINS         { 0, 0 }
+    } __elision_data;
+    __pthread_slist_t __list;
+  };
+#endif
+};
+
+#define __PTHREAD_MUTEX_T_CONTENT		\
+  struct __pthread_mutex_s  __data;		\
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];	\
+  long int __align;
+
+
+/* Data structure for conditional variable handling */
+#define __PTHREAD_COND_T_CONTENT			\
+  struct						\
+  {							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    { 							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+#endif
diff --git a/sysdeps/s390/nptl/bits/pthreadtypes.h b/sysdeps/s390/nptl/bits/pthreadtypes.h
index 48ffdb4..8cd8602 100644
--- a/sysdeps/s390/nptl/bits/pthreadtypes.h
+++ b/sysdeps/s390/nptl/bits/pthreadtypes.h
@@ -19,12 +19,11 @@
 #define _BITS_PTHREADTYPES_H	1
 
 #include <bits/wordsize.h>
+#include <bits/pthreadtypes-common.h>
 
 #if __WORDSIZE == 64
 # define __SIZEOF_PTHREAD_ATTR_T 56
-# define __SIZEOF_PTHREAD_MUTEX_T 40
 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
 # define __SIZEOF_PTHREAD_CONDATTR_T 4
 # define __SIZEOF_PTHREAD_RWLOCK_T 56
 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
@@ -32,9 +31,7 @@
 # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 #else
 # define __SIZEOF_PTHREAD_ATTR_T 36
-# define __SIZEOF_PTHREAD_MUTEX_T 24
 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
 # define __SIZEOF_PTHREAD_CONDATTR_T 4
 # define __SIZEOF_PTHREAD_RWLOCK_T 32
 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
@@ -59,78 +56,10 @@ typedef union pthread_attr_t pthread_attr_t;
 #endif
 
 
-#if __WORDSIZE == 64
-typedef struct __pthread_internal_list
-{
-  struct __pthread_internal_list *__prev;
-  struct __pthread_internal_list *__next;
-} __pthread_list_t;
-#else
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-#endif
-
-
 /* Data structures for mutex handling.  The structure of the attribute
    type is not exposed on purpose.  */
 typedef union
 {
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-#if __WORDSIZE == 64
-    unsigned int __nusers;
-#endif
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-#if __WORDSIZE == 64
-# ifdef ENABLE_LOCK_ELISION
-    short __spins;
-    short __elision;
-    /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#  define __PTHREAD_SPINS               0, 0
-# else
-    int __spins;
-    /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#  define __PTHREAD_SPINS               0
-# endif
-    __pthread_list_t __list;
-# define __PTHREAD_MUTEX_HAVE_PREV	1
-#else
-    unsigned int __nusers;
-    __extension__ union
-    {
-# ifdef ENABLE_LOCK_ELISION
-      struct
-      {
-	short __espins;
-	short __elision;
-      } _d;
-#  define __spins _d.__espins
-#  define __elision _d.__elision
-    /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#  define __PTHREAD_SPINS               { 0, 0 }
-# else
-      int __spins;
-    /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#  define __PTHREAD_SPINS               0
-# endif
-      __pthread_slist_t __list;
-    };
-#endif
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
   int __align;
 } pthread_mutexattr_t;
@@ -140,36 +69,6 @@ typedef union
    the attribute type is not exposed on purpose.  */
 typedef union
 {
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
   int __align;
 } pthread_condattr_t;
diff --git a/sysdeps/s390/nptl/bits/thread-shared-types.h b/sysdeps/s390/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..893e626
--- /dev/null
+++ b/sysdeps/s390/nptl/bits/thread-shared-types.h
@@ -0,0 +1,137 @@
+/* Common thread definition for pthread and c11 threads.  Linux/s390
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for
+   the declaration of pthread_mutex_t and pthread_cond_t,
+   both needed by C11 types mtx_t and cnd_t. */
+
+#ifndef _BITS_THREAD_SHARED_TYPES_H
+#define _BITS_THREAD_SHARED_TYPES_H	1
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+# define __SIZEOF_PTHREAD_COND_T 48
+#else
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+# define __SIZEOF_PTHREAD_COND_T 48
+#endif
+
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+  struct __pthread_internal_list *__prev;
+  struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
+/* Data structure for mutex handling. */
+
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+#if __WORDSIZE == 64
+  unsigned int __nusers;
+#endif
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility.  */
+  int __kind;
+#if __WORDSIZE == 64
+# ifdef ENABLE_LOCK_ELISION
+  short __spins;
+  short __elision;
+  /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#  define __PTHREAD_SPINS               0, 0
+# else
+  int __spins;
+  /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#  define __PTHREAD_SPINS               0
+# endif
+  __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV	1
+#else
+  unsigned int __nusers;
+  __extension__ union
+  {
+# ifdef ENABLE_LOCK_ELISION
+    struct
+    {
+      short __espins;
+      short __elision;
+    } _d;
+#  define __spins _d.__espins
+#  define __elision _d.__elision
+  /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#  define __PTHREAD_SPINS               { 0, 0 }
+# else
+    int __spins;
+  /* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#  define __PTHREAD_SPINS               0
+# endif
+    __pthread_slist_t __list;
+  };
+#endif
+};
+
+#define __PTHREAD_MUTEX_T_CONTENT         \
+  struct __pthread_mutex_s __data;        \
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];  \
+  long int __align;
+
+
+/* Data structure for conditional variable handling */
+
+#define __PTHREAD_COND_T_CONTENT			\
+  struct						\
+  {							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    { 							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+#endif
diff --git a/sysdeps/sh/nptl/bits/pthreadtypes.h b/sysdeps/sh/nptl/bits/pthreadtypes.h
index eec5811..c0b4297 100644
--- a/sysdeps/sh/nptl/bits/pthreadtypes.h
+++ b/sysdeps/sh/nptl/bits/pthreadtypes.h
@@ -19,11 +19,10 @@
 #define _BITS_PTHREADTYPES_H	1
 
 #include <endian.h>
+#include <bits/pthreadtypes-common.h>
 
 #define __SIZEOF_PTHREAD_ATTR_T 36
-#define __SIZEOF_PTHREAD_MUTEX_T 24
 #define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-#define __SIZEOF_PTHREAD_COND_T 48
 #define __SIZEOF_PTHREAD_COND_COMPAT_T 12
 #define __SIZEOF_PTHREAD_CONDATTR_T 4
 #define __SIZEOF_PTHREAD_RWLOCK_T 32
@@ -48,40 +47,10 @@ typedef union pthread_attr_t pthread_attr_t;
 #endif
 
 
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-
-
 /* Data structures for mutex handling.  The structure of the attribute
    type is not exposed on purpose.  */
 typedef union
 {
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-    unsigned int __nusers;
-    __extension__ union
-    {
-      int __spins;
-      __pthread_slist_t __list;
-    };
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
-/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#define __PTHREAD_SPINS 0
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
   long int __align;
 } pthread_mutexattr_t;
@@ -91,36 +60,6 @@ typedef union
    the attribute type is not exposed on purpose.  */
 typedef union
 {
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
   long int __align;
 } pthread_condattr_t;
diff --git a/sysdeps/sh/nptl/bits/thread-shared-types.h b/sysdeps/sh/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..7a28e58
--- /dev/null
+++ b/sysdeps/sh/nptl/bits/thread-shared-types.h
@@ -0,0 +1,94 @@
+/* Common thread definition for pthread and c11 threads.  Linux/sh
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for
+   the declaration of pthread_mutex_t and pthread_cond_t,
+   both needed by C11 types mtx_t and cnd_t. */
+
+#ifndef _BITS_THREAD_SHARED_TYPES_H
+#define _BITS_THREAD_SHARED_TYPES_H	1
+
+#include <bits/wordsize.h>
+
+#define __SIZEOF_PTHREAD_MUTEX_T 24
+#define __SIZEOF_PTHREAD_COND_T 48
+
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+/* Data structure for mutex handling. */
+
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility.  */
+  int __kind;
+  unsigned int __nusers;
+  __extension__ union
+  {
+    int __spins;
+    __pthread_slist_t __list;
+  };
+};
+
+#define __PTHREAD_MUTEX_T_CONTENT         \
+  struct __pthread_mutex_s __data;         \
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];   \
+  long int __align;
+
+
+/* Data structure for conditional variable handling */
+
+#define __PTHREAD_COND_T_CONTENT			\
+  struct						\
+  { 							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+#endif	/* bits/thread-shared-types.h */
diff --git a/sysdeps/sparc/nptl/bits/pthreadtypes.h b/sysdeps/sparc/nptl/bits/pthreadtypes.h
index 525988c..9788df6 100644
--- a/sysdeps/sparc/nptl/bits/pthreadtypes.h
+++ b/sysdeps/sparc/nptl/bits/pthreadtypes.h
@@ -20,12 +20,11 @@
 #define _BITS_PTHREADTYPES_H	1
 
 #include <bits/wordsize.h>
+#include <bits/pthreadtypes-common.h>
 
 #if __WORDSIZE == 64
 # define __SIZEOF_PTHREAD_ATTR_T 56
-# define __SIZEOF_PTHREAD_MUTEX_T 40
 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
 # define __SIZEOF_PTHREAD_CONDATTR_T 4
 # define __SIZEOF_PTHREAD_RWLOCK_T 56
 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
@@ -33,9 +32,7 @@
 # define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 #else
 # define __SIZEOF_PTHREAD_ATTR_T 36
-# define __SIZEOF_PTHREAD_MUTEX_T 24
 # define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
 # define __SIZEOF_PTHREAD_CONDATTR_T 4
 # define __SIZEOF_PTHREAD_RWLOCK_T 32
 # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
@@ -60,57 +57,10 @@ typedef union pthread_attr_t pthread_attr_t;
 #endif
 
 
-#if __WORDSIZE == 64
-typedef struct __pthread_internal_list
-{
-  struct __pthread_internal_list *__prev;
-  struct __pthread_internal_list *__next;
-} __pthread_list_t;
-#else
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-#endif
-
-
 /* Data structures for mutex handling.  The structure of the attribute
    type is deliberately not exposed.  */
 typedef union
 {
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-#if __WORDSIZE == 64
-    unsigned int __nusers;
-#endif
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-#if __WORDSIZE == 64
-    int __spins;
-    __pthread_list_t __list;
-# define __PTHREAD_MUTEX_HAVE_PREV	1
-#else
-    unsigned int __nusers;
-    __extension__ union
-    {
-      int __spins;
-      __pthread_slist_t __list;
-    };
-#endif
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
-/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#define __PTHREAD_SPINS 0
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
   int __align;
 } pthread_mutexattr_t;
@@ -120,36 +70,6 @@ typedef union
    the attribute type is deliberately not exposed.  */
 typedef union
 {
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
   int __align;
 } pthread_condattr_t;
diff --git a/sysdeps/sparc/nptl/bits/thread-shared-types.h b/sysdeps/sparc/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..d12916a
--- /dev/null
+++ b/sysdeps/sparc/nptl/bits/thread-shared-types.h
@@ -0,0 +1,115 @@
+/* Common thread definition for pthread and c11 threads.  Linux/sparc
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for
+   the declaration of pthread_mutex_t and pthread_cond_t,
+   both needed by C11 types mtx_t and cnd_t. */
+
+#ifndef _BITS_THREAD_SHARED_TYPES_H
+#define _BITS_THREAD_SHARED_TYPES_H	1
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+# define __SIZEOF_PTHREAD_COND_T 48
+#else
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+# define __SIZEOF_PTHREAD_COND_T 48
+#endif
+
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+  struct __pthread_internal_list *__prev;
+  struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+/* Data structures for mutex handling.  */
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+#if __WORDSIZE == 64
+  unsigned int __nusers;
+#endif
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility with static initializers.  */
+  int __kind;
+#if __WORDSIZE == 64
+  int __spins;
+  __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV      1
+#else
+  unsigned int __nusers;
+  __extension__ union
+  {
+    int __spins;
+    __pthread_slist_t __list;
+  };
+#endif
+};
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+#define __PTHREAD_MUTEX_T_CONTENT		\
+  struct __pthread_mutex_s __data;		\
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];	\
+  long int __align;
+
+
+/* Data structure for conditional variable handling */
+#define __PTHREAD_COND_T_CONTENT			\
+  struct						\
+  { 							\
+    __extension__ union					\
+    { 							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+#endif
+
diff --git a/sysdeps/tile/nptl/bits/pthreadtypes.h b/sysdeps/tile/nptl/bits/pthreadtypes.h
index 1632d82..1751082 100644
--- a/sysdeps/tile/nptl/bits/pthreadtypes.h
+++ b/sysdeps/tile/nptl/bits/pthreadtypes.h
@@ -21,28 +21,21 @@
 #define _BITS_PTHREADTYPES_H	1
 
 #include <bits/wordsize.h>
+#include <bits/pthreadtypes-common.h>
 
 #if __WORDSIZE == 64
 # define __SIZEOF_PTHREAD_ATTR_T 56
-# define __SIZEOF_PTHREAD_MUTEX_T 40
-# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
-# define __SIZEOF_PTHREAD_CONDATTR_T 4
 # define __SIZEOF_PTHREAD_RWLOCK_T 56
-# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
 # define __SIZEOF_PTHREAD_BARRIER_T 32
-# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 #else
 # define __SIZEOF_PTHREAD_ATTR_T 36
-# define __SIZEOF_PTHREAD_MUTEX_T 24
-# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
-# define __SIZEOF_PTHREAD_CONDATTR_T 4
 # define __SIZEOF_PTHREAD_RWLOCK_T 32
-# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
 # define __SIZEOF_PTHREAD_BARRIER_T 20
-# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 #endif
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 
 
 /* Thread identifiers.  The structure of the attribute type is not
@@ -60,51 +53,6 @@ typedef union pthread_attr_t pthread_attr_t;
 # define __have_pthread_attr_t	1
 #endif
 
-#if __WORDSIZE == 64
-typedef struct __pthread_internal_list
-{
-  struct __pthread_internal_list *__prev;
-  struct __pthread_internal_list *__next;
-} __pthread_list_t;
-#else
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-#endif
-
-
-/* Data structures for mutex handling.  The structure of the attribute
-   type is not exposed on purpose.  */
-typedef union
-{
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-#if __WORDSIZE == 64
-    unsigned int __nusers;
-#endif
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-#if __WORDSIZE == 64
-    int __spins;
-    __pthread_list_t __list;
-# define __PTHREAD_MUTEX_HAVE_PREV	1
-#else
-    unsigned int __nusers;
-    __extension__ union
-    {
-      int __spins;
-      __pthread_slist_t __list;
-    };
-#endif
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
 
 typedef union
 {
@@ -112,44 +60,11 @@ typedef union
   int __align;
 } pthread_mutexattr_t;
 
-/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-#define __PTHREAD_SPINS 0
-
 
 /* Data structure for conditional variable handling.  The structure of
    the attribute type is not exposed on purpose.  */
 typedef union
 {
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
   int __align;
 } pthread_condattr_t;
diff --git a/sysdeps/tile/nptl/bits/thread-shared-types.h b/sysdeps/tile/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..0a4587e
--- /dev/null
+++ b/sysdeps/tile/nptl/bits/thread-shared-types.h
@@ -0,0 +1,114 @@
+/* Common thread definition for pthread and c11 threads.  Linux/sparc
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+/* This header contains macros definition required for
+   the declaration of pthread_mutex_t and pthread_cond_t,
+   both needed by C11 types mtx_t and cnd_t. */
+
+#ifndef _BITS_THREAD_SHARED_TYPES_H
+#define _BITS_THREAD_SHARED_TYPES_H	1
+
+#include <bits/wordsize.h>
+
+#if __WORDSIZE == 64
+# define __SIZEOF_PTHREAD_MUTEX_T 40
+#else
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+#endif
+#define __SIZEOF_PTHREAD_COND_T 48
+
+
+#if __WORDSIZE == 64
+typedef struct __pthread_internal_list
+{
+  struct __pthread_internal_list *__prev;
+  struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
+/* Data structures for mutex handling.  */
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+#if __WORDSIZE == 64
+  unsigned int __nusers;
+#endif
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility with static initializers.  */
+  int __kind;
+#if __WORDSIZE == 64
+  int __spins;
+  __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV	1
+#else
+  unsigned int __nusers;
+  __extension__ union
+  {
+    int __spins;
+    __pthread_slist_t __list;
+  };
+#endif
+};
+
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+#define __PTHREAD_SPINS 0
+
+#define __PTHREAD_MUTEX_T_CONTENT			\
+  struct __pthread_mutex_s __data;			\
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];		\
+  long int __align;
+
+
+#define __PTHREAD_COND_T_CONTENT			\
+  struct						\
+  {							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+#endif
diff --git a/sysdeps/x86/nptl/bits/pthreadtypes.h b/sysdeps/x86/nptl/bits/pthreadtypes.h
index c3055ca..a08aace 100644
--- a/sysdeps/x86/nptl/bits/pthreadtypes.h
+++ b/sysdeps/x86/nptl/bits/pthreadtypes.h
@@ -19,40 +19,30 @@
 #define _BITS_PTHREADTYPES_H	1
 
 #include <bits/wordsize.h>
+#include <bits/pthreadtypes-common.h>
 
 #ifdef __x86_64__
 # if __WORDSIZE == 64
 #  define __SIZEOF_PTHREAD_ATTR_T 56
 #  define __SIZEOF_PTHREAD_MUTEX_T 40
-#  define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-#  define __SIZEOF_PTHREAD_COND_T 48
-#  define __SIZEOF_PTHREAD_CONDATTR_T 4
 #  define __SIZEOF_PTHREAD_RWLOCK_T 56
-#  define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
 #  define __SIZEOF_PTHREAD_BARRIER_T 32
-#  define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 # else
 #  define __SIZEOF_PTHREAD_ATTR_T 32
 #  define __SIZEOF_PTHREAD_MUTEX_T 32
-#  define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-#  define __SIZEOF_PTHREAD_COND_T 48
-#  define __SIZEOF_PTHREAD_CONDATTR_T 4
 #  define __SIZEOF_PTHREAD_RWLOCK_T 44
-#  define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
 #  define __SIZEOF_PTHREAD_BARRIER_T 20
-#  define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 # endif
 #else
 # define __SIZEOF_PTHREAD_ATTR_T 36
 # define __SIZEOF_PTHREAD_MUTEX_T 24
-# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
-# define __SIZEOF_PTHREAD_COND_T 48
-# define __SIZEOF_PTHREAD_CONDATTR_T 4
 # define __SIZEOF_PTHREAD_RWLOCK_T 32
-# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
 # define __SIZEOF_PTHREAD_BARRIER_T 20
-# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 #endif
+#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
+#define __SIZEOF_PTHREAD_CONDATTR_T 4
+#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
+#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
 
 
 /* Thread identifiers.  The structure of the attribute type is not
@@ -71,64 +61,10 @@ typedef union pthread_attr_t pthread_attr_t;
 #endif
 
 
-#ifdef __x86_64__
-typedef struct __pthread_internal_list
-{
-  struct __pthread_internal_list *__prev;
-  struct __pthread_internal_list *__next;
-} __pthread_list_t;
-#else
-typedef struct __pthread_internal_slist
-{
-  struct __pthread_internal_slist *__next;
-} __pthread_slist_t;
-#endif
-
-
 /* Data structures for mutex handling.  The structure of the attribute
    type is not exposed on purpose.  */
 typedef union
 {
-  struct __pthread_mutex_s
-  {
-    int __lock;
-    unsigned int __count;
-    int __owner;
-#ifdef __x86_64__
-    unsigned int __nusers;
-#endif
-    /* KIND must stay at this position in the structure to maintain
-       binary compatibility with static initializers.  */
-    int __kind;
-#ifdef __x86_64__
-    short __spins;
-    short __elision;
-    __pthread_list_t __list;
-# define __PTHREAD_MUTEX_HAVE_PREV	1
-/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
-# define __PTHREAD_SPINS             0, 0
-#else
-    unsigned int __nusers;
-    __extension__ union
-    {
-      struct
-      {
-	short __espins;
-	short __elision;
-# define __spins __elision_data.__espins
-# define __elision __elision_data.__elision
-# define __PTHREAD_SPINS         { 0, 0 }
-      } __elision_data;
-      __pthread_slist_t __list;
-    };
-#endif
-  } __data;
-  char __size[__SIZEOF_PTHREAD_MUTEX_T];
-  long int __align;
-} pthread_mutex_t;
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
   int __align;
 } pthread_mutexattr_t;
@@ -138,36 +74,6 @@ typedef union
    the attribute type is not exposed on purpose.  */
 typedef union
 {
-  struct
-  {
-    __extension__ union
-    {
-      __extension__ unsigned long long int __wseq;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __wseq32;
-    };
-    __extension__ union
-    {
-      __extension__ unsigned long long int __g1_start;
-      struct {
-	unsigned int __low;
-	unsigned int __high;
-      } __g1_start32;
-    };
-    unsigned int __g_refs[2];
-    unsigned int __g_size[2];
-    unsigned int __g1_orig_size;
-    unsigned int __wrefs;
-    unsigned int __g_signals[2];
-  } __data;
-  char __size[__SIZEOF_PTHREAD_COND_T];
-  __extension__ long long int __align;
-} pthread_cond_t;
-
-typedef union
-{
   char __size[__SIZEOF_PTHREAD_CONDATTR_T];
   int __align;
 } pthread_condattr_t;
diff --git a/sysdeps/x86/nptl/bits/thread-shared-types.h b/sysdeps/x86/nptl/bits/thread-shared-types.h
new file mode 100644
index 0000000..ffed07d
--- /dev/null
+++ b/sysdeps/x86/nptl/bits/thread-shared-types.h
@@ -0,0 +1,117 @@
+/* Common thread definition for pthread and c11 threads.  Linux/x86
+   version.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _BITS_PTHREAD_SHARED_TYPES_H
+#define _BITS_PTHREAD_SHARED_TYPES_H	1
+
+#ifdef __x86_64__
+# if __WORDSIZE == 64
+#  define __SIZEOF_PTHREAD_MUTEX_T 40
+# else
+#  define __SIZEOF_PTHREAD_MUTEX_T 32
+# endif
+#else
+# define __SIZEOF_PTHREAD_MUTEX_T 24
+#endif
+#define __SIZEOF_PTHREAD_COND_T 48
+
+#ifdef __x86_64__
+typedef struct __pthread_internal_list
+{
+  struct __pthread_internal_list *__prev;
+  struct __pthread_internal_list *__next;
+} __pthread_list_t;
+#else
+typedef struct __pthread_internal_slist
+{
+  struct __pthread_internal_slist *__next;
+} __pthread_slist_t;
+#endif
+
+
+struct __pthread_mutex_s
+{
+  int __lock;
+  unsigned int __count;
+  int __owner;
+#ifdef __x86_64__
+  unsigned int __nusers;
+#endif
+  /* KIND must stay at this position in the structure to maintain
+     binary compatibility with static initializers.  */
+  int __kind;
+#ifdef __x86_64__
+  short __spins;
+  short __elision;
+  __pthread_list_t __list;
+# define __PTHREAD_MUTEX_HAVE_PREV	1
+/* Mutex __spins initializer used by PTHREAD_MUTEX_INITIALIZER.  */
+# define __PTHREAD_SPINS             0, 0
+#else
+  unsigned int __nusers;
+  __extension__ union
+  {
+    struct
+    {
+      short __espins;
+      short __elision;
+# define __spins __elision_data.__espins
+# define __elision __elision_data.__elision
+# define __PTHREAD_SPINS         { 0, 0 }
+    } __elision_data;
+    __pthread_slist_t __list;
+  };
+#endif
+};
+
+#define __PTHREAD_MUTEX_T_CONTENT		\
+  struct __pthread_mutex_s __data;		\
+  char __size[__SIZEOF_PTHREAD_MUTEX_T];	\
+  long int __align;				\
+
+#define __PTHREAD_COND_T_CONTENT			\
+  struct						\
+  {							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __wseq;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __wseq32;					\
+    };							\
+    __extension__ union					\
+    {							\
+      __extension__ unsigned long long int __g1_start;	\
+      struct {						\
+        unsigned int __low;				\
+        unsigned int __high;				\
+      } __g1_start32;					\
+    };							\
+    unsigned int __g_refs[2];				\
+    unsigned int __g_size[2];				\
+    unsigned int __g1_orig_size;			\
+    unsigned int __wrefs;				\
+    unsigned int __g_signals[2];			\
+  } __data;						\
+  char __size[__SIZEOF_PTHREAD_COND_T];			\
+  __extension__ long long int __align;
+
+
+#endif
-- 
2.7.4

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 3/6] Clean pthread functions namespaces for C11 threads
  2017-03-21 13:40 [PATCH v3 0/6] Add support for ISO C11 threads.h Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2017-03-21 13:40 ` [PATCH 4/6] Add C11 threads support Adhemerval Zanella
@ 2017-03-21 13:40 ` Adhemerval Zanella
  2017-03-21 13:40 ` [PATCH 2/6] Move mutex and condition variable definition to common header Adhemerval Zanella
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-21 13:40 UTC (permalink / raw)
  To: libc-alpha

This patch adds internal definition (through {libc_}hidden_{proto,def}) and
also change some strong to weak alias for symbols that might be used by C11
threads implementations.

The patchset should not change libc/libpthread functional, although object
changes are expected (since now internal symbols are used instead) and final
exported symbols through GLIBC_PRIVATE is also expanded (to cover libpthread
usage of __mmap{64}, __munmap, __mprotect).

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, hppa-linux-gnu, i386-linux-gnu, ia64-linux-gnu,
m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

	* include/sched.h (__sched_get_priority_max): Add libc hidden proto.
	(__sched_get_prioriry_min): Likewise.
	* include/sys/mman.h (__mmap): Likewise.
	(__mmap64): Likewise.
	(__munmap): Likewise.
	(__mprotect): Likewise.
	* include/termios.h (__tcsetattr): Likewise.
	* include/time.h (__nanosleep): Use hidden_proto instead of
	libc_hidden_proto.
	* posix/nanosleep.c (__nanosleep): Likewise.
	* misc/Versions (libc): Export __mmap, __munmap, __mprotect,
	__sched_get_priority_min, and __sched_get_priority_max under
	GLIBC_PRIVATE.
	* nptl/allocatestack.c (__free_stacks): Use internal definition for
	libc symbols.
	(change_stack_perm): Likewise.
	(allocate_stack): Likewise.
	* sysdeps/posix/gethostname.c: Likewise.
	* nptl/tpp.c (__init_sched_fifo_prio): Likewise.
	* sysdeps/unix/sysv/linux/hppa/internaltypes.h
	(cond_compat_check_and_clear): Likewise.
	* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/ioctl.c (__ioctl): Likewise.
	* nptl/pthreadP.h (__pthread_mutex_timedlock): Add definition.
	(__pthread_key_delete): Likewise.
	(__pthread_detach): Likewise.
	(__pthread_cancel): Likewise.
	(__pthread_mutex_trylock): Likewise.
	(__pthread_mutexattr_init): Likewise.
	(__pthread_mutexattr_settype): Likewise.
	* nptl/pthread_cancel.c (pthread_cancel): Change to internal name and
	create alias for exported one.
	* nptl/pthread_join.c (pthread_join): Likewise.
	* nptl/pthread_detach.c (pthread_detach): Likewise.
	* nptl/pthread_key_delete.c (pthread_key_delete): Likewise.
	* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.
	* nptl/pthread_create.c: Change static requirements for pthread
	symbols.
	* nptl/pthread_equal.c (__pthread_equal): Change strong alias to weak
	for internal definition.
	* nptl/pthread_exit.c (__pthread_exit): Likewise.
	* nptl/pthread_getspecific.c (__pthread_getspecific): Likewise.
	* nptl/pthread_key_create.c (__pthread_key_create): Likewise.
	* nptl/pthread_mutex_destroy.c (__pthread_mutex_destroy): Likewise.
	* nptl/pthread_mutex_init.c (__pthread_mutex_init): Likewise.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise.
	* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock): Likewise.
	* nptl/pthread_mutexattr_init.c (__pthread_mutexattr_init): Likwise.
	* nptl/pthread_mutexattr_settype.c (__pthread_mutexattr_settype):
	Likewise.
	* nptl/pthread_self.c (__pthread_self): Likewise.
	* nptl/pthread_setspecific.c (__pthread_setspecific): Likewise.
	* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/mmap.c (__mmap): Add internal symbol
	definition.
	(__mmap64): Likewise.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c (__mmap):
	Likewise.
	* sysdeps/unix/sysv/linux/hppa/mmap.c (__mmap): Likewise.
	* sysdeps/unix/sysv/linux/i386/mmap.c (__mmap): Likewise.
	* sysdeps/unix/sysv/linux/m68k/mmap.S (__mmap): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/mmap.S (__mmap): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c (__mmap64):
	Likewise.
	* sysdeps/unix/sysv/linux/mmap64.c (__mmap): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/mmap.S (__mmap): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S (__mmap64): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/mmap.S (__mmap): Likewise.
	(__mmap64): Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/mmap.c (__mmap): Likewise.
	(__mmap64): Likewise.
	* sysdeps/unix/sysv/linux/i386/Versions (libc) [GLIBC_PRIVATE):
	Add __uname.
	* sysdeps/microblaze/backtrace.c (get_frame_size): Add static.
---
 ChangeLog                                          | 76 ++++++++++++++++++++++
 include/sched.h                                    |  2 +
 include/sys/mman.h                                 |  4 ++
 include/termios.h                                  |  2 +
 include/time.h                                     |  2 +-
 misc/Versions                                      |  2 +
 nptl/allocatestack.c                               | 24 +++----
 nptl/pthreadP.h                                    |  9 +++
 nptl/pthread_cancel.c                              |  7 +-
 nptl/pthread_create.c                              | 18 ++---
 nptl/pthread_detach.c                              |  3 +-
 nptl/pthread_equal.c                               |  2 +-
 nptl/pthread_exit.c                                |  4 +-
 nptl/pthread_getspecific.c                         |  2 +-
 nptl/pthread_join.c                                |  3 +-
 nptl/pthread_key_create.c                          |  2 +-
 nptl/pthread_key_delete.c                          |  3 +-
 nptl/pthread_mutex_destroy.c                       |  2 +-
 nptl/pthread_mutex_init.c                          |  2 +-
 nptl/pthread_mutex_lock.c                          |  2 +-
 nptl/pthread_mutex_timedlock.c                     |  5 +-
 nptl/pthread_mutex_trylock.c                       |  3 +-
 nptl/pthread_mutex_unlock.c                        |  2 +-
 nptl/pthread_mutexattr_init.c                      |  3 +-
 nptl/pthread_mutexattr_settype.c                   |  3 +-
 nptl/pthread_self.c                                |  2 +-
 nptl/pthread_setspecific.c                         |  2 +-
 nptl/tpp.c                                         |  4 +-
 posix/nanosleep.c                                  |  2 +-
 sysdeps/posix/gethostname.c                        |  2 +-
 sysdeps/unix/sysv/linux/aarch64/mmap.c             |  5 +-
 sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c |  5 +-
 sysdeps/unix/sysv/linux/hppa/mmap.c                |  1 +
 sysdeps/unix/sysv/linux/i386/Versions              |  2 +-
 sysdeps/unix/sysv/linux/i386/mmap.c                |  1 +
 sysdeps/unix/sysv/linux/i386/smp.h                 |  2 +-
 sysdeps/unix/sysv/linux/m68k/mmap.S                |  1 +
 sysdeps/unix/sysv/linux/microblaze/mmap.S          |  1 +
 sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c     |  5 +-
 sysdeps/unix/sysv/linux/mmap64.c                   |  6 +-
 sysdeps/unix/sysv/linux/powerpc/ioctl.c            |  6 +-
 sysdeps/unix/sysv/linux/s390/s390-32/mmap.S        |  1 +
 sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S      |  1 +
 sysdeps/unix/sysv/linux/s390/s390-64/mmap.S        |  2 +
 sysdeps/unix/sysv/linux/tcsetattr.c                |  3 +-
 sysdeps/unix/sysv/linux/wordsize-64/mmap.c         |  6 +-
 46 files changed, 183 insertions(+), 64 deletions(-)

diff --git a/include/sched.h b/include/sched.h
index b4d7406..f75faed 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -13,7 +13,9 @@ extern int __sched_getscheduler (__pid_t __pid);
 extern int __sched_yield (void);
 libc_hidden_proto (__sched_yield)
 extern int __sched_get_priority_max (int __algorithm);
+libc_hidden_proto (__sched_get_priority_max)
 extern int __sched_get_priority_min (int __algorithm);
+libc_hidden_proto (__sched_get_priority_min)
 extern int __sched_rr_get_interval (__pid_t __pid, struct timespec *__t);
 
 /* These are Linux specific.  */
diff --git a/include/sys/mman.h b/include/sys/mman.h
index 7026f69..8b996fc 100644
--- a/include/sys/mman.h
+++ b/include/sys/mman.h
@@ -5,10 +5,14 @@
 /* Now define the internal interfaces.  */
 extern void *__mmap (void *__addr, size_t __len, int __prot,
 		     int __flags, int __fd, __off_t __offset);
+libc_hidden_proto (__mmap)
 extern void *__mmap64 (void *__addr, size_t __len, int __prot,
 		       int __flags, int __fd, __off64_t __offset);
+libc_hidden_proto (__mmap64)
 extern int __munmap (void *__addr, size_t __len);
+libc_hidden_proto (__munmap)
 extern int __mprotect (void *__addr, size_t __len, int __prot);
+libc_hidden_proto (__mprotect)
 
 extern int __madvise (void *__addr, size_t __len, int __advice);
 libc_hidden_proto (__madvise)
diff --git a/include/termios.h b/include/termios.h
index fad51f8..1a36e22 100644
--- a/include/termios.h
+++ b/include/termios.h
@@ -4,6 +4,8 @@
 #ifndef _ISOMAC
 /* Now define the internal interfaces.  */
 extern int __tcgetattr (int __fd, struct termios *__termios_p);
+extern int __tcsetattr (int __fd, int __optional_actions,
+			const struct termios *__termios_p);
 
 extern int __libc_tcdrain (int __fd);
 
diff --git a/include/time.h b/include/time.h
index 6badf0e..c5f64b3 100644
--- a/include/time.h
+++ b/include/time.h
@@ -80,7 +80,7 @@ extern struct tm *__tz_convert (const time_t *timer, int use_localtime, struct t
 
 extern int __nanosleep (const struct timespec *__requested_time,
 			struct timespec *__remaining);
-libc_hidden_proto (__nanosleep)
+hidden_proto (__nanosleep)
 extern int __nanosleep_nocancel (const struct timespec *__requested_time,
 				 struct timespec *__remaining)
   attribute_hidden;
diff --git a/misc/Versions b/misc/Versions
index f2c90ff..7d8bc4e 100644
--- a/misc/Versions
+++ b/misc/Versions
@@ -160,5 +160,7 @@ libc {
     __mktemp;
     __libc_ifunc_impl_list;
     __tdelete; __tfind; __tsearch; __twalk;
+    __mmap; __munmap; __mprotect;
+    __sched_get_priority_min; __sched_get_priority_max;
   }
 }
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index e5c5f79..d8466e7 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -278,7 +278,7 @@ __free_stacks (size_t limit)
 
 	  /* Remove this block.  This should never fail.  If it does
 	     something is really wrong.  */
-	  if (munmap (curr->stackblock, curr->stackblock_size) != 0)
+	  if (__munmap (curr->stackblock, curr->stackblock_size) != 0)
 	    abort ();
 
 	  /* Maybe we have freed enough.  */
@@ -328,7 +328,7 @@ change_stack_perm (struct pthread *pd
 #else
 # error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
 #endif
-  if (mprotect (stack, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
+  if (__mprotect (stack, len, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
     return errno;
 
   return 0;
@@ -490,8 +490,8 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
 	    size += pagesize_m1 + 1;
 #endif
 
-	  mem = mmap (NULL, size, prot,
-		      MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
+	  mem = __mmap (NULL, size, prot,
+			MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
 
 	  if (__glibc_unlikely (mem == MAP_FAILED))
 	    return errno;
@@ -545,7 +545,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
 	      assert (errno == ENOMEM);
 
 	      /* Free the stack memory we just allocated.  */
-	      (void) munmap (mem, size);
+	      (void) __munmap (mem, size);
 
 	      return errno;
 	    }
@@ -575,7 +575,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
 	      if (err != 0)
 		{
 		  /* Free the stack memory we just allocated.  */
-		  (void) munmap (mem, size);
+		  (void) __munmap (mem, size);
 
 		  return err;
 		}
@@ -600,7 +600,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
 #elif _STACK_GROWS_UP
 	  char *guard = (char *) (((uintptr_t) pd - guardsize) & ~pagesize_m1);
 #endif
-	  if (mprotect (guard, guardsize, PROT_NONE) != 0)
+	  if (__mprotect (guard, guardsize, PROT_NONE) != 0)
 	    {
 	    mprot_error:
 	      lll_lock (stack_cache_lock, LLL_PRIVATE);
@@ -618,7 +618,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
 		 of memory caused problems we better do not use it
 		 anymore.  Uh, and we ignore possible errors.  There
 		 is nothing we could do.  */
-	      (void) munmap (mem, size);
+	      (void) __munmap (mem, size);
 
 	      return errno;
 	    }
@@ -635,19 +635,19 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
 	  char *oldguard = mem + (((size - pd->guardsize) / 2) & ~pagesize_m1);
 
 	  if (oldguard < guard
-	      && mprotect (oldguard, guard - oldguard, prot) != 0)
+	      && __mprotect (oldguard, guard - oldguard, prot) != 0)
 	    goto mprot_error;
 
-	  if (mprotect (guard + guardsize,
+	  if (__mprotect (guard + guardsize,
 			oldguard + pd->guardsize - guard - guardsize,
 			prot) != 0)
 	    goto mprot_error;
 #elif _STACK_GROWS_DOWN
-	  if (mprotect ((char *) mem + guardsize, pd->guardsize - guardsize,
+	  if (__mprotect ((char *) mem + guardsize, pd->guardsize - guardsize,
 			prot) != 0)
 	    goto mprot_error;
 #elif _STACK_GROWS_UP
-	  if (mprotect ((char *) pd - pd->guardsize,
+	  if (__mprotect ((char *) pd - pd->guardsize,
 			pd->guardsize - guardsize, prot) != 0)
 	    goto mprot_error;
 #endif
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 4f76cbb..c4f8879 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -428,6 +428,8 @@ extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
 extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
 extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex);
 extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
+extern int __pthread_mutex_timedlock (pthread_mutex_t *__mutex,
+     const struct timespec *__abstime);
 extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex)
      attribute_hidden internal_function;
 extern void __pthread_mutex_cond_lock_adjust (pthread_mutex_t *__mutex)
@@ -491,6 +493,7 @@ extern int __pthread_cond_timedwait (pthread_cond_t *cond,
 extern int __pthread_condattr_destroy (pthread_condattr_t *attr);
 extern int __pthread_condattr_init (pthread_condattr_t *attr);
 extern int __pthread_key_create (pthread_key_t *key, void (*destr) (void *));
+extern int __pthread_key_delete (pthread_key_t key);
 extern void *__pthread_getspecific (pthread_key_t key);
 extern int __pthread_setspecific (pthread_key_t key, const void *value);
 extern int __pthread_once (pthread_once_t *once_control,
@@ -499,8 +502,11 @@ extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
 			     void (*child) (void));
 extern pthread_t __pthread_self (void);
 extern int __pthread_equal (pthread_t thread1, pthread_t thread2);
+extern int __pthread_detach (pthread_t th);
+extern int __pthread_cancel (pthread_t th);
 extern int __pthread_kill (pthread_t threadid, int signo);
 extern void __pthread_exit (void *value) __attribute__ ((__noreturn__));
+extern int __pthread_join (pthread_t threadid, void **thread_return);
 extern int __pthread_setcanceltype (int type, int *oldtype);
 extern int __pthread_enable_asynccancel (void) attribute_hidden;
 extern void __pthread_disable_asynccancel (int oldtype)
@@ -511,6 +517,7 @@ extern void __pthread_testcancel (void);
 hidden_proto (__pthread_mutex_init)
 hidden_proto (__pthread_mutex_destroy)
 hidden_proto (__pthread_mutex_lock)
+hidden_proto (__pthread_mutex_trylock)
 hidden_proto (__pthread_mutex_unlock)
 hidden_proto (__pthread_rwlock_rdlock)
 hidden_proto (__pthread_rwlock_wrlock)
@@ -521,6 +528,8 @@ hidden_proto (__pthread_setspecific)
 hidden_proto (__pthread_once)
 hidden_proto (__pthread_setcancelstate)
 hidden_proto (__pthread_testcancel)
+hidden_proto (__pthread_mutexattr_init)
+hidden_proto (__pthread_mutexattr_settype)
 #endif
 
 extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
index 231a58d..742dfe6 100644
--- a/nptl/pthread_cancel.c
+++ b/nptl/pthread_cancel.c
@@ -25,7 +25,7 @@
 #include <unistd.h>
 
 int
-pthread_cancel (pthread_t th)
+__pthread_cancel (pthread_t th)
 {
   volatile struct pthread *pd = (volatile struct pthread *) th;
 
@@ -66,7 +66,7 @@ pthread_cancel (pthread_t th)
 #ifdef SIGCANCEL
 	  /* The cancellation handler will take care of marking the
 	     thread as canceled.  */
-	  pid_t pid = getpid ();
+	  pid_t pid = __getpid ();
 
 	  INTERNAL_SYSCALL_DECL (err);
 	  int val = INTERNAL_SYSCALL_CALL (tgkill, err, pid, pd->tid,
@@ -99,5 +99,6 @@ pthread_cancel (pthread_t th)
 
   return result;
 }
+weak_alias (__pthread_cancel, pthread_cancel)
 
-PTHREAD_STATIC_FN_REQUIRE (pthread_create)
+PTHREAD_STATIC_FN_REQUIRE (__pthread_create)
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 2ef2bcb..b303557 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -915,14 +915,14 @@ compat_symbol (libpthread, __pthread_create_2_0, pthread_create,
 \f
 /* If pthread_create is present, libgcc_eh.a and libsupc++.a expects some other POSIX thread
    functions to be present as well.  */
-PTHREAD_STATIC_FN_REQUIRE (pthread_mutex_lock)
-PTHREAD_STATIC_FN_REQUIRE (pthread_mutex_trylock)
-PTHREAD_STATIC_FN_REQUIRE (pthread_mutex_unlock)
+PTHREAD_STATIC_FN_REQUIRE (__pthread_mutex_lock)
+PTHREAD_STATIC_FN_REQUIRE (__pthread_mutex_trylock)
+PTHREAD_STATIC_FN_REQUIRE (__pthread_mutex_unlock)
 
-PTHREAD_STATIC_FN_REQUIRE (pthread_once)
-PTHREAD_STATIC_FN_REQUIRE (pthread_cancel)
+PTHREAD_STATIC_FN_REQUIRE (__pthread_once)
+PTHREAD_STATIC_FN_REQUIRE (__pthread_cancel)
 
-PTHREAD_STATIC_FN_REQUIRE (pthread_key_create)
-PTHREAD_STATIC_FN_REQUIRE (pthread_key_delete)
-PTHREAD_STATIC_FN_REQUIRE (pthread_setspecific)
-PTHREAD_STATIC_FN_REQUIRE (pthread_getspecific)
+PTHREAD_STATIC_FN_REQUIRE (__pthread_key_create)
+PTHREAD_STATIC_FN_REQUIRE (__pthread_key_delete)
+PTHREAD_STATIC_FN_REQUIRE (__pthread_setspecific)
+PTHREAD_STATIC_FN_REQUIRE (__pthread_getspecific)
diff --git a/nptl/pthread_detach.c b/nptl/pthread_detach.c
index 8a2e943..5c4c8f7 100644
--- a/nptl/pthread_detach.c
+++ b/nptl/pthread_detach.c
@@ -22,7 +22,7 @@
 
 
 int
-pthread_detach (pthread_t th)
+__pthread_detach (pthread_t th)
 {
   struct pthread *pd = (struct pthread *) th;
 
@@ -53,3 +53,4 @@ pthread_detach (pthread_t th)
 
   return result;
 }
+weak_alias (__pthread_detach, pthread_detach)
diff --git a/nptl/pthread_equal.c b/nptl/pthread_equal.c
index e304add..b5244ee 100644
--- a/nptl/pthread_equal.c
+++ b/nptl/pthread_equal.c
@@ -24,4 +24,4 @@ __pthread_equal (pthread_t thread1, pthread_t thread2)
 {
   return thread1 == thread2;
 }
-strong_alias (__pthread_equal, pthread_equal)
+weak_alias (__pthread_equal, pthread_equal)
diff --git a/nptl/pthread_exit.c b/nptl/pthread_exit.c
index dffab09..7209769 100644
--- a/nptl/pthread_exit.c
+++ b/nptl/pthread_exit.c
@@ -27,8 +27,8 @@ __pthread_exit (void *value)
 
   __do_cancel ();
 }
-strong_alias (__pthread_exit, pthread_exit)
+weak_alias (__pthread_exit, pthread_exit)
 
 /* After a thread terminates, __libc_start_main decrements
    __nptl_nthreads defined in pthread_create.c.  */
-PTHREAD_STATIC_FN_REQUIRE (pthread_create)
+PTHREAD_STATIC_FN_REQUIRE (__pthread_create)
diff --git a/nptl/pthread_getspecific.c b/nptl/pthread_getspecific.c
index ddedcf2..114d6da 100644
--- a/nptl/pthread_getspecific.c
+++ b/nptl/pthread_getspecific.c
@@ -63,5 +63,5 @@ __pthread_getspecific (pthread_key_t key)
 
   return result;
 }
-strong_alias (__pthread_getspecific, pthread_getspecific)
+weak_alias (__pthread_getspecific, pthread_getspecific)
 hidden_def (__pthread_getspecific)
diff --git a/nptl/pthread_join.c b/nptl/pthread_join.c
index 0192f69..afc8c37 100644
--- a/nptl/pthread_join.c
+++ b/nptl/pthread_join.c
@@ -37,7 +37,7 @@ cleanup (void *arg)
 
 
 int
-pthread_join (pthread_t threadid, void **thread_return)
+__pthread_join (pthread_t threadid, void **thread_return)
 {
   struct pthread *pd = (struct pthread *) threadid;
 
@@ -115,3 +115,4 @@ pthread_join (pthread_t threadid, void **thread_return)
 
   return result;
 }
+weak_alias (__pthread_join, pthread_join)
diff --git a/nptl/pthread_key_create.c b/nptl/pthread_key_create.c
index 4f51c76..70c0e12 100644
--- a/nptl/pthread_key_create.c
+++ b/nptl/pthread_key_create.c
@@ -47,5 +47,5 @@ __pthread_key_create (pthread_key_t *key, void (*destr) (void *))
 
   return EAGAIN;
 }
-strong_alias (__pthread_key_create, pthread_key_create)
+weak_alias (__pthread_key_create, pthread_key_create)
 hidden_def (__pthread_key_create)
diff --git a/nptl/pthread_key_delete.c b/nptl/pthread_key_delete.c
index 605f93b..426163d 100644
--- a/nptl/pthread_key_delete.c
+++ b/nptl/pthread_key_delete.c
@@ -22,7 +22,7 @@
 
 
 int
-pthread_key_delete (pthread_key_t key)
+__pthread_key_delete (pthread_key_t key)
 {
   int result = EINVAL;
 
@@ -39,3 +39,4 @@ pthread_key_delete (pthread_key_t key)
 
   return result;
 }
+weak_alias (__pthread_key_delete, pthread_key_delete)
diff --git a/nptl/pthread_mutex_destroy.c b/nptl/pthread_mutex_destroy.c
index a300832..ed3b63f 100644
--- a/nptl/pthread_mutex_destroy.c
+++ b/nptl/pthread_mutex_destroy.c
@@ -36,5 +36,5 @@ __pthread_mutex_destroy (pthread_mutex_t *mutex)
 
   return 0;
 }
-strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy)
+weak_alias (__pthread_mutex_destroy, pthread_mutex_destroy)
 hidden_def (__pthread_mutex_destroy)
diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c
index 138e144..6f2fc80 100644
--- a/nptl/pthread_mutex_init.c
+++ b/nptl/pthread_mutex_init.c
@@ -144,5 +144,5 @@ __pthread_mutex_init (pthread_mutex_t *mutex,
 
   return 0;
 }
-strong_alias (__pthread_mutex_init, pthread_mutex_init)
+weak_alias (__pthread_mutex_init, pthread_mutex_init)
 hidden_def (__pthread_mutex_init)
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index dc9ca4c..b76475b 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -597,7 +597,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
   return 0;
 }
 #ifndef __pthread_mutex_lock
-strong_alias (__pthread_mutex_lock, pthread_mutex_lock)
+weak_alias (__pthread_mutex_lock, pthread_mutex_lock)
 hidden_def (__pthread_mutex_lock)
 #endif
 
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
index a4beb7b..be53381 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -41,8 +41,8 @@
 #endif
 
 int
-pthread_mutex_timedlock (pthread_mutex_t *mutex,
-			 const struct timespec *abstime)
+__pthread_mutex_timedlock (pthread_mutex_t *mutex,
+			   const struct timespec *abstime)
 {
   int oldval;
   pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
@@ -634,3 +634,4 @@ pthread_mutex_timedlock (pthread_mutex_t *mutex,
  out:
   return result;
 }
+weak_alias (__pthread_mutex_timedlock, pthread_mutex_timedlock)
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index e514997..ec7da61 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -403,6 +403,7 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 
 #ifndef __pthread_mutex_trylock
 #ifndef pthread_mutex_trylock
-strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock)
+weak_alias (__pthread_mutex_trylock, pthread_mutex_trylock)
+hidden_def (__pthread_mutex_trylock)
 #endif
 #endif
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
index f701d4e..e1a8a5c 100644
--- a/nptl/pthread_mutex_unlock.c
+++ b/nptl/pthread_mutex_unlock.c
@@ -346,5 +346,5 @@ __pthread_mutex_unlock (pthread_mutex_t *mutex)
 {
   return __pthread_mutex_unlock_usercnt (mutex, 1);
 }
-strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock)
+weak_alias (__pthread_mutex_unlock, pthread_mutex_unlock)
 hidden_def (__pthread_mutex_unlock)
diff --git a/nptl/pthread_mutexattr_init.c b/nptl/pthread_mutexattr_init.c
index 210d490..dcad522 100644
--- a/nptl/pthread_mutexattr_init.c
+++ b/nptl/pthread_mutexattr_init.c
@@ -33,4 +33,5 @@ __pthread_mutexattr_init (pthread_mutexattr_t *attr)
 
   return 0;
 }
-strong_alias (__pthread_mutexattr_init, pthread_mutexattr_init)
+weak_alias (__pthread_mutexattr_init, pthread_mutexattr_init)
+hidden_def (__pthread_mutexattr_init)
diff --git a/nptl/pthread_mutexattr_settype.c b/nptl/pthread_mutexattr_settype.c
index 8c4d11f..988793b 100644
--- a/nptl/pthread_mutexattr_settype.c
+++ b/nptl/pthread_mutexattr_settype.c
@@ -40,4 +40,5 @@ __pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind)
   return 0;
 }
 weak_alias (__pthread_mutexattr_settype, pthread_mutexattr_setkind_np)
-strong_alias (__pthread_mutexattr_settype, pthread_mutexattr_settype)
+weak_alias (__pthread_mutexattr_settype, pthread_mutexattr_settype)
+hidden_def (__pthread_mutexattr_settype)
diff --git a/nptl/pthread_self.c b/nptl/pthread_self.c
index 4c978e1..8e21775 100644
--- a/nptl/pthread_self.c
+++ b/nptl/pthread_self.c
@@ -25,4 +25,4 @@ __pthread_self (void)
 {
   return (pthread_t) THREAD_SELF;
 }
-strong_alias (__pthread_self, pthread_self)
+weak_alias (__pthread_self, pthread_self)
diff --git a/nptl/pthread_setspecific.c b/nptl/pthread_setspecific.c
index c5416a5..214af3b 100644
--- a/nptl/pthread_setspecific.c
+++ b/nptl/pthread_setspecific.c
@@ -89,5 +89,5 @@ __pthread_setspecific (pthread_key_t key, const void *value)
 
   return 0;
 }
-strong_alias (__pthread_setspecific, pthread_setspecific)
+weak_alias (__pthread_setspecific, pthread_setspecific)
 hidden_def (__pthread_setspecific)
diff --git a/nptl/tpp.c b/nptl/tpp.c
index 57eb026..7eb2b96 100644
--- a/nptl/tpp.c
+++ b/nptl/tpp.c
@@ -43,9 +43,9 @@ void
 __init_sched_fifo_prio (void)
 {
   atomic_store_relaxed (&__sched_fifo_max_prio,
-			sched_get_priority_max (SCHED_FIFO));
+			__sched_get_priority_max (SCHED_FIFO));
   atomic_store_relaxed (&__sched_fifo_min_prio,
-			sched_get_priority_min (SCHED_FIFO));
+			__sched_get_priority_min (SCHED_FIFO));
 }
 
 int
diff --git a/posix/nanosleep.c b/posix/nanosleep.c
index 60a93ca..dbda103 100644
--- a/posix/nanosleep.c
+++ b/posix/nanosleep.c
@@ -29,5 +29,5 @@ __nanosleep (const struct timespec *requested_time,
 }
 stub_warning (nanosleep)
 
-libc_hidden_def (__nanosleep)
+hidden_def (__nanosleep)
 weak_alias (__nanosleep, nanosleep)
diff --git a/sysdeps/posix/gethostname.c b/sysdeps/posix/gethostname.c
index 03a5d3f..a132482 100644
--- a/sysdeps/posix/gethostname.c
+++ b/sysdeps/posix/gethostname.c
@@ -29,7 +29,7 @@ __gethostname (char *name, size_t len)
   struct utsname buf;
   size_t node_len;
 
-  if (uname (&buf))
+  if (__uname (&buf))
     return -1;
 
   node_len = strlen (buf.nodename) + 1;
diff --git a/sysdeps/unix/sysv/linux/aarch64/mmap.c b/sysdeps/unix/sysv/linux/aarch64/mmap.c
index 1dd18f9..7630c15 100644
--- a/sysdeps/unix/sysv/linux/aarch64/mmap.c
+++ b/sysdeps/unix/sysv/linux/aarch64/mmap.c
@@ -26,9 +26,12 @@
 __ptr_t
 __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
 {
-  return (__ptr_t) INLINE_SYSCALL (mmap, 6, addr, len, prot, flags, fd, offset);
+  return (__ptr_t) INLINE_SYSCALL_CALL (mmap, addr, len, prot, flags, fd,
+					offset);
 }
 
 weak_alias (__mmap, mmap)
+libc_hidden_def (__mmap)
 weak_alias (__mmap, mmap64)
 weak_alias (__mmap, __mmap64)
+libc_hidden_def (__mmap64)
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c
index ebeb79b..ca86984 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c
@@ -33,8 +33,9 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
       __set_errno (EINVAL);
       return MAP_FAILED;
     }
-  return (__ptr_t) INLINE_SYSCALL (mmap2, 6, addr, len, prot, flags, fd,
-                                   offset / MMAP_PAGE_UNIT);
+  return (__ptr_t) INLINE_SYSCALL_CALL (mmap2, addr, len, prot, flags, fd,
+					offset / MMAP_PAGE_UNIT);
 }
 
 weak_alias (__mmap, mmap)
+libc_hidden_def (__mmap)
diff --git a/sysdeps/unix/sysv/linux/hppa/mmap.c b/sysdeps/unix/sysv/linux/hppa/mmap.c
index 72957cd..61076b7 100644
--- a/sysdeps/unix/sysv/linux/hppa/mmap.c
+++ b/sysdeps/unix/sysv/linux/hppa/mmap.c
@@ -47,3 +47,4 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
 }
 
 weak_alias (__mmap, mmap)
+libc_hidden_def (__mmap)
diff --git a/sysdeps/unix/sysv/linux/i386/Versions b/sysdeps/unix/sysv/linux/i386/Versions
index f3544ac..b59ace4 100644
--- a/sysdeps/unix/sysv/linux/i386/Versions
+++ b/sysdeps/unix/sysv/linux/i386/Versions
@@ -46,6 +46,6 @@ libc {
     fallocate64;
   }
   GLIBC_PRIVATE {
-    __modify_ldt;
+    __modify_ldt; __uname;
   }
 }
diff --git a/sysdeps/unix/sysv/linux/i386/mmap.c b/sysdeps/unix/sysv/linux/i386/mmap.c
index abf3a26..5da0cd1 100644
--- a/sysdeps/unix/sysv/linux/i386/mmap.c
+++ b/sysdeps/unix/sysv/linux/i386/mmap.c
@@ -34,3 +34,4 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
 }
 
 weak_alias (__mmap, mmap)
+libc_hidden_def (__mmap)
diff --git a/sysdeps/unix/sysv/linux/i386/smp.h b/sysdeps/unix/sysv/linux/i386/smp.h
index 7d1a7f2..3109ea9 100644
--- a/sysdeps/unix/sysv/linux/i386/smp.h
+++ b/sysdeps/unix/sysv/linux/i386/smp.h
@@ -36,7 +36,7 @@ is_smp_system (void)
   char *cp;
 
   /* Try reading the number using `sysctl' first.  */
-  if (uname (&u.uts) == 0)
+  if (__uname (&u.uts) == 0)
     cp = u.uts.version;
   else
     {
diff --git a/sysdeps/unix/sysv/linux/m68k/mmap.S b/sysdeps/unix/sysv/linux/m68k/mmap.S
index eb8e071..36dbf5b 100644
--- a/sysdeps/unix/sysv/linux/m68k/mmap.S
+++ b/sysdeps/unix/sysv/linux/m68k/mmap.S
@@ -40,3 +40,4 @@ ENTRY (__mmap)
 PSEUDO_END (__mmap)
 
 weak_alias (__mmap, mmap)
+libc_hidden_def (__mmap)
diff --git a/sysdeps/unix/sysv/linux/microblaze/mmap.S b/sysdeps/unix/sysv/linux/microblaze/mmap.S
index 0099993..3d71a61 100644
--- a/sysdeps/unix/sysv/linux/microblaze/mmap.S
+++ b/sysdeps/unix/sysv/linux/microblaze/mmap.S
@@ -48,3 +48,4 @@ L(skip):
 PSEUDO_END (__mmap)
 
 weak_alias (__mmap, mmap)
+libc_hidden_def (__mmap)
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c b/sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c
index ca0a5b1..ff587df 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c
@@ -28,8 +28,9 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
   /* To handle negative offsets consistently with other architectures,
      the offset must be zero-extended to 64-bit.  */
   uint64_t offset_adj = (uint64_t) (uint32_t) offset;
-  return (__ptr_t) INLINE_SYSCALL (mmap, 6, addr, len, prot, flags, fd,
-				   offset_adj);
+  return (__ptr_t) INLINE_SYSCALL_CALL (mmap, addr, len, prot, flags, fd,
+					offset_adj);
 }
 
 weak_alias (__mmap, mmap)
+libc_hidden_def (__mmap)
diff --git a/sysdeps/unix/sysv/linux/mmap64.c b/sysdeps/unix/sysv/linux/mmap64.c
index e823600..3d491b4 100644
--- a/sysdeps/unix/sysv/linux/mmap64.c
+++ b/sysdeps/unix/sysv/linux/mmap64.c
@@ -49,9 +49,9 @@ __mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset)
     return (void *) INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
   void *result;
   result = (void *)
-    INLINE_SYSCALL (mmap2, 6, addr,
-		    len, prot, flags, fd,
-		    (off_t) (offset >> page_shift));
+    INLINE_SYSCALL_CALL (mmap2, addr, len, prot, flags, fd,
+			 (off_t) (offset >> page_shift));
   return result;
 }
 weak_alias (__mmap64, mmap64)
+libc_hidden_def (__mmap64)
diff --git a/sysdeps/unix/sysv/linux/powerpc/ioctl.c b/sysdeps/unix/sysv/linux/powerpc/ioctl.c
index e2e3d33..1437d1d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/ioctl.c
+++ b/sysdeps/unix/sysv/linux/powerpc/ioctl.c
@@ -41,15 +41,15 @@ __ioctl (int fd, unsigned long int request, ...)
       break;
 
     case TCSETS:
-      result = tcsetattr (fd, TCSANOW, (struct termios *) arg);
+      result = __tcsetattr (fd, TCSANOW, (struct termios *) arg);
       break;
 
     case TCSETSW:
-      result = tcsetattr (fd, TCSADRAIN, (struct termios *) arg);
+      result = __tcsetattr (fd, TCSADRAIN, (struct termios *) arg);
       break;
 
     case TCSETSF:
-      result = tcsetattr (fd, TCSAFLUSH, (struct termios *) arg);
+      result = __tcsetattr (fd, TCSAFLUSH, (struct termios *) arg);
       break;
 
     default:
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/mmap.S b/sysdeps/unix/sysv/linux/s390/s390-32/mmap.S
index 99b56ed..fa2f128 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/mmap.S
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/mmap.S
@@ -72,3 +72,4 @@ ENTRY(__mmap)
 PSEUDO_END (__mmap)
 
 weak_alias (__mmap, mmap)
+libc_hidden_def (__mmap)
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S b/sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S
index f182578..60277e6 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S
@@ -79,3 +79,4 @@ ENTRY(__mmap64)
 PSEUDO_END (__mmap64)
 
 weak_alias (__mmap64, mmap64)
+libc_hidden_def (__mmap64)
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/mmap.S b/sysdeps/unix/sysv/linux/s390/s390-64/mmap.S
index 06d31bb..105b348 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/mmap.S
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/mmap.S
@@ -73,6 +73,8 @@ ENTRY(__mmap)
 
 PSEUDO_END (__mmap)
 
+libc_hidden_def (__mmap)
 weak_alias (__mmap, mmap)
 weak_alias (__mmap, mmap64)
 weak_alias (__mmap, __mmap64)
+libc_hidden_def (__mmap64)
diff --git a/sysdeps/unix/sysv/linux/tcsetattr.c b/sysdeps/unix/sysv/linux/tcsetattr.c
index c7d1d65..49acd16 100644
--- a/sysdeps/unix/sysv/linux/tcsetattr.c
+++ b/sysdeps/unix/sysv/linux/tcsetattr.c
@@ -41,7 +41,7 @@
 
 /* Set the state of FD to *TERMIOS_P.  */
 int
-tcsetattr (int fd, int optional_actions, const struct termios *termios_p)
+__tcsetattr (int fd, int optional_actions, const struct termios *termios_p)
 {
   struct __kernel_termios k_termios;
   unsigned long int cmd;
@@ -77,4 +77,5 @@ tcsetattr (int fd, int optional_actions, const struct termios *termios_p)
 
   return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
 }
+weak_alias (__tcsetattr, tcsetattr)
 libc_hidden_def (tcsetattr)
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/mmap.c b/sysdeps/unix/sysv/linux/wordsize-64/mmap.c
index a784b62..469213c 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/mmap.c
+++ b/sysdeps/unix/sysv/linux/wordsize-64/mmap.c
@@ -31,10 +31,12 @@ __ptr_t
 __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
 {
   MMAP_PREPARE (addr, len, prot, flags, fd, offset);
-  return (__ptr_t) INLINE_SYSCALL (mmap, 6, addr, len, prot, flags,
-				   fd, offset);
+  return (__ptr_t) INLINE_SYSCALL_CALL (mmap, addr, len, prot, flags,
+					fd, offset);
 }
 
 weak_alias (__mmap, mmap)
+libc_hidden_def (__mmap)
 weak_alias (__mmap, mmap64)
 weak_alias (__mmap, __mmap64)
+libc_hidden_def (__mmap64)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 1/6] Consolidate pthreadtype.h placement
  2017-03-21 13:40 [PATCH v3 0/6] Add support for ISO C11 threads.h Adhemerval Zanella
  2017-03-21 13:40 ` [PATCH 6/6] Add manual documentation for threads.h Adhemerval Zanella
@ 2017-03-21 13:40 ` Adhemerval Zanella
  2017-03-21 13:48   ` Andreas Schwab
  2017-03-21 13:40 ` [PATCH 4/6] Add C11 threads support Adhemerval Zanella
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-21 13:40 UTC (permalink / raw)
  To: libc-alpha

This patch moves all arch specific pthreadtypes.h to a similar path
for all architectures (sysdeps/unix/sysv/<arch>/bits).  No functional
or build change is expected.  The idea is mainly to organize the
header placement for all architectures.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, hppa-linux-gnu, i386-linux-gnu, ia64-linux-gnu,
m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).
---
 ChangeLog                                                      | 10 ++++++++++
 .../{unix/sysv/linux/alpha => alpha/nptl}/bits/pthreadtypes.h  |  0
 .../sysv/linux/powerpc => powerpc/nptl}/bits/pthreadtypes.h    |  0
 sysdeps/unix/sysv/linux/x86/Implies                            |  1 +
 sysdeps/x86/{ => nptl}/bits/pthreadtypes.h                     |  0
 5 files changed, 11 insertions(+)
 rename sysdeps/{unix/sysv/linux/alpha => alpha/nptl}/bits/pthreadtypes.h (100%)
 rename sysdeps/{unix/sysv/linux/powerpc => powerpc/nptl}/bits/pthreadtypes.h (100%)
 create mode 100644 sysdeps/unix/sysv/linux/x86/Implies
 rename sysdeps/x86/{ => nptl}/bits/pthreadtypes.h (100%)

diff --git a/sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h b/sysdeps/alpha/nptl/bits/pthreadtypes.h
similarity index 100%
rename from sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h
rename to sysdeps/alpha/nptl/bits/pthreadtypes.h
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h b/sysdeps/powerpc/nptl/bits/pthreadtypes.h
similarity index 100%
rename from sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h
rename to sysdeps/powerpc/nptl/bits/pthreadtypes.h
diff --git a/sysdeps/unix/sysv/linux/x86/Implies b/sysdeps/unix/sysv/linux/x86/Implies
new file mode 100644
index 0000000..e454b28
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86/Implies
@@ -0,0 +1 @@
+x86/nptl
diff --git a/sysdeps/x86/bits/pthreadtypes.h b/sysdeps/x86/nptl/bits/pthreadtypes.h
similarity index 100%
rename from sysdeps/x86/bits/pthreadtypes.h
rename to sysdeps/x86/nptl/bits/pthreadtypes.h
-- 
2.7.4

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 6/6] Add manual documentation for threads.h
  2017-03-21 13:40 [PATCH v3 0/6] Add support for ISO C11 threads.h Adhemerval Zanella
@ 2017-03-21 13:40 ` Adhemerval Zanella
  2017-03-21 13:40 ` [PATCH 1/6] Consolidate pthreadtype.h placement Adhemerval Zanella
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-21 13:40 UTC (permalink / raw)
  To: libc-alpha; +Cc: Juan Manuel Torres Palma

From: Juan Manuel Torres Palma <j.m.torrespalma@gmail.com>

This patch updates the manual and adds a new chapter to the manual,
explaining types macros, constants and functions defined by ISO C11
threads.h standard.

	* manual/Makefile (chapters): Add isothreads.texi.
	* manual/isothreads.texi: New file. Add new chapter for ISO C11
	threads documentation.
---
 ChangeLog              |   4 +
 manual/Makefile        |   2 +-
 manual/isothreads.texi | 373 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 378 insertions(+), 1 deletion(-)
 create mode 100644 manual/isothreads.texi

diff --git a/manual/Makefile b/manual/Makefile
index 510f160..70811b8 100644
--- a/manual/Makefile
+++ b/manual/Makefile
@@ -39,7 +39,7 @@ chapters = $(addsuffix .texi, \
 		       pipe socket terminal syslog math arith time	\
 		       resource setjmp signal startup process ipc job	\
 		       nss users sysinfo conf crypt debug threads	\
-		       probes tunables)
+		       probes tunables isothreads)
 add-chapters = $(wildcard $(foreach d, $(add-ons), ../$d/$d.texi))
 appendices = lang.texi header.texi install.texi maint.texi platform.texi \
 	     contrib.texi
diff --git a/manual/isothreads.texi b/manual/isothreads.texi
new file mode 100644
index 0000000..418fdd7
--- /dev/null
+++ b/manual/isothreads.texi
@@ -0,0 +1,373 @@
+@node ISO Threads, , , Top
+@chapter ISO C11 threads
+
+This chapter describes @theglibc{} ISO C11 threads implementation.
+To have a deeper understanding of this API, is strongly recomended
+to read ISO/IEC 9899:2011, section 7.26 where ISO C11 threads
+are specified.
+All types and function prototypes are declared in
+@file{threads.h} header.
+@pindex threads.h
+
+@menu
+* Thread Creation and Control:: Support for basic threading.
+* Call Once:: Single call macros and functions.
+* Mutex:: Low level mechanism for mutual exclusion.
+* Condition variable:: High level objects for thread synchronization.
+* Thread-local storage:: Functions to support thread-local storage.
+* C11 error types:: Symbolic constants that represent functions return value.
+@end menu
+
+@node Thread Creation and Control, Call Once, , ISO Threads
+@section Thread Creation and Control
+
+@Theglibc{} implements a set of functions that allow the user
+to easily create and use threads. Many extra functionalities are
+provided to control the behaviour of threads. The following functions
+and types are defined:
+
+@deftp {Data Type} {thrd_t}
+Unique object that identifies a thread
+unequivocally.
+@end deftp
+
+@deftp {Data Type} {thrd_start_t}
+It is a (@code{int (*)(void *)}) typedef that is passed to
+@code{thrd_create} when creating a new thread. Should point
+to the first function that thread will run.
+@end deftp
+
+@deftypefun int thrd_create (thrd_t *@var{thr}, thrd_start_t @var{func}, void *@var{arg})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Create a new thread executing the function @var{func}. The object
+pointed by @var{arg} will be taken as @var{func} arguments. If successful,
+@var{thr} is set to the new thread identifier.
+@end deftypefun
+
+@deftypefun int thrd_equal (thrd_t @var{lhs}, thrd_t @var{rhs})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Checks whether @var{lhs} and @var{rhs} refer to the same thread.
+@end deftypefun
+
+@deftypefun thrd_t thrd_current (void)
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Returns the identifier of the calling thread.
+@end deftypefun
+
+@deftypefun int thrd_sleep (const struct timespec *@var{time_point}, struct timespec *@var{remaining})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Blocks the execution of the current thread for at least until
+the wall-clock time point pointed to by @var{time_point} has been
+reached. This function does not take an absolute time, but a
+duration that the thread is required to be blocked.
+
+The sleep may resume earlier if a signal that is not ignored is
+received. In such case, if remaining is not NULL, the remaining
+time duration is stored into the object pointed to by @var{remaining}
+@end deftypefun
+
+@deftypefun void thrd_yield (void)
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Provides a hint to the implementation to reschedule the execution
+of threads, allowing other threads to run.
+@end deftypefun
+
+@deftypefun _Noreturn void thrd_exit (int @var{res})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Terminates execution of the calling thread and sets its result code
+to @var{res}.
+If this function is called from a single thread process, the call to
+this function is equivalent to @code{exit(0)}.
+Returning from a thread-start function is equivalent to calling
+@code{thrd_exit}.
+@end deftypefun
+
+@deftypefun int thrd_detach (thrd_t @var{thr})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Detaches the thread identified by @var{thr} from the current
+environment.
+The resources held by the thread will be freed automatically once
+the thread exits, thus, the parent thread will never be notified
+by any @var{thr} signal.
+@end deftypefun
+
+@deftypefun int thrd_join (thrd_t @var{thr}, int *@var{res})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Blocks the current thread until the thread identified by @var{thr}
+finishes execution. If @var{res} is not a null pointer, the result
+code of the thread is put to the location pointed to by @var{res}.
+The termination of the thread synchronizes-with the
+completion of this function.
+The behavior is undefined if the thread was previously detached
+or joined by another thread.
+@end deftypefun
+
+@node Call Once, Mutex, Thread Creation and Control, ISO Threads
+@section Call Once
+
+In order to guarantee single access to a function, @theglibc
+implements a call once function to allow unique access in case
+a function is required to be called only once in presence of several
+threads.
+
+@deftp {Data Type} {once_flag}
+Complete object type capable of holding a flag used by @code{call_once}
+@end deftp
+
+@deftypevr Macro {} ONCE_FLAG_INIT
+Value established to initialize an object of type @code{once_flag}.
+@end deftypevr
+
+@deftypefun void call_once (once_flag *@var{flag}, void (*@var{func})(void))
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Calls function @var{func} exactly once, even if invoked from
+several threads. The completion of the function @var{func}
+synchronizes with all previous or subsequent calls to
+@code{call_once} with the same @var{flag} variable.
+@end deftypefun
+
+@node Mutex, Condition variable, Call Once, ISO Threads
+@section Mutex
+
+To have a better control of resources and how threads access them,
+@theglibc{} also implements a mutex object, that allows to
+avoid race conditions and some other concurrency issues.
+
+@deftp {Data Type} {mtx_t}
+Mutex object identifier.
+@end deftp
+
+@deftypefun int mtx_init (mtx_t *@var{mutex}, int @var{type})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Creates a new mutex object with type @var{type}. The object pointed
+to by @var{mutex} is set to an identifier of the newly created mutex.
+@end deftypefun
+
+@deftypefun int mtx_lock (mtx_t *@var{mutex})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Blocks the current thread until the mutex pointed to by @var{mutex}
+is locked.
+The behavior is undefined if the current thread has already
+locked the mutex and the mutex is not recursive.
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
+this operation, and all lock/unlock operations on any given mutex
+form a single total order (similar to the modification order of
+an atomic).
+@end deftypefun
+
+@deftypefun int mtx_timedlock (mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Blocks the current thread until the mutex pointed to by @var{mutex}
+is locked or until the wall-clock time pointed to
+by @var{time_point} has been reached. This function takes
+an absolute time, so if a duration is required, must be calculated
+manually and passed to this function.
+
+The behavior is undefined if the current thread has already
+locked the mutex and the mutex is not recursive.
+The behavior is undefined if the mutex does not support timeout.
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
+this operation (if this operation succeeds), and all lock/unlock
+operations on any given mutex form a single total order
+(similar to the modification order of an atomic).
+@end deftypefun
+
+@deftypefun int mtx_trylock (mtx_t *@var{mutex})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Tries to lock the mutex pointed to by @var{mutex} without blocking.
+Returns immediately if the mutex is already locked.
+Prior calls to @code{mtx_unlock} on the same mutex synchronize-with
+this operation (if this operation succeeds), and all lock/unlock
+operations on any given mutex form a single total order
+(similar to the modification order of an atomic).
+@end deftypefun
+
+@deftypefun int mtx_unlock (mtx_t *@var{mutex})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Unlocks the mutex pointed to by @var{mutex}. The behavior is undefined
+if the mutex is not locked by the calling thread. This function
+synchronizes-with subsequent @code{mtx_lock}, @code{mtx_trylock},
+or @code{mtx_timedlock} on the same mutex. All lock/unlock
+operations on
+any given mutex form a single total order (similar to the
+modification order of an atomic).
+@end deftypefun
+
+@deftypefun void mtx_destroy (mtx_t *@var{mutex})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Destroys the mutex pointed to by @var{mutex}.
+If there are threads waiting on mutex, the behavior is undefined.
+@end deftypefun
+
+The ISO C11 standard also defines several types of mutex that are
+also supported. They are represented with symbolic constants
+(enumeration type values) and are the following:
+
+@vtable @code
+
+@item mtx_plain
+Mutex type that does not support timeout or test and return.
+
+@item mtx_recursive
+Mutex type that supports recursive locking, what means that owner
+thread can lock it twice or more without causing deadlock.
+
+@item mtx_timed
+Mutex type that supports timeout.
+
+@end vtable
+
+@node Condition variable, Thread-local storage, Mutex, ISO Threads
+@section Condition Variable
+
+Mutexes are not the only synchronization mechanisms available. For some
+more complex tasks, @theglibc{} also implements condition variables,
+that allow the user to think in a higher level to solve complex
+synchronization problems. They are used to synchronize threads waiting on
+a certain condition to happen.
+
+@deftp {Data Type} {cnd_t}
+Condition variable object identifier.
+@end deftp
+
+@deftypefun int cnd_init (cnd_t *@var{cond})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Initializes new condition variable. The object pointed to by
+@var{cond} will be set to value that identifies the condition variable.
+@end deftypefun
+
+@deftypefun int cnd_signal (cnd_t *@var{cond})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Unblocks one thread that currently waits on condition variable
+pointed to by @var{cond}. If no threads are blocked, does nothing and
+returns @code{thrd_success}.
+@end deftypefun
+
+@deftypefun int cnd_broadcast (cnd_t *@var{cond})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Unblocks all threads that currently wait on condition variable
+pointed to by @var{cond}. If no threads are blocked, does nothing
+and returns @code{thrd_success}.
+@end deftypefun
+
+@deftypefun int cnd_wait (cnd_t *@var{cond}, mtx_t *@var{mutex})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Atomically unlocks the mutex pointed to by @var{mutex} and blocks on
+the condition variable pointed to by @var{cond} until the thread
+is signalled by @code{cnd_signal} or @code{cnd_broadcast}. The
+mutex is locked again before the function returns.
+@end deftypefun
+
+@deftypefun int cnd_timedwait (cnd_t *restrict @var{cond}, mtx_t *restrict @var{mutex}, const struct timespec *restrict @var{time_point})
+@safety{@prelim{}@mtsafe{}@asunsafe{@asulock{}}@acunsafe{@aculock{}}}
+Atomically unlocks the mutex pointed to by @var{mutex} and blocks on the
+condition variable pointed to by @var{cond} until the thread is signalled
+by @code{cnd_signal} or @code{cnd_broadcast}, or until the wall-clock time
+pointed to by @var{time_point} has been reached. The mutex
+is locked again before the function returns.
+Again, this function takes an absolute time rather than a duration.
+@end deftypefun
+
+@deftypefun void cnd_destroy (cnd_t *@var{cond})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Destroys the condition variable pointed to by @var{cond}.
+If there are threads waiting on @var{cond}, the behavior is undefined.
+@end deftypefun
+
+@node Thread-local storage, C11 error types, Condition variable, ISO Threads
+@section Thread-local Storage
+
+@Theglibc{} also implements different functions that adds
+funtionality for thread-local storage. That means that each thread can
+have their own variables and are not visible by other threads. The
+functions and types provided are:
+
+@deftp {Data Type} {tss_t}
+Thread-specific storage object. Even if shared, every thread will have
+its own instance of that variable with different values.
+@end deftp
+
+@deftp {Data Type} {tss_dtor_t}
+Function pointer of type @code{void(*)(void*)}, used for TSS destructor.
+This function will be called when the current thread calls @code{thrd_exit},
+but never when calling @code{tss_delete} or @code{exit}
+@end deftp
+
+@deftypevr Macro {} thread_local
+Used to mark a variable with thread storage duration, that means created
+when the thread starts, and cleaned up when the thread ends.
+@end deftypevr
+
+@deftypevr Macro {} TSS_DTOR_ITERATIONS
+Integer constant expression representing the maximum number of
+times that destructors will be called when a thread terminates.
+@end deftypevr
+
+@deftypefun int tss_create (tss_t *@var{tss_key}, tss_dtor_t @var{destructor})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Creates new thread-specific storage key and stores it in the object
+pointed to by @var{tss_key}. Although the same key value may be used
+by different threads, the values bound to the key by @code{tss_set}
+are maintained on a per-thread basis and persist for the life
+of the calling thread.
+
+If @var{destructor} is different to NULL, a destructor function will
+be set, and called when the thread finishes its execution by calling
+@code{thrd_exit}.
+@end deftypefun
+
+@deftypefun void *tss_get (tss_t @var{tss_key})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Returns the value held in thread-specific storage for the current
+thread identified by @var{tss_key}. Different threads
+may get different values identified by the same key.
+@end deftypefun
+
+@deftypefun int tss_set (tss_t @var{tss_id}, void *@var{val})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Sets the value of the thread-specific storage identified by
+@var{tss_id} for the current thread to @var{val}. Different threads
+may set different values to the same key.
+The destructor, if available, is not invoked.
+@end deftypefun
+
+@deftypefun void tss_delete (tss_t @var{tss_id})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+Destroys the thread-specific storage identified by @var{tss_id}.
+The destructor, if one was registered by @code{tss_create}, is not
+called.
+@end deftypefun
+
+@node C11 error types, , Thread-local storage, ISO Threads
+@section Error Types
+
+The ISO C11 specification also provides new error types that belong
+specifically to @code{threads.h}. @Theglibc{} has also implemented
+this feature and every function in this API always returns one of the
+following error codes:
+
+
+@vtable @code
+
+@item thrd_timedout
+Value returned by a function to indicate that a specified time was
+reached without acquiring the requested resource, usually a mutex
+or condition variable.
+
+@item thrd_sucess
+Value returned by a function to indicate that the requested operation
+succeded.
+
+@item thrd_busy
+Value returned by a function to indicate that the requested operation
+failed because a resource requested is already in use.
+
+@item thrd_error
+Value returned by a function to indicate that the requested operation
+failed.
+
+@item thrd_nomem
+Value returned by a function to indicate that the requested operation
+failed because it was unable to allocate enough memory.
+
+@end vtable
-- 
2.7.4

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 4/6] Add C11 threads support
  2017-03-21 13:40 [PATCH v3 0/6] Add support for ISO C11 threads.h Adhemerval Zanella
  2017-03-21 13:40 ` [PATCH 6/6] Add manual documentation for threads.h Adhemerval Zanella
  2017-03-21 13:40 ` [PATCH 1/6] Consolidate pthreadtype.h placement Adhemerval Zanella
@ 2017-03-21 13:40 ` Adhemerval Zanella
  2017-03-21 13:40 ` [PATCH 3/6] Clean pthread functions namespaces for C11 threads Adhemerval Zanella
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-21 13:40 UTC (permalink / raw)
  To: libc-alpha

This patch adds C11 threads support (ISO/IEC 9899:2011) based on the
public available n1570 [1].  Since I do not have access to the official
ISO documentation I would ask if there any deviation from the draft
to final doc regarding threads.h please let me know.  However based on
Joseph's comments on a old thread [2] I would expect to N1570 and final
standart to not have any technical differences.

Mostly of the definition required are defined based on POSIX counterparts,
such as thrd_t (pthread_t), once_flag (pthread_once_t), tss_t (pthread_key_t).
The mut_t and cnd_t is also based on internal pthreads fields, but with a
distinct internal layout to avoid possible issues with code interchange
(such as trying to pass POSIX structure on C11 functions and to avoid inclusion
of pthread.h).  The idea is to make it possible to share POSIX internal
implementation for mostly of the code making adjust where only required.

For mostly symbol implementations, direct POSIX pthread internal calls
are used with some exceptions:

  1. thrd_start uses pthread_create internal implementation, but changes
     how to actually calls the start routine.  This is due the difference
     in signature between POSIX and C11, where former return a 'void *'
     and latter 'int'.
     To avoid calling convention issues due 'void *' to int cast, routines
     from C11 threads are started slight different than default pthread one.
     Explicit cast to expected return are used internally on pthread_create
     and the result is stored back to void also with an explicit cast.

  2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering
     errno and to handle expected standard return codes.

  3. thrd_yield also uses internal direct syscall to avoid errno clobbering.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, hppa-linux-gnu, i386-linux-gnu, ia64-linux-gnu,
m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

[1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
[2] https://sourceware.org/ml/libc-alpha/2011-12/msg00060.html

	* conform/Makefile (conformtest-headers-ISO11): Add threads.h.
	(linknamespace-libs-ISO11): Add libpthread.a.
	* include/stdc-predef.h (__STDC_NO_THREADS__): Remove definition.
	* nptl/Makefile (headers): Add threads.h.
	(libpthread-routines): Add new C11 thread objects.
	* nptl/Versions (libpthread) [GLIBC_2.25]): Add C11 thread symbols.
	* conform/data/threads.h-data: New file.
	* nptl/call_once.c: Likewise.
	* nptl/cnd_broadcast.c: Likewise.
	* nptl/cnd_destroy.c: Likewise.
	* nptl/cnd_init.c: Likewise.
	* nptl/cnd_signal.c: Likewise.
	* nptl/cnd_timedwait.c: Likewise.
	* nptl/cnd_wait.c: Likewise.
	* nptl/mtx_destroy.c: Likewise.
	* nptl/mtx_init.c: Likewise.
	* nptl/mtx_lock.c: Likewise.
	* nptl/mtx_timedlock.c: Likewise.
	* nptl/mtx_trylock.c: Likewise.
	* nptl/mtx_unlock.c: Likewise.
	* nptl/thrd_create.c: Likewise.
	* nptl/thrd_current.c: Likewise.
	* nptl/thrd_detach.c: Likewise.
	* nptl/thrd_equal.c: Likewise.
	* nptl/thrd_exit.c: Likewise.
	* nptl/thrd_join.c: Likewise.
	* nptl/thrd_priv.h: Likewise.
	* nptl/thrd_sleep.c: Likewise.
	* nptl/thrd_yield.c: Likewise.
	* nptl/tss_create.c: Likewise.
	* nptl/tss_delete.c: Likewise.
	* nptl/tss_get.c: Likewise.
	* nptl/tss_set.c: Likewise.
	* nptl/descr.h (pthread): Add c11 field.
	* nptl/pthreadP.h (ATTR_C11_THREAD): New define.
	* nptl/pthread_create.c (START_THREAD_DEFN): Call C11 thread start
	routine with expected function prototype.
	(__pthread_create_2_1): Add C11 threads check based on attribute
	value.
	* sysdeps/nptl/threads.h: New file.
	* sysdeps/i386/nptl/tls.h (CALL_THREAD_FCT): Add C11 support.
	* sysdeps/x86_64/nptl/tls.h (CALL_THREAD_FCT): Likewise.
	* sysdeps/x86_64/x32/nptl/tls.h (CALL_THREAD_FCT): Likewise.
	* sysdeps/aarch64/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	New define.
	* sysdeps/alpha/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/arm/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/hppa/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/ia64/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/m68k/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/microblaze/nptl/bits/thread-shared-types.h
	(_ONCE_FLAG_ALIGN): Likewise.
	* sysdeps/mips/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/nios2/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/powerpc/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/s390/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/sh/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/sparc/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/tile/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/x86/nptl/bits/thread-shared-types.h (_ONCE_FLAG_ALIGN):
	Likewise.
	* sysdeps/nacl/libpthread.abilist: Add C11 thread symbols.
	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist:
	Likewise.
	* sysdpes/unix/sysv/linux/s390/s390-32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist: Likewise.
---
 ChangeLog                                          | 105 +++++++++++
 conform/Makefile                                   |   7 +-
 conform/data/threads.h-data                        |  56 ++++++
 include/stdc-predef.h                              |   3 -
 nptl/Makefile                                      |  12 +-
 nptl/Versions                                      |  16 ++
 nptl/call_once.c                                   |  27 +++
 nptl/cnd_broadcast.c                               |  28 +++
 nptl/cnd_destroy.c                                 |  28 +++
 nptl/cnd_init.c                                    |  27 +++
 nptl/cnd_signal.c                                  |  28 +++
 nptl/cnd_timedwait.c                               |  32 ++++
 nptl/cnd_wait.c                                    |  28 +++
 nptl/descr.h                                       |   1 +
 nptl/mtx_destroy.c                                 |  27 +++
 nptl/mtx_init.c                                    |  48 +++++
 nptl/mtx_lock.c                                    |  29 +++
 nptl/mtx_timedlock.c                               |  31 ++++
 nptl/mtx_trylock.c                                 |  29 +++
 nptl/mtx_unlock.c                                  |  28 +++
 nptl/pthreadP.h                                    |   3 +
 nptl/pthread_create.c                              |  21 ++-
 nptl/thrd_create.c                                 |  30 ++++
 nptl/thrd_current.c                                |  26 +++
 nptl/thrd_detach.c                                 |  30 ++++
 nptl/thrd_equal.c                                  |  26 +++
 nptl/thrd_exit.c                                   |  27 +++
 nptl/thrd_join.c                                   |  32 ++++
 nptl/thrd_priv.h                                   |  46 +++++
 nptl/thrd_sleep.c                                  |  41 +++++
 nptl/thrd_yield.c                                  |  29 +++
 nptl/tss_create.c                                  |  29 +++
 nptl/tss_delete.c                                  |  27 +++
 nptl/tss_get.c                                     |  27 +++
 nptl/tss_set.c                                     |  28 +++
 sysdeps/aarch64/nptl/bits/thread-shared-types.h    |   3 +
 sysdeps/alpha/nptl/bits/thread-shared-types.h      |   3 +
 sysdeps/arm/nptl/bits/thread-shared-types.h        |   3 +
 sysdeps/hppa/nptl/bits/thread-shared-types.h       |   3 +
 sysdeps/i386/nptl/tls.h                            |   2 +-
 sysdeps/ia64/nptl/bits/thread-shared-types.h       |   3 +
 sysdeps/m68k/nptl/bits/thread-shared-types.h       |   3 +
 sysdeps/microblaze/nptl/bits/thread-shared-types.h |   3 +
 sysdeps/mips/nptl/bits/thread-shared-types.h       |   3 +
 sysdeps/nacl/libpthread.abilist                    |  26 +++
 sysdeps/nios2/nptl/bits/thread-shared-types.h      |   3 +
 sysdeps/nptl/threads.h                             | 198 +++++++++++++++++++++
 sysdeps/powerpc/nptl/bits/thread-shared-types.h    |   3 +
 sysdeps/s390/nptl/bits/thread-shared-types.h       |   3 +
 sysdeps/sh/nptl/bits/thread-shared-types.h         |   4 +
 sysdeps/sparc/nptl/bits/thread-shared-types.h      |   4 +
 sysdeps/tile/nptl/bits/thread-shared-types.h       |   4 +
 sysdeps/unix/sysv/linux/aarch64/libpthread.abilist |  26 +++
 sysdeps/unix/sysv/linux/alpha/libpthread.abilist   |  26 +++
 sysdeps/unix/sysv/linux/arm/libpthread.abilist     |  26 +++
 sysdeps/unix/sysv/linux/hppa/libpthread.abilist    |  26 +++
 sysdeps/unix/sysv/linux/i386/libpthread.abilist    |  26 +++
 sysdeps/unix/sysv/linux/ia64/libpthread.abilist    |  26 +++
 .../sysv/linux/m68k/coldfire/libpthread.abilist    |  26 +++
 .../unix/sysv/linux/m68k/m680x0/libpthread.abilist |  26 +++
 .../unix/sysv/linux/microblaze/libpthread.abilist  |  26 +++
 .../unix/sysv/linux/mips/mips32/libpthread.abilist |  26 +++
 .../unix/sysv/linux/mips/mips64/libpthread.abilist |  26 +++
 sysdeps/unix/sysv/linux/nios2/libpthread.abilist   |  26 +++
 .../linux/powerpc/powerpc32/libpthread.abilist     |  26 +++
 .../linux/powerpc/powerpc64/libpthread-le.abilist  |  26 +++
 .../linux/powerpc/powerpc64/libpthread.abilist     |  26 +++
 .../sysv/linux/s390/s390-32/libpthread.abilist     |  26 +++
 .../sysv/linux/s390/s390-64/libpthread.abilist     |  26 +++
 sysdeps/unix/sysv/linux/sh/libpthread.abilist      |  26 +++
 .../sysv/linux/sparc/sparc32/libpthread.abilist    |  26 +++
 .../sysv/linux/sparc/sparc64/libpthread.abilist    |  26 +++
 .../linux/tile/tilegx/tilegx32/libpthread.abilist  |  26 +++
 .../linux/tile/tilegx/tilegx64/libpthread.abilist  |  26 +++
 .../sysv/linux/tile/tilepro/libpthread.abilist     |  26 +++
 .../unix/sysv/linux/x86_64/64/libpthread.abilist   |  26 +++
 .../unix/sysv/linux/x86_64/x32/libpthread.abilist  |  26 +++
 sysdeps/x86/nptl/bits/thread-shared-types.h        |   3 +
 sysdeps/x86_64/nptl/tls.h                          |   6 +-
 sysdeps/x86_64/x32/nptl/tls.h                      |   2 +-
 80 files changed, 1928 insertions(+), 16 deletions(-)
 create mode 100644 conform/data/threads.h-data
 create mode 100644 nptl/call_once.c
 create mode 100644 nptl/cnd_broadcast.c
 create mode 100644 nptl/cnd_destroy.c
 create mode 100644 nptl/cnd_init.c
 create mode 100644 nptl/cnd_signal.c
 create mode 100644 nptl/cnd_timedwait.c
 create mode 100644 nptl/cnd_wait.c
 create mode 100644 nptl/mtx_destroy.c
 create mode 100644 nptl/mtx_init.c
 create mode 100644 nptl/mtx_lock.c
 create mode 100644 nptl/mtx_timedlock.c
 create mode 100644 nptl/mtx_trylock.c
 create mode 100644 nptl/mtx_unlock.c
 create mode 100644 nptl/thrd_create.c
 create mode 100644 nptl/thrd_current.c
 create mode 100644 nptl/thrd_detach.c
 create mode 100644 nptl/thrd_equal.c
 create mode 100644 nptl/thrd_exit.c
 create mode 100644 nptl/thrd_join.c
 create mode 100644 nptl/thrd_priv.h
 create mode 100644 nptl/thrd_sleep.c
 create mode 100644 nptl/thrd_yield.c
 create mode 100644 nptl/tss_create.c
 create mode 100644 nptl/tss_delete.c
 create mode 100644 nptl/tss_get.c
 create mode 100644 nptl/tss_set.c
 create mode 100644 sysdeps/nptl/threads.h

diff --git a/conform/Makefile b/conform/Makefile
index b393641..dc3a030 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -34,9 +34,9 @@ conformtest-headers-ISO := assert.h ctype.h errno.h float.h limits.h locale.h \
 conformtest-headers-ISO99 := $(conformtest-headers-ISO) complex.h fenv.h \
 			     inttypes.h iso646.h stdbool.h stdint.h tgmath.h \
 			     wchar.h wctype.h
-# Missing ISO11 expectations for: stdatomic.h threads.h.
+# Missing ISO11 expectations for: stdatomic.h
 conformtest-headers-ISO11 := $(conformtest-headers-ISO99) stdalign.h \
-			     stdnoreturn.h uchar.h
+			     stdnoreturn.h uchar.h threads.h
 conformtest-headers-POSIX := $(conformtest-headers-ISO) aio.h dirent.h \
 			     fcntl.h fnmatch.h glob.h grp.h mqueue.h \
 			     pthread.h pwd.h regex.h sched.h semaphore.h \
@@ -217,7 +217,8 @@ linknamespace-libs-xsi = $(linknamespace-libs-posix) \
 			 $(common-objpfx)crypt/libcrypt.a
 linknamespace-libs-ISO = $(linknamespace-libs-isoc)
 linknamespace-libs-ISO99 = $(linknamespace-libs-isoc)
-linknamespace-libs-ISO11 = $(linknamespace-libs-isoc)
+linknamespace-libs-ISO11 = $(linknamespace-libs-isoc) \
+			   $(common-objpfx)nptl/libpthread.a
 linknamespace-libs-XPG3 = $(linknamespace-libs-isoc) \
 			  $(common-objpfx)crypt/libcrypt.a
 linknamespace-libs-XPG4 = $(linknamespace-libs-XPG3)
diff --git a/conform/data/threads.h-data b/conform/data/threads.h-data
new file mode 100644
index 0000000..a4a0ac1
--- /dev/null
+++ b/conform/data/threads.h-data
@@ -0,0 +1,56 @@
+#if defined ISO11
+
+macro ONCE_FLAG_INIT
+macro thread_local
+macro TSS_DTOR_ITERATIONS
+
+constant thrd_success
+constant thrd_busy
+constant thrd_error
+constant thrd_nomem
+constant thrd_timedout
+
+constant mtx_plain
+constant mtx_recursive
+constant mtx_timed
+
+type thrd_t
+type thrd_start_t
+type mtx_t
+type cnd_t
+type once_flag
+type tss_t
+type tss_dtor_t
+
+function int thrd_create (thrd_t*, thrd_start_t, void*)
+function int thrd_equal (thrd_t, thrd_t)
+function thrd_t thrd_current (void)
+function int thrd_sleep (const struct timespec*, struct timespec*)
+function void thrd_exit (int)
+function int thrd_detach (thrd_t)
+function int thrd_join (thrd_t, int*)
+function void thrd_yield (void)
+
+function int mtx_init (mtx_t*, int)
+function int mtx_lock (mtx_t*)
+function int mtx_timedlock (mtx_t*, const struct timespec*)
+function int mtx_trylock (mtx_t*)
+function int mtx_unlock (mtx_t*)
+function void mtx_destroy (mtx_t*)
+
+function void call_once (once_flag*, void (*)(void))
+function int cnd_init (cnd_t*)
+function int cnd_signal (cnd_t*)
+function int cnd_broadcast (cnd_t*)
+function int cnd_wait (cnd_t*, mtx_t*)
+function int cnd_timedwait (cnd_t*, mtx_t*, const struct timespec*)
+function void cnd_destroy (cnd_t*)
+
+function int tss_create (tss_t*, tss_dtor_t)
+function {void*} tss_get (tss_t)
+function int tss_set (tss_t, void*)
+function void tss_delete (tss_t)
+
+#include "time.h-data"
+
+#endif
diff --git a/include/stdc-predef.h b/include/stdc-predef.h
index a2e148c..94ed385 100644
--- a/include/stdc-predef.h
+++ b/include/stdc-predef.h
@@ -56,7 +56,4 @@
    see https://www.iso.org/obp/ui/#iso:std:iso-iec:10646:ed-4:v1:amd:2:v1:en) */
 #define __STDC_ISO_10646__		201605L
 
-/* We do not support C11 <threads.h>.  */
-#define __STDC_NO_THREADS__		1
-
 #endif
diff --git a/nptl/Makefile b/nptl/Makefile
index 6d48c0c..d28dbba 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -22,7 +22,7 @@ subdir	:= nptl
 
 include ../Makeconfig
 
-headers := pthread.h semaphore.h bits/semaphore.h
+headers := pthread.h semaphore.h bits/semaphore.h threads.h
 
 extra-libs := libpthread
 extra-libs-others := $(extra-libs)
@@ -138,7 +138,15 @@ libpthread-routines = nptl-init vars events version pt-interp \
 		      pthread_mutex_getprioceiling \
 		      pthread_mutex_setprioceiling \
 		      pthread_setname pthread_getname \
-		      pthread_setattr_default_np pthread_getattr_default_np
+		      pthread_setattr_default_np pthread_getattr_default_np \
+		      pthread_setattr_default_np pthread_getattr_default_np \
+		      thrd_create thrd_current thrd_detach thrd_equal \
+		      thrd_exit thrd_join thrd_sleep thrd_yield \
+		      call_once cnd_broadcast cnd_destroy cnd_init \
+		      cnd_signal cnd_timedwait cnd_wait \
+		      mtx_destroy mtx_init mtx_lock mtx_timedlock \
+		      mtx_trylock mtx_unlock \
+		      tss_create tss_delete tss_get tss_set
 #		      pthread_setuid pthread_seteuid pthread_setreuid \
 #		      pthread_setresuid \
 #		      pthread_setgid pthread_setegid pthread_setregid \
diff --git a/nptl/Versions b/nptl/Versions
index 0ae5def..6e1be0c 100644
--- a/nptl/Versions
+++ b/nptl/Versions
@@ -265,6 +265,22 @@ libpthread {
   GLIBC_2.22 {
   }
 
+  # C11 thread symbols.
+  GLIBC_2.26 {
+    thrd_create; thrd_current;
+    thrd_detach; thrd_equal;
+    thrd_exit; thrd_join;
+    thrd_sleep; thrd_yield;
+    call_once; cnd_broadcast;
+    cnd_destroy; cnd_init;
+    cnd_signal; cnd_timedwait;
+    cnd_wait; mtx_destroy;
+    mtx_init; mtx_lock;
+    mtx_timedlock; mtx_trylock;
+    mtx_unlock; tss_create;
+    tss_delete; tss_get; tss_set;
+  };
+
   GLIBC_PRIVATE {
     __pthread_initialize_minimal;
     __pthread_clock_gettime; __pthread_clock_settime;
diff --git a/nptl/call_once.c b/nptl/call_once.c
new file mode 100644
index 0000000..6af1fda
--- /dev/null
+++ b/nptl/call_once.c
@@ -0,0 +1,27 @@
+/* C11 threads call once implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Call function func exactly once, even if invoked from several
+   threads. However, all calls must be made with the same flag object.  */
+void
+call_once (once_flag *flag, void (*func)(void))
+{
+  __pthread_once (flag, func);
+}
diff --git a/nptl/cnd_broadcast.c b/nptl/cnd_broadcast.c
new file mode 100644
index 0000000..f870bd5
--- /dev/null
+++ b/nptl/cnd_broadcast.c
@@ -0,0 +1,28 @@
+/* C11 thread condition broadcast implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Unblock all threads currently waiting on condition
+   variable pointed to by cond.  */
+int
+cnd_broadcast (cnd_t *cond)
+{
+  int err_code = __pthread_cond_broadcast ((pthread_cond_t*) cond);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_destroy.c b/nptl/cnd_destroy.c
new file mode 100644
index 0000000..9ab9bb4
--- /dev/null
+++ b/nptl/cnd_destroy.c
@@ -0,0 +1,28 @@
+/* C11 threads condition destroy implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+#include "pthreadP.h"
+
+/* Destroy condition variable pointed to by cond
+   and free all of its resources.  */
+void
+cnd_destroy (cnd_t *cond)
+{
+  __pthread_cond_destroy ((pthread_cond_t *) cond);
+}
diff --git a/nptl/cnd_init.c b/nptl/cnd_init.c
new file mode 100644
index 0000000..df0bb5f
--- /dev/null
+++ b/nptl/cnd_init.c
@@ -0,0 +1,27 @@
+/* C11 thread condition initialization implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Initialize new condition variable pointed by cond.  */
+int
+cnd_init (cnd_t *cond)
+{
+  int err_code = __pthread_cond_init ((pthread_cond_t *)cond, NULL);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_signal.c b/nptl/cnd_signal.c
new file mode 100644
index 0000000..cf78893
--- /dev/null
+++ b/nptl/cnd_signal.c
@@ -0,0 +1,28 @@
+/* C11 threads conditional signal implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Unblock one thread that currently waits on condition
+   variable pointed to by cond.  */
+int
+cnd_signal (cnd_t *cond)
+{
+  int err_code = __pthread_cond_signal ((pthread_cond_t *) cond);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_timedwait.c b/nptl/cnd_timedwait.c
new file mode 100644
index 0000000..7da87d1
--- /dev/null
+++ b/nptl/cnd_timedwait.c
@@ -0,0 +1,32 @@
+/* C11 threads condition timed wait implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Block current thread on the condition variable until
+   condition variable pointed on by cond is signalled
+   or time pointed by time_point is reached.  */
+int
+cnd_timedwait (cnd_t *restrict cond, mtx_t *restrict mutex,
+		const struct timespec* restrict time_point)
+{
+  int err_code = __pthread_cond_timedwait ((pthread_cond_t *) cond,
+					   (pthread_mutex_t *) mutex,
+					   time_point);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/cnd_wait.c b/nptl/cnd_wait.c
new file mode 100644
index 0000000..70924c1
--- /dev/null
+++ b/nptl/cnd_wait.c
@@ -0,0 +1,28 @@
+/* C11 threads condition wait implementaiton.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Block current thread on the condition variable pointed to by cond.  */
+int
+cnd_wait (cnd_t *cond, mtx_t *mutex)
+{
+  int err_code = __pthread_cond_wait ((pthread_cond_t *) cond,
+				      (pthread_mutex_t *) mutex);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/descr.h b/nptl/descr.h
index a145860..c6bf99d 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -373,6 +373,7 @@ struct pthread
      to the function.  */
   void *(*start_routine) (void *);
   void *arg;
+  bool c11;
 
   /* Debug state.  */
   td_eventbuf_t eventbuf;
diff --git a/nptl/mtx_destroy.c b/nptl/mtx_destroy.c
new file mode 100644
index 0000000..1fcc534
--- /dev/null
+++ b/nptl/mtx_destroy.c
@@ -0,0 +1,27 @@
+/* C11 threads mutex destroy implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+#include "pthreadP.h"
+
+/* Destroy the mutex object pointed by mutex.  */
+void
+mtx_destroy (mtx_t *mutex)
+{
+  __pthread_mutex_destroy ((pthread_mutex_t *) mutex);
+}
diff --git a/nptl/mtx_init.c b/nptl/mtx_init.c
new file mode 100644
index 0000000..cd9f77e
--- /dev/null
+++ b/nptl/mtx_init.c
@@ -0,0 +1,48 @@
+/* C11 threads mutex initialization implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Creates a new mutex object with type __type.  If successful new object
+   is pointed by __mutex.  */
+int
+mtx_init (mtx_t *mutex, int type)
+{
+  pthread_mutexattr_t attr;
+
+  __pthread_mutexattr_init (&attr);
+
+  /* Another possible solution would be to set the flags directly in
+     mutex object. */
+  switch (type)
+  {
+    case mtx_plain | mtx_recursive:
+    case mtx_timed | mtx_recursive:
+      __pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
+      break;
+    case mtx_plain:
+    case mtx_timed: /* No difference between both in standard */
+    default:
+      __pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_NORMAL);
+      break;
+  }
+
+  int err_code = __pthread_mutex_init ((pthread_mutex_t *) mutex, &attr);
+  /* pthread_mutexattr_destroy implementation is empty.  */
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/mtx_lock.c b/nptl/mtx_lock.c
new file mode 100644
index 0000000..3a20f41
--- /dev/null
+++ b/nptl/mtx_lock.c
@@ -0,0 +1,29 @@
+/* C11 threads mutex lock implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Block the current thread until the mutex pointed to by __mutex is
+   unlocked. In case the mutex is free, the current thread will not
+   be blocked.  */
+int
+mtx_lock (mtx_t *mutex)
+{
+  int err_code = __pthread_mutex_lock ((pthread_mutex_t *) mutex);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/mtx_timedlock.c b/nptl/mtx_timedlock.c
new file mode 100644
index 0000000..9834162
--- /dev/null
+++ b/nptl/mtx_timedlock.c
@@ -0,0 +1,31 @@
+/* C11 threads mutex timed lock implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Block the current thread until the mutex pointed to  by mutex is unlocked
+   or time pointed by time_point is reached. In case the mutex is free, the
+   current thread will not be blocked.  */
+int
+mtx_timedlock (mtx_t *restrict mutex,
+	       const struct timespec *restrict time_point)
+{
+  int err_code = __pthread_mutex_timedlock ((pthread_mutex_t *)mutex,
+					    time_point);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/mtx_trylock.c b/nptl/mtx_trylock.c
new file mode 100644
index 0000000..75d09c1
--- /dev/null
+++ b/nptl/mtx_trylock.c
@@ -0,0 +1,29 @@
+/* C11 threads mutex try lock implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Try to lock the mutex pointed by mutex without blocking.
+   If the mutex is free, current threads takes control of it, and
+   if it's not, returns immediately.  */
+int
+mtx_trylock (mtx_t *mutex)
+{
+  int err_code = __pthread_mutex_trylock ((pthread_mutex_t *) mutex);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/mtx_unlock.c b/nptl/mtx_unlock.c
new file mode 100644
index 0000000..33f5ddb
--- /dev/null
+++ b/nptl/mtx_unlock.c
@@ -0,0 +1,28 @@
+/* C11 threads mutex unlock implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Unlock the mutex pointed to by mutex, what can lead to
+   awaking other threads waiting on this mutex.  */
+int
+mtx_unlock (mtx_t *mutex)
+{
+  int err_code = __pthread_mutex_unlock ((pthread_mutex_t *) mutex);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index c4f8879..6369776 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -173,6 +173,9 @@ enum
 #define __PTHREAD_ONCE_DONE		2
 #define __PTHREAD_ONCE_FORK_GEN_INCR	4
 
+/* Attribute to indicate thread creation was issued from C11 thrd_create.  */
+#define ATTR_C11_THREAD ((void*)(uintptr_t)-1)
+
 
 /* Condition variable definitions.  See __pthread_cond_wait_common.
    Need to be defined here so there is one place from which
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index b303557..d76347f 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -452,11 +452,24 @@ START_THREAD_DEFN
       LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg);
 
       /* Run the code the user provided.  */
+      void *ret;
 #ifdef CALL_THREAD_FCT
-      THREAD_SETMEM (pd, result, CALL_THREAD_FCT (pd));
+      ret = CALL_THREAD_FCT (pd, pd->c11);
 #else
-      THREAD_SETMEM (pd, result, pd->start_routine (pd->arg));
+      if (pd->c11)
+	{
+	  /* The function pointer for the the c11 thread start is cast to
+	     an incorrect type on __pthread_create_2_1 call, however it is
+	     casted back to correct one so the call behavior is
+	     well-defined (it is assumed that pointers to void are able to
+	     represent all values of int.  */
+	  int (*start)(void*) = (int (*) (void*)) pd->start_routine;
+	  ret = (void*) (intptr_t) start (pd->arg);
+	}
+      else
+	ret = pd->start_routine (pd->arg);
 #endif
+      THREAD_SETMEM (pd, result, ret);
     }
 
   /* Call destructors for the thread_local TLS variables.  */
@@ -632,7 +645,8 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
   const struct pthread_attr *iattr = (struct pthread_attr *) attr;
   struct pthread_attr default_attr;
   bool free_cpuset = false;
-  if (iattr == NULL)
+  bool c11 = (attr == ATTR_C11_THREAD);
+  if (iattr == NULL || c11)
     {
       lll_lock (__default_pthread_attr_lock, LLL_PRIVATE);
       default_attr = __default_pthread_attr;
@@ -690,6 +704,7 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
      get the information from its thread descriptor.  */
   pd->start_routine = start_routine;
   pd->arg = arg;
+  pd->c11 = c11;
 
   /* Copy the thread attribute flags.  */
   struct pthread *self = THREAD_SELF;
diff --git a/nptl/thrd_create.c b/nptl/thrd_create.c
new file mode 100644
index 0000000..5443d67
--- /dev/null
+++ b/nptl/thrd_create.c
@@ -0,0 +1,30 @@
+/* C11 threads thread creation implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Create a new thread executing the function __func. Arguments to __func
+   are passed through __arg. If succesful, __thr is set to new
+   thread identifier.  */
+int
+thrd_create (thrd_t *thr, thrd_start_t func, void *arg)
+{
+  int err_code = __pthread_create_2_1 (thr, ATTR_C11_THREAD, 
+				       (void* (*) (void*))func, arg);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/thrd_current.c b/nptl/thrd_current.c
new file mode 100644
index 0000000..7269d4b
--- /dev/null
+++ b/nptl/thrd_current.c
@@ -0,0 +1,26 @@
+/* C11 threads current thread implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Return current thread identifier.  */
+thrd_t
+thrd_current (void)
+{
+  return __pthread_self ();
+}
diff --git a/nptl/thrd_detach.c b/nptl/thrd_detach.c
new file mode 100644
index 0000000..07f0707
--- /dev/null
+++ b/nptl/thrd_detach.c
@@ -0,0 +1,30 @@
+/* C11 threads thread detach implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Detache the thread identified by __thr from the current environment.
+   That means we cannot join or wait for __thr to finish it's execution.  */
+int
+thrd_detach (thrd_t thr)
+{
+  int err_code;
+
+  err_code = __pthread_detach (thr);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/thrd_equal.c b/nptl/thrd_equal.c
new file mode 100644
index 0000000..fcda488
--- /dev/null
+++ b/nptl/thrd_equal.c
@@ -0,0 +1,26 @@
+/* C11 threads thread equality check implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Check if lhs and rhs point to the same thread.  */
+int
+thrd_equal (thrd_t lhs, thrd_t rhs)
+{
+  return __pthread_equal (lhs, rhs);
+}
diff --git a/nptl/thrd_exit.c b/nptl/thrd_exit.c
new file mode 100644
index 0000000..e3399b0
--- /dev/null
+++ b/nptl/thrd_exit.c
@@ -0,0 +1,27 @@
+/* C11 threads thread exit implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Terminate current thread execution, cleaning up any thread local
+   storage and freeing resources. Returns the value specified in __res.  */
+_Noreturn void
+thrd_exit (int res)
+{
+  __pthread_exit ((void*)(uintptr_t) res);
+}
diff --git a/nptl/thrd_join.c b/nptl/thrd_join.c
new file mode 100644
index 0000000..65c68ff
--- /dev/null
+++ b/nptl/thrd_join.c
@@ -0,0 +1,32 @@
+/* C11 threads thread join implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Block current thread until execution of __thr is complete.  In case that
+   __res is not NULL, will store the return value of __thr when exiting.  */
+int
+thrd_join (thrd_t thr, int *res)
+{
+  void *pthread_res;
+  int err_code = __pthread_join (thr, &pthread_res);
+  if (res)
+   *res = (int)((uintptr_t)pthread_res);
+
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/thrd_priv.h b/nptl/thrd_priv.h
new file mode 100644
index 0000000..a431d60
--- /dev/null
+++ b/nptl/thrd_priv.h
@@ -0,0 +1,46 @@
+/* Internal C11 threads definitions.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef THRD_PRIV_H
+# define THRD_PRIV_H
+
+#include <features.h>
+#include <threads.h>
+#include <errno.h>
+#include "pthreadP.h"	/* For pthread_{mutex,cond}_t definitions.  */
+
+/* Maps pthread error codes with thrd error codes.  */
+static __always_inline int
+thrd_err_map (int err_code)
+{
+  switch (err_code)
+  {
+    case 0:
+      return thrd_success;
+    case ENOMEM:
+      return thrd_nomem;
+    case ETIMEDOUT:
+      return thrd_timedout;
+    case EBUSY:
+      return thrd_busy;
+    default:
+      return thrd_error;
+  }
+}
+
+#endif
diff --git a/nptl/thrd_sleep.c b/nptl/thrd_sleep.c
new file mode 100644
index 0000000..185e212
--- /dev/null
+++ b/nptl/thrd_sleep.c
@@ -0,0 +1,41 @@
+/* C11 threads thread sleep implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+#include <time.h>
+
+/* Block current thread execution for at least the time pointed by
+   __time_point.  The current thread may resume if receives a signal.  In
+   that case, if __remaining is not NULL, the remaining time is stored in
+   the object pointed by __remaining.  */
+int
+thrd_sleep (const struct timespec* time_point, struct timespec* remaining)
+{
+  INTERNAL_SYSCALL_DECL (err);
+  int ret = INTERNAL_SYSCALL_CALL (nanosleep, err, time_point, remaining);
+  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+    {
+      /* C11 states thrd_sleep function returns -1 if it has been interrupted
+         by a signal, or a negative value if it fails.  */
+      ret = INTERNAL_SYSCALL_ERRNO (ret, err);
+      if (ret == EINTR)
+	return -1;
+      return -2;
+    }
+  return 0;
+}
diff --git a/nptl/thrd_yield.c b/nptl/thrd_yield.c
new file mode 100644
index 0000000..13a02f3
--- /dev/null
+++ b/nptl/thrd_yield.c
@@ -0,0 +1,29 @@
+/* C11 threads thread yield implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Stop current thread execution and call the scheduler to decide which
+   thread should execute next.  The current thread may be selected by the
+   scheduler to keep running.  */
+void
+thrd_yield (void)
+{
+  INTERNAL_SYSCALL_DECL (err);
+  INTERNAL_SYSCALL_CALL (sched_yield, err);
+}
diff --git a/nptl/tss_create.c b/nptl/tss_create.c
new file mode 100644
index 0000000..5aa6704
--- /dev/null
+++ b/nptl/tss_create.c
@@ -0,0 +1,29 @@
+/* C11 threads thread-specific creation implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Create new thread-specific storage key and stores it in the object
+   pointed by tss_id. If destructor is not NULL, destructor function is
+   called when the thread terminates.  */
+int
+tss_create (tss_t *tss_id, tss_dtor_t destructor)
+{
+  int err_code = __pthread_key_create (tss_id, destructor);
+  return thrd_err_map (err_code);
+}
diff --git a/nptl/tss_delete.c b/nptl/tss_delete.c
new file mode 100644
index 0000000..a57acd3
--- /dev/null
+++ b/nptl/tss_delete.c
@@ -0,0 +1,27 @@
+/* C11 threads thread-specific delete implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Destroys the thread-specific storage identified by tss_id. However,
+   the destructor is not called until thrd_exit is called. */
+void
+tss_delete (tss_t tss_id)
+{
+  __pthread_key_delete (tss_id);
+}
diff --git a/nptl/tss_get.c b/nptl/tss_get.c
new file mode 100644
index 0000000..784a1cf
--- /dev/null
+++ b/nptl/tss_get.c
@@ -0,0 +1,27 @@
+/* C11 threads thread-specific get implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Return the value held in thread-specific storage for the current
+   thread identified by tss_id.  */
+void *
+tss_get (tss_t tss_id)
+{
+  return __pthread_getspecific (tss_id);
+}
diff --git a/nptl/tss_set.c b/nptl/tss_set.c
new file mode 100644
index 0000000..16a0b04
--- /dev/null
+++ b/nptl/tss_set.c
@@ -0,0 +1,28 @@
+/* C11 threads thread-specific set implementation.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include "thrd_priv.h"
+
+/* Sets the value of the thread-specific storage identified by tss_id for
+   the current thread to val.  */
+int
+tss_set (tss_t tss_id, void *val)
+{
+  int err_code = __pthread_setspecific (tss_id, val);
+  return thrd_err_map (err_code);
+}
diff --git a/sysdeps/aarch64/nptl/bits/thread-shared-types.h b/sysdeps/aarch64/nptl/bits/thread-shared-types.h
index bb361d7..d82a9b7 100644
--- a/sysdeps/aarch64/nptl/bits/thread-shared-types.h
+++ b/sysdeps/aarch64/nptl/bits/thread-shared-types.h
@@ -91,4 +91,7 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];				\
   __extension__ long long int __align;
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/alpha/nptl/bits/thread-shared-types.h b/sysdeps/alpha/nptl/bits/thread-shared-types.h
index b3c8505..ce7b791 100644
--- a/sysdeps/alpha/nptl/bits/thread-shared-types.h
+++ b/sysdeps/alpha/nptl/bits/thread-shared-types.h
@@ -87,4 +87,7 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];			\
   __extension__ long long int __align;
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/arm/nptl/bits/thread-shared-types.h b/sysdeps/arm/nptl/bits/thread-shared-types.h
index 2475792..1fac0fd 100644
--- a/sysdeps/arm/nptl/bits/thread-shared-types.h
+++ b/sysdeps/arm/nptl/bits/thread-shared-types.h
@@ -89,4 +89,7 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];			\
   __extension__ long long int __align;
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/hppa/nptl/bits/thread-shared-types.h b/sysdeps/hppa/nptl/bits/thread-shared-types.h
index 2a6d7d9..d46861b 100644
--- a/sysdeps/hppa/nptl/bits/thread-shared-types.h
+++ b/sysdeps/hppa/nptl/bits/thread-shared-types.h
@@ -99,4 +99,7 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];   \
   __extension__ long long int __align;
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
index 04dc6ae..402aac0 100644
--- a/sysdeps/i386/nptl/tls.h
+++ b/sysdeps/i386/nptl/tls.h
@@ -395,7 +395,7 @@ tls_fill_user_desc (union user_desc_init *desc,
 
 
 /* Call the user-provided thread function.  */
-#define CALL_THREAD_FCT(descr) \
+#define CALL_THREAD_FCT(descr, c11) \
   ({ void *__res;							      \
      int __ignore1, __ignore2;						      \
      asm volatile ("pushl %%eax\n\t"					      \
diff --git a/sysdeps/ia64/nptl/bits/thread-shared-types.h b/sysdeps/ia64/nptl/bits/thread-shared-types.h
index f318236..652ea57 100644
--- a/sysdeps/ia64/nptl/bits/thread-shared-types.h
+++ b/sysdeps/ia64/nptl/bits/thread-shared-types.h
@@ -89,4 +89,7 @@ struct __pthread_mutex_s
   __extension__ long long int __align;
 
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/m68k/nptl/bits/thread-shared-types.h b/sysdeps/m68k/nptl/bits/thread-shared-types.h
index ab6f05f..b539ed35 100644
--- a/sysdeps/m68k/nptl/bits/thread-shared-types.h
+++ b/sysdeps/m68k/nptl/bits/thread-shared-types.h
@@ -94,4 +94,7 @@ struct __pthread_mutex_s
   __extension__ long long int __align;
 
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN __attribute__ ((__aligned__ (4)))
+
 #endif
diff --git a/sysdeps/microblaze/nptl/bits/thread-shared-types.h b/sysdeps/microblaze/nptl/bits/thread-shared-types.h
index 91d14b6..fccdf83 100644
--- a/sysdeps/microblaze/nptl/bits/thread-shared-types.h
+++ b/sysdeps/microblaze/nptl/bits/thread-shared-types.h
@@ -90,4 +90,7 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];			\
   __extension__ long long int __align;
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/mips/nptl/bits/thread-shared-types.h b/sysdeps/mips/nptl/bits/thread-shared-types.h
index a34b816..c0c69fa 100644
--- a/sysdeps/mips/nptl/bits/thread-shared-types.h
+++ b/sysdeps/mips/nptl/bits/thread-shared-types.h
@@ -111,4 +111,7 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];			\
   __extension__ long long int __align;
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/nacl/libpthread.abilist b/sysdeps/nacl/libpthread.abilist
index 8f0099c..7d377b5 100644
--- a/sysdeps/nacl/libpthread.abilist
+++ b/sysdeps/nacl/libpthread.abilist
@@ -173,3 +173,29 @@ GLIBC_2.22 sem_timedwait F
 GLIBC_2.22 sem_trywait F
 GLIBC_2.22 sem_unlink F
 GLIBC_2.22 sem_wait F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
diff --git a/sysdeps/nios2/nptl/bits/thread-shared-types.h b/sysdeps/nios2/nptl/bits/thread-shared-types.h
index 8904239..bf58a90 100644
--- a/sysdeps/nios2/nptl/bits/thread-shared-types.h
+++ b/sysdeps/nios2/nptl/bits/thread-shared-types.h
@@ -87,4 +87,7 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];			\
   __extension__ long long int __align;
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
new file mode 100644
index 0000000..7d7282a
--- /dev/null
+++ b/sysdeps/nptl/threads.h
@@ -0,0 +1,198 @@
+/* ISO C11 Standard: 7.26 - Thread support library  <threads.h>.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _THREADS_H
+#define _THREADS_H	1
+
+#include <features.h>
+#include <time.h>
+
+__BEGIN_DECLS
+
+#include <bits/thread-shared-types.h>
+#include <bits/types/struct_timespec.h>
+
+#define ONCE_FLAG_INIT 0
+#define thread_local _Thread_local
+#define TSS_DTOR_ITERATIONS 4
+
+typedef unsigned long int thrd_t;         /* Based on pthread_t.  */
+typedef int __ONCE_FLAG_ALIGN once_flag;  /* Based on pthread_once_t.  */
+typedef unsigned int tss_t;               /* Based on pthread_key_t.  */
+typedef int (*thrd_start_t) (void*);
+typedef void (*tss_dtor_t) (void*);
+
+/* Exit and error codes.  */
+enum
+{
+  thrd_success  = 0,
+  thrd_busy     = 1,
+  thrd_error    = 2,
+  thrd_nomem    = 3,
+  thrd_timedout = 4
+};
+
+/* Kinds of mutexes.  */
+enum
+{
+  mtx_plain     = 0,
+  mtx_recursive = 1,
+  mtx_timed     = 2
+};
+
+/* Definition of mtx_t based on pthread_mutex_t.  */
+typedef union
+{
+  __PTHREAD_MUTEX_T_CONTENT
+} mtx_t;
+
+/* Definition of cnd_t based on pthread_cond_t.  */
+typedef union
+{
+  __PTHREAD_COND_T_CONTENT
+} cnd_t;
+
+/* Threads functions.  */
+
+/* Create a new thread executing the function __func. Arguments to __func
+   are passed through __arg. If succesful, __thr is set to new
+   thread identifier.  */
+extern int thrd_create (thrd_t *__thr, thrd_start_t __func, void *__arg);
+
+/* Check if __lhs and __rhs point to the same thread.  */
+extern int thrd_equal (thrd_t __lhs, thrd_t __rhs);
+
+/* Return current thread identifier.  */
+extern thrd_t thrd_current (void);
+
+/* Block current thread execution for at least the time pointed by
+   __time_point.  The current thread may resume if receives a signal.  In
+   that case, if __remaining is not NULL, the remaining time is stored in
+   the object pointed by __remaining.  */
+extern int thrd_sleep (const struct timespec *__time_point,
+		       struct timespec *__remaining);
+
+/* Terminate current thread execution, cleaning up any thread local
+   storage and freeing resources. Returns the value specified in __res.  */
+extern void thrd_exit (int __res) __attribute__ ((__noreturn__));
+
+/* Detache the thread identified by __thr from the current environment.
+   That means we cannot join or wait for __thr to finish it's execution.  */
+extern int thrd_detach (thrd_t __thr);
+
+/* Block current thread until execution of __thr is complete.  In case that
+   __res is not NULL, will store the return value of __thr when exiting.  */
+extern int thrd_join (thrd_t __thr, int *__res);
+
+/* Stop current thread execution and call the scheduler to decide which
+   thread should execute next.  The current thread may be selected by the
+   scheduler to keep running.  */
+extern void thrd_yield (void);
+
+/* Mutex functions.  */
+
+/* Creates a new mutex object with type __type.  If successful the new
+   object is pointed by __mutex.  */
+extern int mtx_init (mtx_t *__mutex, int __type);
+
+/* Block the current thread until the mutex pointed to
+   by __mutex is unlocked. In case the mutex is free,
+   the current thread will not be blocked.  */
+extern int mtx_lock (mtx_t *__mutex);
+
+/* Block the current thread until the mutex pointed by __mutex is unlocked
+   or time pointed by __time_point is reached.  In case the mutex is free,
+   the current thread will not be blocked.  */
+extern int mtx_timedlock (mtx_t *__restrict __mutex,
+			  const struct timespec *__restrict __time_point);
+
+/* Try to lock the mutex pointed by __mutex without blocking.  If the mutex
+   is free, current threads takes control of it, and if it's not, returns
+   immediately.  */
+extern int mtx_trylock (mtx_t *__mutex);
+
+/* Unlock the mutex pointed to by __mutex, what can lead to
+   awaking other threads waiting on this mutex.  */
+extern int mtx_unlock (mtx_t *__mutex);
+
+/* Destroy the mutex object pointed by __mutex.  */
+extern void mtx_destroy (mtx_t *__mutex);
+
+/* Call function __func exactly once, even if invoked from several threads.
+   However, all calls must be made with the same __flag object.  */
+extern void call_once (once_flag *__flag, void (*__func)(void));
+
+/* Condition variable functions.  */
+
+/* Initialize new condition variable pointed by __cond.  */
+extern int cnd_init (cnd_t *__cond);
+
+/* Unblock one thread that currently waits on condition variable pointed to
+   by __cond.  */
+extern int cnd_signal (cnd_t *__cond);
+
+/* Unblock all threads currently waiting on condition variable pointed to by
+   __cond.  */
+extern int cnd_broadcast (cnd_t *__cond);
+
+/* Block current thread on the condition variable
+   pointed to by __cond.  */
+extern int cnd_wait (cnd_t *__cond, mtx_t *__mutex);
+
+/* Block current thread on the condition variable until condition variable
+   pointed on by __cond is signalled or time pointed by __time_point is
+   reached.  */
+extern int cnd_timedwait (cnd_t *__restrict __cond,
+			  mtx_t *__restrict __mutex,
+			  const struct timespec *__restrict __time_point);
+
+/* Destroy condition variable pointed to by __cond and free all of its
+   resources.  */
+extern void cnd_destroy (cnd_t *__cond);
+
+/* Thread specific storage functions.  */
+
+/* Create new thread-specific storage key and stores it in the object pointed
+   by __tss_id.  If __destructor is not NULL, __destructor function is called
+   when the thread terminates.  */
+extern int tss_create (tss_t *__tss_id, tss_dtor_t __destructor);
+
+/* Return the value held in thread-specific storage for the current thread
+   identified by __tss_id.  */
+extern void *tss_get (tss_t __tss_id);
+
+/* Sets the value of the thread-specific storage identified by __tss_id for
+   the current thread to __val.  */
+extern int tss_set (tss_t __tss_id, void *__val);
+
+/* Destroys the thread-specific storage identified by __tss_id.  However, the
+   destructor is not called until thrd_exit is called.  */
+extern void tss_delete (tss_t __tss_id);
+
+#ifdef __USE_EXTERN_INLINES
+/* Optimizations.  */
+__extern_inline int
+thrd_equal (thrd_t __thread1, thrd_t __thread2)
+{
+  return __thread1 == __thread2;
+}
+#endif
+
+__END_DECLS
+
+#endif /* _THREADS_H */
diff --git a/sysdeps/powerpc/nptl/bits/thread-shared-types.h b/sysdeps/powerpc/nptl/bits/thread-shared-types.h
index 3653f83..6ca60ba 100644
--- a/sysdeps/powerpc/nptl/bits/thread-shared-types.h
+++ b/sysdeps/powerpc/nptl/bits/thread-shared-types.h
@@ -115,4 +115,7 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];			\
   __extension__ long long int __align;
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/s390/nptl/bits/thread-shared-types.h b/sysdeps/s390/nptl/bits/thread-shared-types.h
index 893e626..bedcd28 100644
--- a/sysdeps/s390/nptl/bits/thread-shared-types.h
+++ b/sysdeps/s390/nptl/bits/thread-shared-types.h
@@ -134,4 +134,7 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];			\
   __extension__ long long int __align;
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/sh/nptl/bits/thread-shared-types.h b/sysdeps/sh/nptl/bits/thread-shared-types.h
index 7a28e58..1f90b3b 100644
--- a/sysdeps/sh/nptl/bits/thread-shared-types.h
+++ b/sysdeps/sh/nptl/bits/thread-shared-types.h
@@ -91,4 +91,8 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];			\
   __extension__ long long int __align;
 
+
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif	/* bits/thread-shared-types.h */
diff --git a/sysdeps/sparc/nptl/bits/thread-shared-types.h b/sysdeps/sparc/nptl/bits/thread-shared-types.h
index d12916a..e44ec45 100644
--- a/sysdeps/sparc/nptl/bits/thread-shared-types.h
+++ b/sysdeps/sparc/nptl/bits/thread-shared-types.h
@@ -111,5 +111,9 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];			\
   __extension__ long long int __align;
 
+
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
 
diff --git a/sysdeps/tile/nptl/bits/thread-shared-types.h b/sysdeps/tile/nptl/bits/thread-shared-types.h
index 0a4587e..88d3b8a 100644
--- a/sysdeps/tile/nptl/bits/thread-shared-types.h
+++ b/sysdeps/tile/nptl/bits/thread-shared-types.h
@@ -111,4 +111,8 @@ struct __pthread_mutex_s
   char __size[__SIZEOF_PTHREAD_COND_T];			\
   __extension__ long long int __align;
 
+
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
index 0cf30ee..c0f6af2 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libpthread.abilist
@@ -224,3 +224,29 @@ GLIBC_2.17 write F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
diff --git a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
index 7e121d4..bf852a0 100644
--- a/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libpthread.abilist
@@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/arm/libpthread.abilist b/sysdeps/unix/sysv/linux/arm/libpthread.abilist
index 91545c1..7c39603 100644
--- a/sysdeps/unix/sysv/linux/arm/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/arm/libpthread.abilist
@@ -9,6 +9,32 @@ GLIBC_2.12 pthread_setname_np F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 _IO_flockfile F
 GLIBC_2.4 _IO_ftrylockfile F
diff --git a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
index a73aa43..4d1dbc5 100644
--- a/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libpthread.abilist
@@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/i386/libpthread.abilist b/sysdeps/unix/sysv/linux/i386/libpthread.abilist
index 8f9c325..1e3aeae 100644
--- a/sysdeps/unix/sysv/linux/i386/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libpthread.abilist
@@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
index d4c8ded..a87669f 100644
--- a/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libpthread.abilist
@@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
index 91545c1..7c39603 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist
@@ -9,6 +9,32 @@ GLIBC_2.12 pthread_setname_np F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 _IO_flockfile F
 GLIBC_2.4 _IO_ftrylockfile F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
index 8f9c325..1e3aeae 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist
@@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist b/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist
index 00d948b..07e3831 100644
--- a/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/libpthread.abilist
@@ -223,3 +223,29 @@ GLIBC_2.18 vfork F
 GLIBC_2.18 wait F
 GLIBC_2.18 waitpid F
 GLIBC_2.18 write F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
index 280d99d..53d3d1c 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist
@@ -213,6 +213,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
index ad55bdd..7aabe95 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist
@@ -213,6 +213,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
index a10bbde..c117ce5 100644
--- a/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libpthread.abilist
@@ -221,3 +221,29 @@ GLIBC_2.21 tcdrain F
 GLIBC_2.21 wait F
 GLIBC_2.21 waitpid F
 GLIBC_2.21 write F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
index 14c3a86..160b523 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist
@@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist
index 0cf30ee..475ecd6 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist
@@ -224,3 +224,29 @@ GLIBC_2.17 write F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.25 GLIBC_2.25 A
+GLIBC_2.25 call_once F
+GLIBC_2.25 cnd_broadcast F
+GLIBC_2.25 cnd_destroy F
+GLIBC_2.25 cnd_init F
+GLIBC_2.25 cnd_signal F
+GLIBC_2.25 cnd_timedwait F
+GLIBC_2.25 cnd_wait F
+GLIBC_2.25 mtx_destroy F
+GLIBC_2.25 mtx_init F
+GLIBC_2.25 mtx_lock F
+GLIBC_2.25 mtx_timedlock F
+GLIBC_2.25 mtx_trylock F
+GLIBC_2.25 mtx_unlock F
+GLIBC_2.25 thrd_create F
+GLIBC_2.25 thrd_current F
+GLIBC_2.25 thrd_detach F
+GLIBC_2.25 thrd_equal F
+GLIBC_2.25 thrd_exit F
+GLIBC_2.25 thrd_join F
+GLIBC_2.25 thrd_sleep F
+GLIBC_2.25 thrd_yield F
+GLIBC_2.25 tss_create F
+GLIBC_2.25 tss_delete F
+GLIBC_2.25 tss_get F
+GLIBC_2.25 tss_set F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist
index 464b91a..7881e7b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist
@@ -9,6 +9,32 @@ GLIBC_2.12 pthread_setname_np F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 _IO_flockfile F
 GLIBC_2.3 _IO_ftrylockfile F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
index 3c5e11a..0a98f27 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist
@@ -219,6 +219,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
index 83a1fcd..c3fe23b 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist
@@ -207,6 +207,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/sh/libpthread.abilist b/sysdeps/unix/sysv/linux/sh/libpthread.abilist
index a73aa43..4d1dbc5 100644
--- a/sysdeps/unix/sysv/linux/sh/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sh/libpthread.abilist
@@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
index 7e121d4..bf852a0 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist
@@ -216,6 +216,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
index d4c8ded..a87669f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist
@@ -204,6 +204,32 @@ GLIBC_2.2.3 GLIBC_2.2.3 A
 GLIBC_2.2.3 pthread_getattr_np F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libpthread.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libpthread.abilist
index d16158f..1e538e8 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libpthread.abilist
@@ -224,3 +224,29 @@ GLIBC_2.12 write F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist
index d16158f..1e538e8 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libpthread.abilist
@@ -224,3 +224,29 @@ GLIBC_2.12 write F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
diff --git a/sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist b/sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist
index d16158f..1e538e8 100644
--- a/sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist
@@ -224,3 +224,29 @@ GLIBC_2.12 write F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
index 85365c0..2395f5d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist
@@ -203,6 +203,32 @@ GLIBC_2.2.5 waitpid F
 GLIBC_2.2.5 write F
 GLIBC_2.2.6 GLIBC_2.2.6 A
 GLIBC_2.2.6 __nanosleep F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
 GLIBC_2.3.2 GLIBC_2.3.2 A
 GLIBC_2.3.2 pthread_cond_broadcast F
 GLIBC_2.3.2 pthread_cond_destroy F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
index 6cd0fc3..42a39db 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist
@@ -224,3 +224,29 @@ GLIBC_2.16 write F
 GLIBC_2.18 GLIBC_2.18 A
 GLIBC_2.18 pthread_getattr_default_np F
 GLIBC_2.18 pthread_setattr_default_np F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 call_once F
+GLIBC_2.26 cnd_broadcast F
+GLIBC_2.26 cnd_destroy F
+GLIBC_2.26 cnd_init F
+GLIBC_2.26 cnd_signal F
+GLIBC_2.26 cnd_timedwait F
+GLIBC_2.26 cnd_wait F
+GLIBC_2.26 mtx_destroy F
+GLIBC_2.26 mtx_init F
+GLIBC_2.26 mtx_lock F
+GLIBC_2.26 mtx_timedlock F
+GLIBC_2.26 mtx_trylock F
+GLIBC_2.26 mtx_unlock F
+GLIBC_2.26 thrd_create F
+GLIBC_2.26 thrd_current F
+GLIBC_2.26 thrd_detach F
+GLIBC_2.26 thrd_equal F
+GLIBC_2.26 thrd_exit F
+GLIBC_2.26 thrd_join F
+GLIBC_2.26 thrd_sleep F
+GLIBC_2.26 thrd_yield F
+GLIBC_2.26 tss_create F
+GLIBC_2.26 tss_delete F
+GLIBC_2.26 tss_get F
+GLIBC_2.26 tss_set F
diff --git a/sysdeps/x86/nptl/bits/thread-shared-types.h b/sysdeps/x86/nptl/bits/thread-shared-types.h
index ffed07d..7795756 100644
--- a/sysdeps/x86/nptl/bits/thread-shared-types.h
+++ b/sysdeps/x86/nptl/bits/thread-shared-types.h
@@ -114,4 +114,7 @@ struct __pthread_mutex_s
   __extension__ long long int __align;
 
 
+/* Used to force once_flag alignment.  */
+#define __ONCE_FLAG_ALIGN
+
 #endif
diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
index 53b41bc..9f0aaa6 100644
--- a/sysdeps/x86_64/nptl/tls.h
+++ b/sysdeps/x86_64/nptl/tls.h
@@ -326,8 +326,8 @@ typedef struct
 	      abort (); })
 
 
-# define CALL_THREAD_FCT(descr) \
-  ({ void *__res;							      \
+# define CALL_THREAD_FCT(descr, c11) \
+  ({ union { void *voidr; int intr; } __res;				      \
      asm volatile ("movq %%fs:%P2, %%rdi\n\t"				      \
 		   "callq *%%fs:%P1"					      \
 		   : "=a" (__res)					      \
@@ -335,7 +335,7 @@ typedef struct
 		     "i" (offsetof (struct pthread, arg))		      \
 		   : "di", "si", "cx", "dx", "r8", "r9", "r10", "r11",	      \
 		     "memory", "cc");					      \
-     __res; })
+     c11 ? (void*) (intptr_t) __res.intr : __res.voidr; })
 
 
 /* Set the stack guard field in TCB head.  */
diff --git a/sysdeps/x86_64/x32/nptl/tls.h b/sysdeps/x86_64/x32/nptl/tls.h
index 68f65a6..1995877 100644
--- a/sysdeps/x86_64/x32/nptl/tls.h
+++ b/sysdeps/x86_64/x32/nptl/tls.h
@@ -29,7 +29,7 @@
    32 bits of the return-value register.  We then do the indirect call
    via the 64-bit return-value register.  */
 # undef CALL_THREAD_FCT
-# define CALL_THREAD_FCT(descr) \
+# define CALL_THREAD_FCT(descr, c11) \
   ({ void *__res;							      \
      asm volatile ("movl %%fs:%P2, %%edi\n\t"				      \
 		   "movl %%fs:%P1, %k0\n\t"				      \
-- 
2.7.4

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v3 0/6] Add support for ISO C11 threads.h
@ 2017-03-21 13:40 Adhemerval Zanella
  2017-03-21 13:40 ` [PATCH 6/6] Add manual documentation for threads.h Adhemerval Zanella
                   ` (6 more replies)
  0 siblings, 7 replies; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-21 13:40 UTC (permalink / raw)
  To: libc-alpha

This is a new update of C11 thread support based on version 2 from 
Juan Manuel Torres Palma [1].  I contact him to take over his initial
patches and extended to fix some issues and update to glibc 2.26.

The main changes are:

  - Addresses Joseph's comments from [2] and ad indicated in
    in C11 thread patch I based this implementation from th
    public C11 thread document I have access [3]. I would ask for
    suggestion and change if it deviates from the final standard
    definition.

  - Fix remaining namespace and linkspace issues by building on
    basically all supported architectures (aarch64, alpha, armhf,
    hppa, i686, ia64, m68k, microblaze, mips64, mips64n32, mips,
    nios2, powerpc64le, powerpc64, powerpc, powerpc-power4, s390,
    s390x, sh4, sparc64, sparcv9, tilegx, tilegx32, tilepro,
    x86_64, and x86_64-32).  Note: hppa changes still results in
    broken build as indicated in BZ#21016.

  - Adjusted abi files to 2.26, headers dates to 2017 and some
    others typos.

  - Fix a calling convention on pthread_create to call c11 start
    function with a well-behaved semanthics.

I tested this without regression with a full make/check on
x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf,
sparc64-linux-gnu, and sparcv9-linux-gnu.

[1] https://sourceware.org/ml/libc-alpha/2015-08/msg01051.html
[2] https://sourceware.org/ml/libc-alpha/2016-03/msg00604.html
[3] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

Adhemerval Zanella (5):
  Consolidate pthreadtype.h placement
  Move mutex and condition variable definition to common header
  Clean pthread functions namespaces for C11 threads
  Add C11 threads support
  Add test cases for ISO C11 threads

Juan Manuel Torres Palma (1):
  Add manual documentation for threads.h

 ChangeLog                                          | 247 ++++++++++++++
 bits/thread-shared-types.h                         |  36 ++
 conform/Makefile                                   |   7 +-
 conform/data/threads.h-data                        |  56 ++++
 include/sched.h                                    |   2 +
 include/stdc-predef.h                              |   3 -
 include/sys/mman.h                                 |   4 +
 include/termios.h                                  |   2 +
 include/time.h                                     |   2 +-
 manual/Makefile                                    |   2 +-
 manual/isothreads.texi                             | 373 +++++++++++++++++++++
 misc/Versions                                      |   2 +
 nptl/Makefile                                      |  17 +-
 nptl/Versions                                      |  16 +
 nptl/allocatestack.c                               |  24 +-
 nptl/call_once.c                                   |  27 ++
 nptl/cnd_broadcast.c                               |  28 ++
 nptl/cnd_destroy.c                                 |  28 ++
 nptl/cnd_init.c                                    |  27 ++
 nptl/cnd_signal.c                                  |  28 ++
 nptl/cnd_timedwait.c                               |  32 ++
 nptl/cnd_wait.c                                    |  28 ++
 nptl/descr.h                                       |   1 +
 nptl/mtx_destroy.c                                 |  27 ++
 nptl/mtx_init.c                                    |  48 +++
 nptl/mtx_lock.c                                    |  29 ++
 nptl/mtx_timedlock.c                               |  31 ++
 nptl/mtx_trylock.c                                 |  29 ++
 nptl/mtx_unlock.c                                  |  28 ++
 nptl/pthreadP.h                                    |  12 +
 nptl/pthread_cancel.c                              |   7 +-
 nptl/pthread_create.c                              |  39 ++-
 nptl/pthread_detach.c                              |   3 +-
 nptl/pthread_equal.c                               |   2 +-
 nptl/pthread_exit.c                                |   4 +-
 nptl/pthread_getspecific.c                         |   2 +-
 nptl/pthread_join.c                                |   3 +-
 nptl/pthread_key_create.c                          |   2 +-
 nptl/pthread_key_delete.c                          |   3 +-
 nptl/pthread_mutex_destroy.c                       |   2 +-
 nptl/pthread_mutex_init.c                          |   2 +-
 nptl/pthread_mutex_lock.c                          |   2 +-
 nptl/pthread_mutex_timedlock.c                     |   5 +-
 nptl/pthread_mutex_trylock.c                       |   3 +-
 nptl/pthread_mutex_unlock.c                        |   2 +-
 nptl/pthread_mutexattr_init.c                      |   3 +-
 nptl/pthread_mutexattr_settype.c                   |   3 +-
 nptl/pthread_self.c                                |   2 +-
 nptl/pthread_setspecific.c                         |   2 +-
 nptl/thrd_create.c                                 |  30 ++
 nptl/thrd_current.c                                |  26 ++
 nptl/thrd_detach.c                                 |  30 ++
 nptl/thrd_equal.c                                  |  26 ++
 nptl/thrd_exit.c                                   |  27 ++
 nptl/thrd_join.c                                   |  32 ++
 nptl/thrd_priv.h                                   |  46 +++
 nptl/thrd_sleep.c                                  |  41 +++
 nptl/thrd_yield.c                                  |  29 ++
 nptl/tpp.c                                         |   4 +-
 nptl/tss_create.c                                  |  29 ++
 nptl/tss_delete.c                                  |  27 ++
 nptl/tss_get.c                                     |  27 ++
 nptl/tss_set.c                                     |  28 ++
 nptl/tst-call-once.c                               |  66 ++++
 nptl/tst-cnd-basic.c                               |  68 ++++
 nptl/tst-cnd-broadcast.c                           |  83 +++++
 nptl/tst-cnd-timedwait.c                           |  70 ++++
 nptl/tst-mtx-basic.c                               |  73 ++++
 nptl/tst-mtx-recursive.c                           |  45 +++
 nptl/tst-mtx-timedlock.c                           |  98 ++++++
 nptl/tst-mtx-trylock.c                             |  90 +++++
 nptl/tst-thrd-detach.c                             |  52 +++
 nptl/tst-thrd-sleep.c                              |  51 +++
 nptl/tst-tss-basic.c                               |  75 +++++
 posix/Makefile                                     |   3 +-
 posix/nanosleep.c                                  |   2 +-
 sysdeps/aarch64/nptl/bits/pthreadtypes.h           |  67 +---
 sysdeps/aarch64/nptl/bits/thread-shared-types.h    |  97 ++++++
 .../linux/alpha => alpha/nptl}/bits/pthreadtypes.h |  63 +---
 sysdeps/alpha/nptl/bits/thread-shared-types.h      |  93 +++++
 sysdeps/arm/nptl/bits/pthreadtypes.h               |  67 +---
 sysdeps/arm/nptl/bits/thread-shared-types.h        |  95 ++++++
 sysdeps/hppa/nptl/bits/pthreadtypes.h              |  83 +----
 sysdeps/hppa/nptl/bits/thread-shared-types.h       | 105 ++++++
 sysdeps/i386/nptl/tls.h                            |   2 +-
 sysdeps/ia64/nptl/bits/pthreadtypes.h              |  67 +---
 sysdeps/ia64/nptl/bits/thread-shared-types.h       |  95 ++++++
 sysdeps/m68k/nptl/bits/pthreadtypes.h              |  68 +---
 sysdeps/m68k/nptl/bits/thread-shared-types.h       | 100 ++++++
 sysdeps/microblaze/nptl/bits/pthreadtypes.h        |  61 +---
 sysdeps/microblaze/nptl/bits/thread-shared-types.h |  96 ++++++
 sysdeps/mips/nptl/bits/pthreadtypes.h              |  83 +----
 sysdeps/mips/nptl/bits/thread-shared-types.h       | 117 +++++++
 sysdeps/nacl/libpthread.abilist                    |  26 ++
 sysdeps/nios2/nptl/bits/pthreadtypes.h             |  67 +---
 sysdeps/nios2/nptl/bits/thread-shared-types.h      |  93 +++++
 sysdeps/nptl/bits/pthreadtypes-common.h            |  44 +++
 sysdeps/nptl/threads.h                             | 198 +++++++++++
 sysdeps/posix/gethostname.c                        |   2 +-
 .../powerpc => powerpc/nptl}/bits/pthreadtypes.h   | 100 +-----
 sysdeps/powerpc/nptl/bits/thread-shared-types.h    | 121 +++++++
 sysdeps/s390/nptl/bits/pthreadtypes.h              | 103 +-----
 sysdeps/s390/nptl/bits/thread-shared-types.h       | 140 ++++++++
 sysdeps/sh/nptl/bits/pthreadtypes.h                |  63 +---
 sysdeps/sh/nptl/bits/thread-shared-types.h         |  98 ++++++
 sysdeps/sparc/nptl/bits/pthreadtypes.h             |  82 +----
 sysdeps/sparc/nptl/bits/thread-shared-types.h      | 119 +++++++
 sysdeps/tile/nptl/bits/pthreadtypes.h              |  95 +-----
 sysdeps/tile/nptl/bits/thread-shared-types.h       | 118 +++++++
 sysdeps/unix/sysv/linux/aarch64/libpthread.abilist |  26 ++
 sysdeps/unix/sysv/linux/aarch64/mmap.c             |   5 +-
 sysdeps/unix/sysv/linux/alpha/libpthread.abilist   |  26 ++
 sysdeps/unix/sysv/linux/arm/libpthread.abilist     |  26 ++
 sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c |   5 +-
 sysdeps/unix/sysv/linux/hppa/libpthread.abilist    |  26 ++
 sysdeps/unix/sysv/linux/hppa/mmap.c                |   1 +
 sysdeps/unix/sysv/linux/i386/Versions              |   2 +-
 sysdeps/unix/sysv/linux/i386/libpthread.abilist    |  26 ++
 sysdeps/unix/sysv/linux/i386/mmap.c                |   1 +
 sysdeps/unix/sysv/linux/i386/smp.h                 |   2 +-
 sysdeps/unix/sysv/linux/ia64/libpthread.abilist    |  26 ++
 .../sysv/linux/m68k/coldfire/libpthread.abilist    |  26 ++
 .../unix/sysv/linux/m68k/m680x0/libpthread.abilist |  26 ++
 sysdeps/unix/sysv/linux/m68k/mmap.S                |   1 +
 .../unix/sysv/linux/microblaze/libpthread.abilist  |  26 ++
 sysdeps/unix/sysv/linux/microblaze/mmap.S          |   1 +
 .../unix/sysv/linux/mips/mips32/libpthread.abilist |  26 ++
 .../unix/sysv/linux/mips/mips64/libpthread.abilist |  26 ++
 sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c     |   5 +-
 sysdeps/unix/sysv/linux/mmap64.c                   |   6 +-
 sysdeps/unix/sysv/linux/nios2/libpthread.abilist   |  26 ++
 sysdeps/unix/sysv/linux/powerpc/ioctl.c            |   6 +-
 .../linux/powerpc/powerpc32/libpthread.abilist     |  26 ++
 .../linux/powerpc/powerpc64/libpthread-le.abilist  |  26 ++
 .../linux/powerpc/powerpc64/libpthread.abilist     |  26 ++
 .../sysv/linux/s390/s390-32/libpthread.abilist     |  26 ++
 sysdeps/unix/sysv/linux/s390/s390-32/mmap.S        |   1 +
 sysdeps/unix/sysv/linux/s390/s390-32/mmap64.S      |   1 +
 .../sysv/linux/s390/s390-64/libpthread.abilist     |  26 ++
 sysdeps/unix/sysv/linux/s390/s390-64/mmap.S        |   2 +
 sysdeps/unix/sysv/linux/sh/libpthread.abilist      |  26 ++
 .../sysv/linux/sparc/sparc32/libpthread.abilist    |  26 ++
 .../sysv/linux/sparc/sparc64/libpthread.abilist    |  26 ++
 sysdeps/unix/sysv/linux/tcsetattr.c                |   3 +-
 .../linux/tile/tilegx/tilegx32/libpthread.abilist  |  26 ++
 .../linux/tile/tilegx/tilegx64/libpthread.abilist  |  26 ++
 .../sysv/linux/tile/tilepro/libpthread.abilist     |  26 ++
 sysdeps/unix/sysv/linux/wordsize-64/mmap.c         |   6 +-
 sysdeps/unix/sysv/linux/x86/Implies                |   1 +
 .../unix/sysv/linux/x86_64/64/libpthread.abilist   |  26 ++
 .../unix/sysv/linux/x86_64/x32/libpthread.abilist  |  26 ++
 sysdeps/x86/{ => nptl}/bits/pthreadtypes.h         | 104 +-----
 sysdeps/x86/nptl/bits/thread-shared-types.h        | 120 +++++++
 sysdeps/x86_64/nptl/tls.h                          |   6 +-
 sysdeps/x86_64/x32/nptl/tls.h                      |   2 +-
 155 files changed, 4998 insertions(+), 1226 deletions(-)
 create mode 100644 bits/thread-shared-types.h
 create mode 100644 conform/data/threads.h-data
 create mode 100644 manual/isothreads.texi
 create mode 100644 nptl/call_once.c
 create mode 100644 nptl/cnd_broadcast.c
 create mode 100644 nptl/cnd_destroy.c
 create mode 100644 nptl/cnd_init.c
 create mode 100644 nptl/cnd_signal.c
 create mode 100644 nptl/cnd_timedwait.c
 create mode 100644 nptl/cnd_wait.c
 create mode 100644 nptl/mtx_destroy.c
 create mode 100644 nptl/mtx_init.c
 create mode 100644 nptl/mtx_lock.c
 create mode 100644 nptl/mtx_timedlock.c
 create mode 100644 nptl/mtx_trylock.c
 create mode 100644 nptl/mtx_unlock.c
 create mode 100644 nptl/thrd_create.c
 create mode 100644 nptl/thrd_current.c
 create mode 100644 nptl/thrd_detach.c
 create mode 100644 nptl/thrd_equal.c
 create mode 100644 nptl/thrd_exit.c
 create mode 100644 nptl/thrd_join.c
 create mode 100644 nptl/thrd_priv.h
 create mode 100644 nptl/thrd_sleep.c
 create mode 100644 nptl/thrd_yield.c
 create mode 100644 nptl/tss_create.c
 create mode 100644 nptl/tss_delete.c
 create mode 100644 nptl/tss_get.c
 create mode 100644 nptl/tss_set.c
 create mode 100644 nptl/tst-call-once.c
 create mode 100644 nptl/tst-cnd-basic.c
 create mode 100644 nptl/tst-cnd-broadcast.c
 create mode 100644 nptl/tst-cnd-timedwait.c
 create mode 100644 nptl/tst-mtx-basic.c
 create mode 100644 nptl/tst-mtx-recursive.c
 create mode 100644 nptl/tst-mtx-timedlock.c
 create mode 100644 nptl/tst-mtx-trylock.c
 create mode 100644 nptl/tst-thrd-detach.c
 create mode 100644 nptl/tst-thrd-sleep.c
 create mode 100644 nptl/tst-tss-basic.c
 create mode 100644 sysdeps/aarch64/nptl/bits/thread-shared-types.h
 rename sysdeps/{unix/sysv/linux/alpha => alpha/nptl}/bits/pthreadtypes.h (70%)
 create mode 100644 sysdeps/alpha/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/arm/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/hppa/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/ia64/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/m68k/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/microblaze/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/mips/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/nios2/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/nptl/bits/pthreadtypes-common.h
 create mode 100644 sysdeps/nptl/threads.h
 rename sysdeps/{unix/sysv/linux/powerpc => powerpc/nptl}/bits/pthreadtypes.h (63%)
 create mode 100644 sysdeps/powerpc/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/s390/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/sh/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/sparc/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/tile/nptl/bits/thread-shared-types.h
 create mode 100644 sysdeps/unix/sysv/linux/x86/Implies
 rename sysdeps/x86/{ => nptl}/bits/pthreadtypes.h (64%)
 create mode 100644 sysdeps/x86/nptl/bits/thread-shared-types.h

-- 
2.7.4

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 5/6] Add test cases for ISO C11 threads
  2017-03-21 13:40 [PATCH v3 0/6] Add support for ISO C11 threads.h Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2017-03-21 13:40 ` [PATCH 2/6] Move mutex and condition variable definition to common header Adhemerval Zanella
@ 2017-03-21 13:40 ` Adhemerval Zanella
  2017-03-21 16:25 ` [PATCH v3 0/6] Add support for ISO C11 threads.h Joseph Myers
  6 siblings, 0 replies; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-21 13:40 UTC (permalink / raw)
  To: libc-alpha

This patch adds to testsuite new test cases to test all new introduced
C11 threads functions, types and macros are tested.

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, hppa-linux-gnu, i386-linux-gnu, ia64-linux-gnu,
m68k-linux-gnu, microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	Adhemerval Zanella  <adhemerval.zanella@linaro.org>
	Juan Manuel Torres Palma  <jmtorrespalma@gmail.com>

	* nptl/Makefile (tests): Add new test files.
	* nptl/tst-call-once.c : New file. Tests C11 functions and types.
	* nptl/tst-cnd-basic.c: Likewise.
	* nptl/tst-cnd-broadcast.c: Likewise.
	* nptl/tst-cnd-timedwait.c: Likewise.
	* nptl/tst-mtx-basic.c: Likewise.
	* nptl/tst-mtx-recursive.c: Likewise.
	* nptl/tst-mtx-timedlock.c: Likewise.
	* nptl/tst-mtx-trylock.c: Likewise.
	* nptl/tst-thrd-basic.c: Likewise.
	* nptl/tst-thrd-detach.c: Likewise.
	* nptl/tst-thrd-sleep.c: Likewise.
	* nptl/tst-tss-basic.c: Likewise.
---
 ChangeLog                | 13 +++++++
 nptl/Makefile            |  5 ++-
 nptl/tst-call-once.c     | 66 ++++++++++++++++++++++++++++++++
 nptl/tst-cnd-basic.c     | 68 +++++++++++++++++++++++++++++++++
 nptl/tst-cnd-broadcast.c | 83 ++++++++++++++++++++++++++++++++++++++++
 nptl/tst-cnd-timedwait.c | 70 ++++++++++++++++++++++++++++++++++
 nptl/tst-mtx-basic.c     | 73 ++++++++++++++++++++++++++++++++++++
 nptl/tst-mtx-recursive.c | 45 ++++++++++++++++++++++
 nptl/tst-mtx-timedlock.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++
 nptl/tst-mtx-trylock.c   | 90 ++++++++++++++++++++++++++++++++++++++++++++
 nptl/tst-thrd-detach.c   | 52 +++++++++++++++++++++++++
 nptl/tst-thrd-sleep.c    | 51 +++++++++++++++++++++++++
 nptl/tst-tss-basic.c     | 75 ++++++++++++++++++++++++++++++++++++
 13 files changed, 788 insertions(+), 1 deletion(-)
 create mode 100644 nptl/tst-call-once.c
 create mode 100644 nptl/tst-cnd-basic.c
 create mode 100644 nptl/tst-cnd-broadcast.c
 create mode 100644 nptl/tst-cnd-timedwait.c
 create mode 100644 nptl/tst-mtx-basic.c
 create mode 100644 nptl/tst-mtx-recursive.c
 create mode 100644 nptl/tst-mtx-timedlock.c
 create mode 100644 nptl/tst-mtx-trylock.c
 create mode 100644 nptl/tst-thrd-detach.c
 create mode 100644 nptl/tst-thrd-sleep.c
 create mode 100644 nptl/tst-tss-basic.c

diff --git a/nptl/Makefile b/nptl/Makefile
index d28dbba..15301b3 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -304,7 +304,10 @@ tests = tst-typesizes \
 			    c89 gnu89 c99 gnu99 c11 gnu11) \
 	tst-bad-schedattr \
 	tst-thread_local1 tst-mutex-errorcheck tst-robust10 \
-	tst-robust-fork tst-create-detached
+	tst-robust-fork tst-create-detached \
+	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
 xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
 	tst-mutexpp1 tst-mutexpp6 tst-mutexpp10
 test-srcs = tst-oddstacklimit
diff --git a/nptl/tst-call-once.c b/nptl/tst-call-once.c
new file mode 100644
index 0000000..331174e
--- /dev/null
+++ b/nptl/tst-call-once.c
@@ -0,0 +1,66 @@
+/* C11 threads call_once test.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Flag that controls the first thread access.  */
+static once_flag flag = ONCE_FLAG_INIT;
+
+static int value = 0;
+
+static void
+do_once (void)
+{
+  value++;
+}
+
+static int
+func (void* data)
+{
+  call_once (&flag, do_once);
+  thrd_exit (thrd_success);
+}
+
+#define N 20
+
+int
+do_test (void)
+{
+  thrd_t ids[N];
+
+  for (int i = 0; i < N; ++i)
+    {
+      if (thrd_create (&ids[i], func, NULL) != thrd_success)
+	FAIL_EXIT1 ("thrd_create failed");
+    }
+
+  /* Join threads.  */
+  for (int i = 0; i < N; ++i)
+    {
+      if (thrd_join (ids[i], NULL) != thrd_success)
+	FAIL_EXIT1 ("thrd_join failed");
+    }
+
+  return (value != 1);
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-cnd-basic.c b/nptl/tst-cnd-basic.c
new file mode 100644
index 0000000..56de4d7
--- /dev/null
+++ b/nptl/tst-cnd-basic.c
@@ -0,0 +1,68 @@
+/* C11 threads condition variable tests.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Shared condition variable between child and parent.  */
+static cnd_t cond;
+
+/* Mutex needed to signal and wait threads.  */
+static mtx_t mutex;
+
+static int
+signal_parent (void)
+{
+  if (cnd_signal (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_signal");
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+
+  if (cnd_init (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_init failed");
+  if (mtx_init (&mutex, mtx_plain) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  if (thrd_create (&id, (thrd_start_t) signal_parent, NULL)
+      != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  if (cnd_wait (&cond, &mutex) != thrd_success)
+    FAIL_EXIT1 ("cnd_wait failed");
+
+  /* Joining is not mandatory here, but still done to assure child thread
+     ends correctly.  */
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_join failed");
+
+  mtx_destroy (&mutex);
+  cnd_destroy (&cond);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-cnd-broadcast.c b/nptl/tst-cnd-broadcast.c
new file mode 100644
index 0000000..1ca87a3
--- /dev/null
+++ b/nptl/tst-cnd-broadcast.c
@@ -0,0 +1,83 @@
+/* C11 threads condition broadcast variable tests.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Condition variable where child threads will wait.  */
+static cnd_t cond;
+
+/* Mutex to control wait on cond.  */
+static mtx_t mutex;
+
+/* Code executed by each thread.  */
+static int
+child_wait (void* data)
+{
+  /* Wait until parent thread sends broadcast here.  */
+  mtx_lock (&mutex);
+  cnd_wait (&cond, &mutex);
+  mtx_unlock (&mutex);
+
+  thrd_exit (thrd_success);
+}
+
+#define N 5
+
+static int
+do_test (void)
+{
+  thrd_t ids[N];
+  unsigned char i;
+
+  if (cnd_init (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_init failed");
+  if (mtx_init (&mutex, mtx_plain) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  /* Create N new threads.  */
+  for (i = 0; i < N; ++i)
+    {
+      if (thrd_create (&ids[i], child_wait, NULL) != thrd_success)
+	FAIL_EXIT1 ("thrd_create failed");
+    }
+
+  /* Wait for other threads to reach their wait func.  */
+  thrd_sleep (&((struct timespec){.tv_sec = 2}), NULL);
+
+  mtx_lock (&mutex);
+  if (cnd_broadcast (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_broadcast failed");
+  mtx_unlock (&mutex);
+
+  for (i = 0; i < N; ++i)
+    {
+      if (thrd_join (ids[i], NULL) != thrd_success)
+	FAIL_EXIT1 ("thrd_join failed");
+    }
+
+  mtx_destroy (&mutex);
+  cnd_destroy (&cond);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-cnd-timedwait.c b/nptl/tst-cnd-timedwait.c
new file mode 100644
index 0000000..64a9546
--- /dev/null
+++ b/nptl/tst-cnd-timedwait.c
@@ -0,0 +1,70 @@
+/* C11 threads condition timed wait variable tests.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Shared condition variable between child and parent.  */
+static cnd_t cond;
+
+/* Mutex needed to signal and wait threads.  */
+static mtx_t mutex;
+
+static int
+signal_parent (void *arg)
+{
+  if (cnd_signal (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_signal failed");
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+  struct timespec w_time;
+
+  if (cnd_init (&cond) != thrd_success)
+    FAIL_EXIT1 ("cnd_init failed");
+  if (mtx_init (&mutex, mtx_plain) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  if (clock_gettime (CLOCK_REALTIME, &w_time) != 0)
+    FAIL_EXIT1 ("clock_gettime failed");
+  w_time.tv_nsec += 150000;
+
+  if (thrd_create (&id, signal_parent, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  if (cnd_timedwait (&cond, &mutex, &w_time) != thrd_success)
+    FAIL_EXIT1 ("cnd_timedwait failed");
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_join failed");
+
+  mtx_destroy (&mutex);
+  cnd_destroy (&cond);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-mtx-basic.c b/nptl/tst-mtx-basic.c
new file mode 100644
index 0000000..c064405
--- /dev/null
+++ b/nptl/tst-mtx-basic.c
@@ -0,0 +1,73 @@
+/* C11 threads basic mutex tests.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Shared mutex between child and parent.  */
+static mtx_t mutex;
+
+/* Shared counter to check possible race conditions.  */
+static int counter;
+
+static int
+child_add (void *arg)
+{
+  if (mtx_lock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_lock failed");
+
+  counter++;
+
+  if (mtx_unlock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_unlock failed");
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  mtx_init (&mutex, mtx_plain);
+
+  thrd_t id;
+  if (thrd_create (&id, child_add, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  if (mtx_lock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_lock failed");
+
+  counter++;
+
+  if (mtx_unlock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_unlock failed");
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_join failed");
+
+  if (counter != 2)
+    FAIL_EXIT1 ("counter (%d) != 2", counter);
+
+  mtx_destroy (&mutex);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-mtx-recursive.c b/nptl/tst-mtx-recursive.c
new file mode 100644
index 0000000..df959c7
--- /dev/null
+++ b/nptl/tst-mtx-recursive.c
@@ -0,0 +1,45 @@
+/* C11 threads recursive mutex tests.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  static mtx_t mutex;
+
+  if (mtx_init (&mutex, mtx_recursive) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  if (mtx_lock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_lock failed");
+
+  /* Lock mutex second time, if not recursive should deadlock.  */
+  if (mtx_lock (&mutex) != thrd_success)
+    FAIL_EXIT1 ("mtx_lock failed");
+
+  mtx_destroy (&mutex);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-mtx-timedlock.c b/nptl/tst-mtx-timedlock.c
new file mode 100644
index 0000000..1f02bd4
--- /dev/null
+++ b/nptl/tst-mtx-timedlock.c
@@ -0,0 +1,98 @@
+/* C11 threads timed mutex tests.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Shared mutex between child and parent.  */
+static mtx_t mutex;
+
+/* Shared counter to check possible race conditions.  */
+static char shrd_counter;
+
+/* Maximum amount of time waiting for mutex.  */
+static struct timespec wait_time;
+
+/* Function to choose an action to do, depending on mtx_timedlock
+   return value.  */
+static inline void
+choose_action (int action, char* thread_name)
+{
+  switch (action)
+    {
+      case thrd_success:
+        ++shrd_counter;
+
+	if (mtx_unlock (&mutex) != thrd_success)
+	  FAIL_EXIT1 ("mtx_unlock failed");
+      break;
+
+      case thrd_timedout:
+        break;
+
+      case thrd_error:
+	FAIL_EXIT1 ("%s lock error", thread_name);
+        break;
+    }
+}
+
+static int
+child_add (void *arg)
+{
+  char child_name[] = "child";
+
+  /* Try to lock mutex.  */
+  choose_action (mtx_timedlock (&mutex, &wait_time), child_name);
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+  char parent_name[] = "parent";
+
+  if (mtx_init (&mutex, mtx_timed) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  if (clock_gettime (CLOCK_REALTIME, &wait_time) != 0)
+    FAIL_EXIT1 ("clock_gettime failed");
+  /* Tiny amount of time, to assure that if any thread finds it busy.
+     It will receive thrd_timedout.  */
+  wait_time.tv_nsec += 1;
+
+  if (thrd_create (&id, child_add, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  choose_action (mtx_timedlock (&mutex, &wait_time), parent_name);
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_join failed");
+
+  if (shrd_counter != 2 && shrd_counter != 1)
+    FAIL_EXIT1 ("shrd_counter != {1,2} (%d)", shrd_counter);
+
+  mtx_destroy (&mutex);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-mtx-trylock.c b/nptl/tst-mtx-trylock.c
new file mode 100644
index 0000000..5c1e804
--- /dev/null
+++ b/nptl/tst-mtx-trylock.c
@@ -0,0 +1,90 @@
+/* C11 threads trylock mutex tests.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Shared mutex between child and parent.  */
+static mtx_t mutex;
+
+/* Shared counter to check possible race conditions.  */
+static char shrd_counter;
+
+/* Function to choose an action to do, depending on mtx_trylock
+   return value.  */
+static inline void
+choose_action (int action, char* thread_name)
+{
+  switch (action)
+    {
+      case thrd_success:
+        ++shrd_counter;
+
+	if (mtx_unlock (&mutex) != thrd_success)
+	  FAIL_EXIT1 ("mtx_unlock failed");
+      break;
+
+      case thrd_busy:
+        break;
+
+      case thrd_error:
+	FAIL_EXIT1 ("%s lock error", thread_name);
+        break;
+    }
+}
+
+static int
+child_add (void *arg)
+{
+  char child_name[] = "child";
+
+  /* Try to lock mutex.  */
+  choose_action (mtx_trylock (&mutex), child_name);
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+  char parent_name[] = "parent";
+
+  if (mtx_init (&mutex, mtx_timed) != thrd_success)
+    FAIL_EXIT1 ("mtx_init failed");
+
+  if (thrd_create (&id, child_add, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  choose_action (mtx_trylock (&mutex), parent_name);
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_join failed");
+
+  if (shrd_counter != 2 && shrd_counter != 1)
+    FAIL_EXIT1 ("shrd_counter != {1,2} (%d)", shrd_counter);
+
+  mtx_destroy (&mutex);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-thrd-detach.c b/nptl/tst-thrd-detach.c
new file mode 100644
index 0000000..ec28173
--- /dev/null
+++ b/nptl/tst-thrd-detach.c
@@ -0,0 +1,52 @@
+/* C11 threads thread detach tests.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <threads.h>
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+static int
+detach_thrd (void *arg)
+{
+  if (thrd_detach (thrd_current ()) != thrd_success)
+    FAIL_EXIT1 ("thrd_detach failed");
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+
+  /* Create new thread.  */
+  if (thrd_create (&id, detach_thrd, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  /* Give some time so the thread can finish.  */
+  thrd_sleep (&(struct timespec){.tv_sec = 2}, NULL);
+
+  if (thrd_join (id, NULL) == thrd_success)
+    FAIL_EXIT1 ("thrd_join succeed where it should fail");
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-thrd-sleep.c b/nptl/tst-thrd-sleep.c
new file mode 100644
index 0000000..17380b2
--- /dev/null
+++ b/nptl/tst-thrd-sleep.c
@@ -0,0 +1,51 @@
+/* C11 threads thread sleep tests.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <threads.h>
+#include <time.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+static int
+sleep_thrd (void *arg)
+{
+  struct timespec const *tl = (struct timespec const *) arg;
+  if (thrd_sleep (tl, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_sleep failed");
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  thrd_t id;
+  struct timespec wait_time = {.tv_sec = 3};
+
+  if (thrd_create (&id, sleep_thrd, (void *) (&wait_time)) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd failed");
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/nptl/tst-tss-basic.c b/nptl/tst-tss-basic.c
new file mode 100644
index 0000000..8181dc1
--- /dev/null
+++ b/nptl/tst-tss-basic.c
@@ -0,0 +1,75 @@
+/* C11 threads specific storage tests.
+   Copyright (C) 2017 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <threads.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <support/check.h>
+
+/* Thread specific storage.  */
+static tss_t key;
+
+#define TSS_VALUE (void*) 0xFF
+
+static int
+tss_thrd (void *arg)
+{
+  if (tss_create (&key, NULL) != thrd_success)
+    FAIL_EXIT1 ("tss_create failed");
+
+  if (tss_set (key, TSS_VALUE))
+    FAIL_EXIT1 ("tss_set failed");
+
+  void *value = tss_get (key);
+  if (value == 0)
+    FAIL_EXIT1 ("tss_get failed");
+  if (value != TSS_VALUE)
+    FAIL_EXIT1 ("tss_get returned %p, expected %p", value, TSS_VALUE);
+
+  thrd_exit (thrd_success);
+}
+
+static int
+do_test (void)
+{
+  /* Setting an invalid key should return an error.  */
+  if (tss_set (key, TSS_VALUE) == thrd_success)
+    FAIL_EXIT1 ("tss_set succeed where it should have failed");
+
+  if (tss_create (&key, NULL) != thrd_success)
+    FAIL_EXIT1 ("tss_create failed");
+
+  thrd_t id;
+  if (thrd_create (&id, tss_thrd, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd_create failed");
+
+  if (thrd_join (id, NULL) != thrd_success)
+    FAIL_EXIT1 ("thrd failed");
+
+  /* The value set in tss_thrd should not be visible here.  */
+  void *value = tss_get (key);
+  if (value != 0)
+    FAIL_EXIT1 ("tss_get succeed where it should have failed");
+
+  tss_delete (key);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.7.4

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/6] Consolidate pthreadtype.h placement
  2017-03-21 13:40 ` [PATCH 1/6] Consolidate pthreadtype.h placement Adhemerval Zanella
@ 2017-03-21 13:48   ` Andreas Schwab
  2017-03-21 15:07     ` Adhemerval Zanella
  0 siblings, 1 reply; 26+ messages in thread
From: Andreas Schwab @ 2017-03-21 13:48 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Mär 21 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> This patch moves all arch specific pthreadtypes.h to a similar path
> for all architectures (sysdeps/unix/sysv/<arch>/bits).

The description doesn't agree with the patch.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/6] Consolidate pthreadtype.h placement
  2017-03-21 13:48   ` Andreas Schwab
@ 2017-03-21 15:07     ` Adhemerval Zanella
  0 siblings, 0 replies; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-21 15:07 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha



On 21/03/2017 10:48, Andreas Schwab wrote:
> On Mär 21 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
> 
>> This patch moves all arch specific pthreadtypes.h to a similar path
>> for all architectures (sysdeps/unix/sysv/<arch>/bits).
> 
> The description doesn't agree with the patch.
> 
> Andreas.
> 

Indeed, my confusion here.  It in fact changes from
sysdeps/{unix/sysv/linux/<arch> => <arch>/nptl}/bits/.  I will
correctly it locally, thanks.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-03-21 13:40 [PATCH v3 0/6] Add support for ISO C11 threads.h Adhemerval Zanella
                   ` (5 preceding siblings ...)
  2017-03-21 13:40 ` [PATCH 5/6] Add test cases for ISO C11 threads Adhemerval Zanella
@ 2017-03-21 16:25 ` Joseph Myers
  2017-03-21 16:44   ` Adhemerval Zanella
  6 siblings, 1 reply; 26+ messages in thread
From: Joseph Myers @ 2017-03-21 16:25 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Tue, 21 Mar 2017, Adhemerval Zanella wrote:

>   - Addresses Joseph's comments from [2] and ad indicated in
>     in C11 thread patch I based this implementation from th
>     public C11 thread document I have access [3]. I would ask for
>     suggestion and change if it deviates from the final standard
>     definition.

Did you review those C11 DRs related to threads to make sure the 
implementation behaves properly regarding issues raised in those DRs (and 
that there are tests of this if applicable)?

Current DR log: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2109.htm

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-03-21 16:25 ` [PATCH v3 0/6] Add support for ISO C11 threads.h Joseph Myers
@ 2017-03-21 16:44   ` Adhemerval Zanella
  2017-03-21 16:49     ` Joseph Myers
  0 siblings, 1 reply; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-21 16:44 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 21/03/2017 13:25, Joseph Myers wrote:
> On Tue, 21 Mar 2017, Adhemerval Zanella wrote:
> 
>>   - Addresses Joseph's comments from [2] and ad indicated in
>>     in C11 thread patch I based this implementation from th
>>     public C11 thread document I have access [3]. I would ask for
>>     suggestion and change if it deviates from the final standard
>>     definition.
> 
> Did you review those C11 DRs related to threads to make sure the 
> implementation behaves properly regarding issues raised in those DRs (and 
> that there are tests of this if applicable)?
> 
> Current DR log: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2109.htm
> 

Thanks for the link, I will check this out. Do you know off the top of your 
head which ones would be applicable? 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-03-21 16:44   ` Adhemerval Zanella
@ 2017-03-21 16:49     ` Joseph Myers
  2017-03-21 17:08       ` Adhemerval Zanella
                         ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Joseph Myers @ 2017-03-21 16:49 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Tue, 21 Mar 2017, Adhemerval Zanella wrote:

> > Did you review those C11 DRs related to threads to make sure the 
> > implementation behaves properly regarding issues raised in those DRs (and 
> > that there are tests of this if applicable)?
> > 
> > Current DR log: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2109.htm
> > 
> 
> Thanks for the link, I will check this out. Do you know off the top of your 
> head which ones would be applicable? 

It appears to be: 405 414 416 424 449 469 470 479 480 493.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-03-21 16:49     ` Joseph Myers
@ 2017-03-21 17:08       ` Adhemerval Zanella
  2017-03-21 20:10       ` Adhemerval Zanella
  2017-03-27 13:29       ` Torvald Riegel
  2 siblings, 0 replies; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-21 17:08 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 21/03/2017 13:49, Joseph Myers wrote:
> It appears to be: 405 414 416 424 449 469 470 479 480 493.

Thank you.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-03-21 16:49     ` Joseph Myers
  2017-03-21 17:08       ` Adhemerval Zanella
@ 2017-03-21 20:10       ` Adhemerval Zanella
  2017-03-27 13:29         ` Torvald Riegel
  2017-03-27 13:29       ` Torvald Riegel
  2 siblings, 1 reply; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-21 20:10 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha, Torvald Riegel, Martin Sebor



On 21/03/2017 13:49, Joseph Myers wrote:
> On Tue, 21 Mar 2017, Adhemerval Zanella wrote:
> 
>>> Did you review those C11 DRs related to threads to make sure the 
>>> implementation behaves properly regarding issues raised in those DRs (and 
>>> that there are tests of this if applicable)?
>>>
>>> Current DR log: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2109.htm
>>>
>>
>> Thanks for the link, I will check this out. Do you know off the top of your 
>> head which ones would be applicable? 
> 
> It appears to be: 405 414 416 424 449 469 470 479 480 493.

It indeed seems to be one related to threads definitions and in general
C11 clarification seems to align with POSIX thread definition, which
simplifies its implementation.  However I see some problematic ones:
416 (tss_t destruction unspecified) and 493 (Mutex Initialization
Underspecified), so I am copying Tovarld's and Martin since they were the
one that raised most the DR.  It could be good if they is any impending
reason to avoid implement C11 thread over POSIX primitives based
on current standard.

Below some observation of the raised DRs related to current patch
proposal:

405: The mutex specification

"The C11 specification of mutexes is missing the total order over all the
 calls on a particular mutex."

My understanding is current implementation with POSIX primitives should be
enough to guarantee C11 total order over mutex (which is currently based on
acquire/release semanthics).


416: tss_t destruction unspecified

I could not find any impeding wording from the proposed technical corrigendum
that would prevent us to implement tss function on top of pthread key ones.


414: Typos in 6.27 Threads <threads.h> 

The typos does clarify one definition of mtx_plain and raises a questioning: 
how should we proceed if mtx_timedlock is used along with a mtx_plain mutex? 

My understanding is thrd_error should be returned, however current GLIBC 
implementation makes no distinction between PTHREAD_MUTEX_NORMAL and 
PTHREAD_MUTEX_TIMED_NP (and current C11 patch follows this semanthic).

It is feasible to do so, but it would require maybe an extra field in
mtx_t definition or a GNU-only thread type (maybe not intended to be
exposed).


424: underspecification of tss_t

These issues are covered under DR 416.


449: What is the value of TSS_DTOR_ITERATIONS for implementations with no maximum?

The proposed committee response was to intentionally do not define a value of 
TSS_DTOR_ITERATIONS, so my view is align with PTHREAD_DESTRUCTOR_ITERATIONS 
should be suffice (even though various architectures redefine 
_POSIX_THREAD_DESTRUCTOR_ITERATIONS to same value in local_lim.h).


469: lock ownership vs. thread termination

Defined as future.  However from last committee discussion it seems that
they are aiming for similar POSIX description.  So I am not sure if there
is any impending stardard definition to use underlying POSIX implementation.


470: mtx_trylock should be allowed to fail spuriously

It align with POSIX and thus with __pthread_mutex_trylock which uses a 
atomic_compare_and_exchange_bool_acq (similar to atomic_compare_exchange_weak).


479: unclear specification of mtx_trylock on non-recursive muteness

Defined as future. I am not aware of any issue trying to use POSIX
in underlying implementation.


480: cnd_wait and cnd_timewait should allow spurious wake-ups

Define as open, although my understanding is C11 definitions from last proposed
technical corrigendum may now allow spurious wakes ups (from the words "until
it is unblocked due to an unspecified reason"). So I think implementing
cnd_{timed}wait as pthread_cond_{timed}wait wrapper should be still valid.


493: Mutex Initialization Underspecified

Define as open and the proposed committee response follows:

  - Problems with mtx_init(): I think the only applicable point to curent
    patch is the last one:

    7. thrd_error shall be returned by mtx_init() when passed a NULL pointer.

    Which currently leads to a segfault (since it is based on pthread_mutex_init).
    It is simple to align current patch proposal to this specification.

  - Problems with mtx_destroy(): wording aligns with POSIX definition, so
    implementing mtx_destroy as a pthread_mutex_destroy wrapper should be ok.

  - Other Problems: wording aligns with POSIX definition as well, so I think
    there is no requirement to change for current patch.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/6] Move mutex and condition variable definition to common header
  2017-03-21 13:40 ` [PATCH 2/6] Move mutex and condition variable definition to common header Adhemerval Zanella
@ 2017-03-22 22:59   ` Ivo Raisr
  2017-03-27 13:43   ` Torvald Riegel
  1 sibling, 0 replies; 26+ messages in thread
From: Ivo Raisr @ 2017-03-22 22:59 UTC (permalink / raw)
  To: libc-alpha; +Cc: Adhemerval Zanella

Thank you for the patches.
See my comment below.
I.

On 21.3.2017 14:40, Adhemerval Zanella wrote:
> This patch sorts out pthread_mutex_t and pthread_cond_t in new files,
> so new C11 types could be based on pthread types without corrupting
> namespaces and exposing pthread symbols.
...
>
> diff --git a/bits/thread-shared-types.h b/bits/thread-shared-types.h
> new file mode 100644
> index 0000000..98f2084
> --- /dev/null
> +++ b/bits/thread-shared-types.h
> +/* This file is required to have a shared types definition
> +   between POSIX threads and C11 threads. It allows to
> +   header files like pthread.h and thread.h to define their types
> +   with the same size and fields without corrupting namespaces.

Typo here. I'd suggest:
-   between POSIX threads and C11 threads. It allows to
+   between POSIX threads and C11 threads. It allows

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-03-21 16:49     ` Joseph Myers
  2017-03-21 17:08       ` Adhemerval Zanella
  2017-03-21 20:10       ` Adhemerval Zanella
@ 2017-03-27 13:29       ` Torvald Riegel
  2017-03-27 16:10         ` Martin Sebor
  2 siblings, 1 reply; 26+ messages in thread
From: Torvald Riegel @ 2017-03-27 13:29 UTC (permalink / raw)
  To: Joseph Myers; +Cc: Adhemerval Zanella, libc-alpha, Martin Sebor, Stefan Liebler

On Tue, 2017-03-21 at 16:49 +0000, Joseph Myers wrote:
> On Tue, 21 Mar 2017, Adhemerval Zanella wrote:
> 
> > > Did you review those C11 DRs related to threads to make sure the 
> > > implementation behaves properly regarding issues raised in those DRs (and 
> > > that there are tests of this if applicable)?
> > > 
> > > Current DR log: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2109.htm
> > > 
> > 
> > Thanks for the link, I will check this out. Do you know off the top of your 
> > head which ones would be applicable? 
> 
> It appears to be: 405 414 416 424 449 469 470 479 480 493.
> 

Here's my take on these:

405, 414:
Some of these DRs affect implementations, but there's nothing
contentious in these I believe.

416, 424, 449:
I haven't looked at these before and can't comment on them currently.

469:
What I proposed should be clarified by C matches our implementation.
The committee seems to agree.
POSIX makes stronger requirements on the implementation, which we do not
implement (and what I do not intend to implement).  I have arguend in a
POSIX bug that POSIX should not make these stronger requirements (sorry,
don't have the bug number handy).

470:
C11's requirements on implementations are weaker than what POSIX
requires. Arguably, POSIX should require what C11 requires.
We need to check the lowlevellock implementation, in particular on archs
that use LL/SC (I'm not aware of an arch with a true CAS instruction
that can fail spuriously).
Our generic lowlevellock implementation on master still uses the
old-style atomics (ie, atomic_compare_and_exchange_bool_acq); if we move
to C11 atomics, C11 (with DR 470's proposed corrigendum applied) would
require our atomic_compare_exchange_weak_acquire, whereas current POSIX
would require the strong variant of the CAS.
Thus, what we do is okay in terms of C11.
I don't recall right now whether we have an open Austin Group bug about
POSIX allowing a spurious failure; I believe we have, or we should,
because this is also related to what memory order is required for lock
acquisitions (generally, not just trylock).
(Stefan, that's why I'm CC'ing you too, this is relevant for
pthread_spin_trylock too, but I can't remember right now whether we
already discussed this or not.)


479:
Our implementation is correct.
What C++ requires from a program, and what the committee agrees C11
should require, is stronger than what POSIX requires.  This means that
the C11 implementation of trylock would not have to conservatively abort
transactions in the lock elision implementation for the non-recursive
mutexes.

480:
A specification bug.  Committee agrees with what we implement.


493:
The intent of the standard as stated by the committee in this DR seems
to be compatible with what glibc implements and could implement in the
foreseeable future.

Martin,
please correct anything I got wrong.  Also, I assume you are tracking
these DRs, so please give us a heads up if the committee should change
its mind in a way that conflicts with what we implement.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-03-21 20:10       ` Adhemerval Zanella
@ 2017-03-27 13:29         ` Torvald Riegel
  0 siblings, 0 replies; 26+ messages in thread
From: Torvald Riegel @ 2017-03-27 13:29 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: Joseph Myers, libc-alpha, Martin Sebor

On Tue, 2017-03-21 at 17:09 -0300, Adhemerval Zanella wrote:
> 405: The mutex specification
> 
> "The C11 specification of mutexes is missing the total order over all the
>  calls on a particular mutex."
> 
> My understanding is current implementation with POSIX primitives should be
> enough to guarantee C11 total order over mutex (which is currently based on
> acquire/release semanthics).

Yes.

> 414: Typos in 6.27 Threads <threads.h> 
> 
> The typos does clarify one definition of mtx_plain and raises a questioning: 
> how should we proceed if mtx_timedlock is used along with a mtx_plain mutex? 

If C11 requires that mtx_timedlock is supplied a mutex that supports
timeout.  If the program violates this requirement, it is undefined
behavior, and glibc is allowed to just acquire with a timeout.

> 469: lock ownership vs. thread termination

See my other response to this thread.

> 
> 470: mtx_trylock should be allowed to fail spuriously
> 
> It align with POSIX and thus with __pthread_mutex_trylock which uses a 
> atomic_compare_and_exchange_bool_acq (similar to atomic_compare_exchange_weak).

That's not quite true.  See my other response.

> 479: unclear specification of mtx_trylock on non-recursive muteness

> 480: cnd_wait and cnd_timewait should allow spurious wake-ups

See my other response to this thread.


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/6] Move mutex and condition variable definition to common header
  2017-03-21 13:40 ` [PATCH 2/6] Move mutex and condition variable definition to common header Adhemerval Zanella
  2017-03-22 22:59   ` Ivo Raisr
@ 2017-03-27 13:43   ` Torvald Riegel
  2017-03-27 14:25     ` Adhemerval Zanella
  1 sibling, 1 reply; 26+ messages in thread
From: Torvald Riegel @ 2017-03-27 13:43 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Tue, 2017-03-21 at 10:40 -0300, Adhemerval Zanella wrote:
> This patch sorts out pthread_mutex_t and pthread_cond_t in new files,
> so new C11 types could be based on pthread types without corrupting
> namespaces and exposing pthread symbols.
> 
> Common pthread types like pthread_mutex_t and pthread_cond_t are now
> defined in arch specific bits/pthreadtypes-common.h headers, while the
> internal implementation is moved to bits/thread-shared-types.h.  File
> pthreadtypes.h is cleaned up of those definitions and some related macros
> and structures.

If we are moving declarations in pthreadtypes.h around, can we just
merge those that are common?  Most of the archs just use the same
generic code or at least the same underlying data structure; most of the
differences I remember where some additional alignment requirements,
which probably could be handled by an additional macro that
arch-specific files have to define.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/6] Move mutex and condition variable definition to common header
  2017-03-27 13:43   ` Torvald Riegel
@ 2017-03-27 14:25     ` Adhemerval Zanella
  2017-03-28  8:19       ` Torvald Riegel
  0 siblings, 1 reply; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-27 14:25 UTC (permalink / raw)
  To: Torvald Riegel; +Cc: libc-alpha



On 27/03/2017 10:43, Torvald Riegel wrote:
> On Tue, 2017-03-21 at 10:40 -0300, Adhemerval Zanella wrote:
>> This patch sorts out pthread_mutex_t and pthread_cond_t in new files,
>> so new C11 types could be based on pthread types without corrupting
>> namespaces and exposing pthread symbols.
>>
>> Common pthread types like pthread_mutex_t and pthread_cond_t are now
>> defined in arch specific bits/pthreadtypes-common.h headers, while the
>> internal implementation is moved to bits/thread-shared-types.h.  File
>> pthreadtypes.h is cleaned up of those definitions and some related macros
>> and structures.
> 
> If we are moving declarations in pthreadtypes.h around, can we just
> merge those that are common?  Most of the archs just use the same
> generic code or at least the same underlying data structure; most of the
> differences I remember where some additional alignment requirements,
> which probably could be handled by an additional macro that
> arch-specific files have to define.
> 

I would also like to consolidate the pthreadtypes definition in one header,
however I rather than make it on a following patchset instead.  But I think
have the correct approach is required to avoid a double refactor.  I chose
to keep using the macros (__PTHREAD_COND_T_CONTENT and __PTHREAD_MUTEX_T_CONTENT)
because it is the most straightforward arrange, however maybe using a composed
struct with defines to access the direct member could be a better strategy.
Thoughts? 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-03-27 13:29       ` Torvald Riegel
@ 2017-03-27 16:10         ` Martin Sebor
  2017-03-28  8:08           ` Torvald Riegel
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Sebor @ 2017-03-27 16:10 UTC (permalink / raw)
  To: Torvald Riegel, Joseph Myers
  Cc: Adhemerval Zanella, libc-alpha, Martin Sebor, Stefan Liebler

On 03/27/2017 03:25 AM, Torvald Riegel wrote:
> On Tue, 2017-03-21 at 16:49 +0000, Joseph Myers wrote:
>> On Tue, 21 Mar 2017, Adhemerval Zanella wrote:
>>
>>>> Did you review those C11 DRs related to threads to make sure the
>>>> implementation behaves properly regarding issues raised in those DRs (and
>>>> that there are tests of this if applicable)?
>>>>
>>>> Current DR log: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2109.htm
>>>>
>>>
>>> Thanks for the link, I will check this out. Do you know off the top of your
>>> head which ones would be applicable?
>>
>> It appears to be: 405 414 416 424 449 469 470 479 480 493.
>>
>
> Here's my take on these:

I've reviewed the DRs and your comments below.  I agree with
your view and just for clarity provide some additional comments
of my own.

>
> 405, 414:
> Some of these DRs affect implementations, but there's nothing
> contentious in these I believe.

Agreed.

>
> 416, 424, 449:
> I haven't looked at these before and can't comment on them currently.

The 416 corrignedum was accepted.  424 was rolled into 416, and
449 resulted in no changes.

>
> 469:
> What I proposed should be clarified by C matches our implementation.
> The committee seems to agree.
> POSIX makes stronger requirements on the implementation, which we do not
> implement (and what I do not intend to implement).  I have arguend in a
> POSIX bug that POSIX should not make these stronger requirements (sorry,
> don't have the bug number handy).

This issue was closed with the expectation that it will be resolved
in C2X.  Unless someone else steps up it will likely mean that you
(or we) will have to propose the changes you/we would like to see.

> 470:
> C11's requirements on implementations are weaker than what POSIX
> requires. Arguably, POSIX should require what C11 requires.
> We need to check the lowlevellock implementation, in particular on archs
> that use LL/SC (I'm not aware of an arch with a true CAS instruction
> that can fail spuriously).
> Our generic lowlevellock implementation on master still uses the
> old-style atomics (ie, atomic_compare_and_exchange_bool_acq); if we move
> to C11 atomics, C11 (with DR 470's proposed corrigendum applied) would
> require our atomic_compare_exchange_weak_acquire, whereas current POSIX
> would require the strong variant of the CAS.
> Thus, what we do is okay in terms of C11.
> I don't recall right now whether we have an open Austin Group bug about
> POSIX allowing a spurious failure; I believe we have, or we should,
> because this is also related to what memory order is required for lock
> acquisitions (generally, not just trylock).
> (Stefan, that's why I'm CC'ing you too, this is relevant for
> pthread_spin_trylock too, but I can't remember right now whether we
> already discussed this or not.)
>

The resolution for the DR was accepted and the DR is closed.
The change will be in the 2017 C11 TC.  If other changes are
required here a new issue will need to be submitted that will
be considered for C2X.

>
> 479:
> Our implementation is correct.
> What C++ requires from a program, and what the committee agrees C11
> should require, is stronger than what POSIX requires.  This means that
> the C11 implementation of trylock would not have to conservatively abort
> transactions in the lock elision implementation for the non-recursive
> mutexes.

Here it sounds like as the authors of the DR we're on the hook
for providing wording that the rest of WG14 agrees with.  This
too will be considered for C2X.

>
> 480:
> A specification bug.  Committee agrees with what we implement.
>
>
> 493:
> The intent of the standard as stated by the committee in this DR seems
> to be compatible with what glibc implements and could implement in the
> foreseeable future.

This DR is still Open and needs a proposed resolution.

>
> Martin,
> please correct anything I got wrong.  Also, I assume you are tracking
> these DRs, so please give us a heads up if the committee should change
> its mind in a way that conflicts with what we implement.

Most of the DRs on the list are in a Closed state with (presumably)
clear resolutions.  As I understand the C11 schedule, the outstanding
ones that are still Open or labeled Future will not be fixed in
the final corrigendum that's expected to be finalized this year.
After 2017 there will not be any further C11 corrigenda.  C2X will
the next work item on WG14's list.

There's been a lot of talk over the last few WG14 meetings about
the whole threads section needing an overhaul.  I don't know if
anyone is actually working on it but if it were to happen (for
C2X) there is some risk that an implementation coded to the C11
spec not conforming to the cleaned up and improved C2X spec.

Martin

PS Besides the issues list there are at least two other documents
that could offer additional insight or guidance here.  The C2X
charter that outlines the guiding principles for C2X development:

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2021.htm

In addition, the WG14 Convener maintains a standing document where
he tracks a subset of issues that have come up over the years and
that he wants WG14 to review for C2X.  This is not a complete list,
just some select items.

http://www.open-std.org/JTC1/SC22/WG14/www/docs/n2087.htm

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-03-27 16:10         ` Martin Sebor
@ 2017-03-28  8:08           ` Torvald Riegel
  2017-03-31 13:39             ` Adhemerval Zanella
  0 siblings, 1 reply; 26+ messages in thread
From: Torvald Riegel @ 2017-03-28  8:08 UTC (permalink / raw)
  To: Martin Sebor
  Cc: Joseph Myers, Adhemerval Zanella, libc-alpha, Martin Sebor,
	Stefan Liebler

On Mon, 2017-03-27 at 10:10 -0600, Martin Sebor wrote:
> I've reviewed the DRs and your comments below.  I agree with
> your view and just for clarity provide some additional comments
> of my own.

Thanks!

> There's been a lot of talk over the last few WG14 meetings about
> the whole threads section needing an overhaul.  I don't know if
> anyone is actually working on it but if it were to happen (for
> C2X) there is some risk that an implementation coded to the C11
> spec not conforming to the cleaned up and improved C2X spec.

I'd hope that they wouldn't deviate from what C++ specifies.  I'm
monitoring C++ changes, including whether anything would result in
required changes for glibc.  IOW, if C doesn't deviate from C++, we
shouldn't need additional changes just for C.


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/6] Move mutex and condition variable definition to common header
  2017-03-27 14:25     ` Adhemerval Zanella
@ 2017-03-28  8:19       ` Torvald Riegel
  2017-03-31 13:43         ` Adhemerval Zanella
  0 siblings, 1 reply; 26+ messages in thread
From: Torvald Riegel @ 2017-03-28  8:19 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Mon, 2017-03-27 at 11:24 -0300, Adhemerval Zanella wrote:
> 
> On 27/03/2017 10:43, Torvald Riegel wrote:
> > On Tue, 2017-03-21 at 10:40 -0300, Adhemerval Zanella wrote:
> >> This patch sorts out pthread_mutex_t and pthread_cond_t in new files,
> >> so new C11 types could be based on pthread types without corrupting
> >> namespaces and exposing pthread symbols.
> >>
> >> Common pthread types like pthread_mutex_t and pthread_cond_t are now
> >> defined in arch specific bits/pthreadtypes-common.h headers, while the
> >> internal implementation is moved to bits/thread-shared-types.h.  File
> >> pthreadtypes.h is cleaned up of those definitions and some related macros
> >> and structures.
> > 
> > If we are moving declarations in pthreadtypes.h around, can we just
> > merge those that are common?  Most of the archs just use the same
> > generic code or at least the same underlying data structure; most of the
> > differences I remember where some additional alignment requirements,
> > which probably could be handled by an additional macro that
> > arch-specific files have to define.
> > 
> 
> I would also like to consolidate the pthreadtypes definition in one header,
> however I rather than make it on a following patchset instead.

If that's easier for you, then that's certainly okay.  I just saw that
you are moving quite a bit of (mostly) redundant code around, and
thought whether it would be easier to merge it first, so that less code
needs to be moved.

> But I think
> have the correct approach is required to avoid a double refactor.  I chose
> to keep using the macros (__PTHREAD_COND_T_CONTENT and __PTHREAD_MUTEX_T_CONTENT)
> because it is the most straightforward arrange, however maybe using a composed
> struct with defines to access the direct member could be a better strategy.
> Thoughts? 

AFAIR the differences between most of the pthread types, it mostly is a
different alignment specifier here and there.  Things like sparc pre-v9
and maybe hppa are exceptions, but the rest is pretty much the same
everywhere.

Can we have just one definition of what's __PTHREAD_COND_T_CONTENT etc.
now, and keep that in a file and include it everywhere (with additional
modifier macros for things like the aligment specifiers, which would be
defined in an arch-specific file)?  Or does that bring up the namespace
problem you want to avoid?

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-03-28  8:08           ` Torvald Riegel
@ 2017-03-31 13:39             ` Adhemerval Zanella
  2017-04-06 11:05               ` Torvald Riegel
  0 siblings, 1 reply; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-31 13:39 UTC (permalink / raw)
  To: Torvald Riegel, Martin Sebor
  Cc: Joseph Myers, libc-alpha, Martin Sebor, Stefan Liebler



On 28/03/2017 05:08, Torvald Riegel wrote:
> On Mon, 2017-03-27 at 10:10 -0600, Martin Sebor wrote:
>> I've reviewed the DRs and your comments below.  I agree with
>> your view and just for clarity provide some additional comments
>> of my own.
> 
> Thanks!
> 
>> There's been a lot of talk over the last few WG14 meetings about
>> the whole threads section needing an overhaul.  I don't know if
>> anyone is actually working on it but if it were to happen (for
>> C2X) there is some risk that an implementation coded to the C11
>> spec not conforming to the cleaned up and improved C2X spec.
> 
> I'd hope that they wouldn't deviate from what C++ specifies.  I'm
> monitoring C++ changes, including whether anything would result in
> required changes for glibc.  IOW, if C doesn't deviate from C++, we
> shouldn't need additional changes just for C.
> 

Thanks for both extensive inputs and discussion.  From the comments I 
see that a current C11 thread based on POSIX could be still be feasible,
however I am not sure if we should prevent its implementation based on 
the C2X possible different spec.

In any way, I see that the still pending DR493 should not pose any
implementation issues (we can work out on the wrapper if any other
requirement is posed).

So I would like the input from the community whether implementing C11
in GLIBC is desirable and if current approach based is most correct
one.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/6] Move mutex and condition variable definition to common header
  2017-03-28  8:19       ` Torvald Riegel
@ 2017-03-31 13:43         ` Adhemerval Zanella
  0 siblings, 0 replies; 26+ messages in thread
From: Adhemerval Zanella @ 2017-03-31 13:43 UTC (permalink / raw)
  To: Torvald Riegel; +Cc: libc-alpha



On 28/03/2017 05:19, Torvald Riegel wrote:
> On Mon, 2017-03-27 at 11:24 -0300, Adhemerval Zanella wrote:
>>
>> On 27/03/2017 10:43, Torvald Riegel wrote:
>>> On Tue, 2017-03-21 at 10:40 -0300, Adhemerval Zanella wrote:
>>>> This patch sorts out pthread_mutex_t and pthread_cond_t in new files,
>>>> so new C11 types could be based on pthread types without corrupting
>>>> namespaces and exposing pthread symbols.
>>>>
>>>> Common pthread types like pthread_mutex_t and pthread_cond_t are now
>>>> defined in arch specific bits/pthreadtypes-common.h headers, while the
>>>> internal implementation is moved to bits/thread-shared-types.h.  File
>>>> pthreadtypes.h is cleaned up of those definitions and some related macros
>>>> and structures.
>>>
>>> If we are moving declarations in pthreadtypes.h around, can we just
>>> merge those that are common?  Most of the archs just use the same
>>> generic code or at least the same underlying data structure; most of the
>>> differences I remember where some additional alignment requirements,
>>> which probably could be handled by an additional macro that
>>> arch-specific files have to define.
>>>
>>
>> I would also like to consolidate the pthreadtypes definition in one header,
>> however I rather than make it on a following patchset instead.
> 
> If that's easier for you, then that's certainly okay.  I just saw that
> you are moving quite a bit of (mostly) redundant code around, and
> thought whether it would be easier to merge it first, so that less code
> needs to be moved.
> 
>> But I think
>> have the correct approach is required to avoid a double refactor.  I chose
>> to keep using the macros (__PTHREAD_COND_T_CONTENT and __PTHREAD_MUTEX_T_CONTENT)
>> because it is the most straightforward arrange, however maybe using a composed
>> struct with defines to access the direct member could be a better strategy.
>> Thoughts? 
> 
> AFAIR the differences between most of the pthread types, it mostly is a
> different alignment specifier here and there.  Things like sparc pre-v9
> and maybe hppa are exceptions, but the rest is pretty much the same
> everywhere.
> 
> Can we have just one definition of what's __PTHREAD_COND_T_CONTENT etc.
> now, and keep that in a file and include it everywhere (with additional
> modifier macros for things like the aligment specifiers, which would be
> defined in an arch-specific file)?  Or does that bring up the namespace
> problem you want to avoid?
> 

I think a pthread types cleanup is code refactor that should be done
independently of C11 thread support.  I will work on removing all the
redundant code from architectures.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-03-31 13:39             ` Adhemerval Zanella
@ 2017-04-06 11:05               ` Torvald Riegel
  2017-04-06 14:30                 ` Adhemerval Zanella
  0 siblings, 1 reply; 26+ messages in thread
From: Torvald Riegel @ 2017-04-06 11:05 UTC (permalink / raw)
  To: Adhemerval Zanella
  Cc: Martin Sebor, Joseph Myers, libc-alpha, Martin Sebor, Stefan Liebler

On Fri, 2017-03-31 at 10:39 -0300, Adhemerval Zanella wrote:
> 
> On 28/03/2017 05:08, Torvald Riegel wrote:
> > On Mon, 2017-03-27 at 10:10 -0600, Martin Sebor wrote:
> >> I've reviewed the DRs and your comments below.  I agree with
> >> your view and just for clarity provide some additional comments
> >> of my own.
> > 
> > Thanks!
> > 
> >> There's been a lot of talk over the last few WG14 meetings about
> >> the whole threads section needing an overhaul.  I don't know if
> >> anyone is actually working on it but if it were to happen (for
> >> C2X) there is some risk that an implementation coded to the C11
> >> spec not conforming to the cleaned up and improved C2X spec.
> > 
> > I'd hope that they wouldn't deviate from what C++ specifies.  I'm
> > monitoring C++ changes, including whether anything would result in
> > required changes for glibc.  IOW, if C doesn't deviate from C++, we
> > shouldn't need additional changes just for C.
> > 
> 
> Thanks for both extensive inputs and discussion.  From the comments I 
> see that a current C11 thread based on POSIX could be still be feasible,
> however I am not sure if we should prevent its implementation based on 
> the C2X possible different spec.
> 
> In any way, I see that the still pending DR493 should not pose any
> implementation issues (we can work out on the wrapper if any other
> requirement is posed).
> 
> So I would like the input from the community whether implementing C11
> in GLIBC is desirable and if current approach based is most correct
> one.

I think it is desirable, and it's probably about time that we have
something.  I'm not aware of anything that would be a huge problem.  C11
is in several cases much closer to what we implement than POSIX.

I still think it may have been nice to have smaller data structure sizes
for things like mutexes; however, we don't have consensus in the
community to shrink them, and we don't have the resources I believe to
really investigate this.

I haven't looked at the TLS issues, or at how you organize headers and
such.  I also haven't yet reviewed all of your patches.  But unless
somebody complains, IMHO we should just go forward with what you have.
Supporting the C11 threading support functions in the next release would
be nice.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3 0/6] Add support for ISO C11 threads.h
  2017-04-06 11:05               ` Torvald Riegel
@ 2017-04-06 14:30                 ` Adhemerval Zanella
  0 siblings, 0 replies; 26+ messages in thread
From: Adhemerval Zanella @ 2017-04-06 14:30 UTC (permalink / raw)
  To: Torvald Riegel
  Cc: Martin Sebor, Joseph Myers, libc-alpha, Martin Sebor, Stefan Liebler



On 06/04/2017 08:05, Torvald Riegel wrote:
> On Fri, 2017-03-31 at 10:39 -0300, Adhemerval Zanella wrote:
>>
>> On 28/03/2017 05:08, Torvald Riegel wrote:
>>> On Mon, 2017-03-27 at 10:10 -0600, Martin Sebor wrote:
>>>> I've reviewed the DRs and your comments below.  I agree with
>>>> your view and just for clarity provide some additional comments
>>>> of my own.
>>>
>>> Thanks!
>>>
>>>> There's been a lot of talk over the last few WG14 meetings about
>>>> the whole threads section needing an overhaul.  I don't know if
>>>> anyone is actually working on it but if it were to happen (for
>>>> C2X) there is some risk that an implementation coded to the C11
>>>> spec not conforming to the cleaned up and improved C2X spec.
>>>
>>> I'd hope that they wouldn't deviate from what C++ specifies.  I'm
>>> monitoring C++ changes, including whether anything would result in
>>> required changes for glibc.  IOW, if C doesn't deviate from C++, we
>>> shouldn't need additional changes just for C.
>>>
>>
>> Thanks for both extensive inputs and discussion.  From the comments I 
>> see that a current C11 thread based on POSIX could be still be feasible,
>> however I am not sure if we should prevent its implementation based on 
>> the C2X possible different spec.
>>
>> In any way, I see that the still pending DR493 should not pose any
>> implementation issues (we can work out on the wrapper if any other
>> requirement is posed).
>>
>> So I would like the input from the community whether implementing C11
>> in GLIBC is desirable and if current approach based is most correct
>> one.
> 
> I think it is desirable, and it's probably about time that we have
> something.  I'm not aware of anything that would be a huge problem.  C11
> is in several cases much closer to what we implement than POSIX.
> 
> I still think it may have been nice to have smaller data structure sizes
> for things like mutexes; however, we don't have consensus in the
> community to shrink them, and we don't have the resources I believe to
> really investigate this.

Indeed, however this would add some complication to use the POSIX internal
implementation directly.  We would need to create a common internal function
that would be called by POSIX and C11 wrappers, I will check this out in my
next rebase.

> 
> I haven't looked at the TLS issues, or at how you organize headers and
> such.  I also haven't yet reviewed all of your patches.  But unless
> somebody complains, IMHO we should just go forward with what you have.
> Supporting the C11 threading support functions in the next release would
> be nice.

Now with the removal of the ancient macro CALL_THREAD_FCT [1] and the
consolidation of pthreadtypes.h in a different patchset [2] [3], I will
rebase the changes and send a new patchset.  The consolidation of
pthreadtypes.h is mostly a mechanical change without expected code changes,
so I think it should be safer to push i

[1] https://sourceware.org/ml/libc-alpha/2017-04/msg00057.html
[2] https://sourceware.org/ml/libc-alpha/2017-04/msg00018.html
[3] https://sourceware.org/ml/libc-alpha/2017-04/msg00019.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2017-04-06 14:30 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-21 13:40 [PATCH v3 0/6] Add support for ISO C11 threads.h Adhemerval Zanella
2017-03-21 13:40 ` [PATCH 6/6] Add manual documentation for threads.h Adhemerval Zanella
2017-03-21 13:40 ` [PATCH 1/6] Consolidate pthreadtype.h placement Adhemerval Zanella
2017-03-21 13:48   ` Andreas Schwab
2017-03-21 15:07     ` Adhemerval Zanella
2017-03-21 13:40 ` [PATCH 4/6] Add C11 threads support Adhemerval Zanella
2017-03-21 13:40 ` [PATCH 3/6] Clean pthread functions namespaces for C11 threads Adhemerval Zanella
2017-03-21 13:40 ` [PATCH 2/6] Move mutex and condition variable definition to common header Adhemerval Zanella
2017-03-22 22:59   ` Ivo Raisr
2017-03-27 13:43   ` Torvald Riegel
2017-03-27 14:25     ` Adhemerval Zanella
2017-03-28  8:19       ` Torvald Riegel
2017-03-31 13:43         ` Adhemerval Zanella
2017-03-21 13:40 ` [PATCH 5/6] Add test cases for ISO C11 threads Adhemerval Zanella
2017-03-21 16:25 ` [PATCH v3 0/6] Add support for ISO C11 threads.h Joseph Myers
2017-03-21 16:44   ` Adhemerval Zanella
2017-03-21 16:49     ` Joseph Myers
2017-03-21 17:08       ` Adhemerval Zanella
2017-03-21 20:10       ` Adhemerval Zanella
2017-03-27 13:29         ` Torvald Riegel
2017-03-27 13:29       ` Torvald Riegel
2017-03-27 16:10         ` Martin Sebor
2017-03-28  8:08           ` Torvald Riegel
2017-03-31 13:39             ` Adhemerval Zanella
2017-04-06 11:05               ` Torvald Riegel
2017-04-06 14:30                 ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).