[2/6] Move mutex and condition variable definition to common header

Message ID 1490103612-9401-3-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show
Series
  • Add support for ISO C11 threads.h
Related show

Commit Message

Adhemerval Zanella March 21, 2017, 1:40 p.m.
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

-- 
2.7.4

Comments

Ivo Raisr March 22, 2017, 10:59 p.m. | #1
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
Torvald Riegel March 27, 2017, 1:43 p.m. | #2
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.
Adhemerval Zanella March 27, 2017, 2:24 p.m. | #3
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?
Torvald Riegel March 28, 2017, 8:19 a.m. | #4
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?
Adhemerval Zanella March 31, 2017, 1:43 p.m. | #5
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.

Patch

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