93dc2d
commit 627f5ede70d70c77bdaf857db07404e8bf7f60af
93dc2d
Author: Florian Weimer <fweimer@redhat.com>
93dc2d
Date:   Thu Dec 9 17:57:11 2021 +0100
93dc2d
93dc2d
    Remove TLS_TCB_ALIGN and TLS_INIT_TCB_ALIGN
93dc2d
    
93dc2d
    TLS_INIT_TCB_ALIGN is not actually used.  TLS_TCB_ALIGN was likely
93dc2d
    introduced to support a configuration where the thread pointer
93dc2d
    has not the same alignment as THREAD_SELF.  Only ia64 seems to use
93dc2d
    that, but for the stack/pointer guard, not for storing tcbhead_t.
93dc2d
    Some ports use TLS_TCB_OFFSET and TLS_PRE_TCB_SIZE to shift
93dc2d
    the thread pointer, potentially landing in a different residue class
93dc2d
    modulo the alignment, but the changes should not impact that.
93dc2d
    
93dc2d
    In general, given that TLS variables have their own alignment
93dc2d
    requirements, having different alignment for the (unshifted) thread
93dc2d
    pointer and struct pthread would potentially result in dynamic
93dc2d
    offsets, leading to more complexity.
93dc2d
    
93dc2d
    hppa had different values before: __alignof__ (tcbhead_t), which
93dc2d
    seems to be 4, and __alignof__ (struct pthread), which was 8
93dc2d
    (old default) and is now 32.  However, it defines THREAD_SELF as:
93dc2d
    
93dc2d
    /* Return the thread descriptor for the current thread.  */
93dc2d
    # define THREAD_SELF \
93dc2d
      ({ struct pthread *__self;                    \
93dc2d
            __self = __get_cr27();                  \
93dc2d
            __self - 1;                             \
93dc2d
       })
93dc2d
    
93dc2d
    So the thread pointer points after struct pthread (hence __self - 1),
93dc2d
    and they have to have the same alignment on hppa as well.
93dc2d
    
93dc2d
    Similarly, on ia64, the definitions were different.  We have:
93dc2d
    
93dc2d
    # define TLS_PRE_TCB_SIZE \
93dc2d
      (sizeof (struct pthread)                                              \
93dc2d
       + (PTHREAD_STRUCT_END_PADDING < 2 * sizeof (uintptr_t)               \
93dc2d
          ? ((2 * sizeof (uintptr_t) + __alignof__ (struct pthread) - 1)    \
93dc2d
             & ~(__alignof__ (struct pthread) - 1))                         \
93dc2d
          : 0))
93dc2d
    # define THREAD_SELF \
93dc2d
      ((struct pthread *) ((char *) __thread_self - TLS_PRE_TCB_SIZE))
93dc2d
    
93dc2d
    And TLS_PRE_TCB_SIZE is a multiple of the struct pthread alignment
93dc2d
    (confirmed by the new _Static_assert in sysdeps/ia64/libc-tls.c).
93dc2d
    
93dc2d
    On m68k, we have a larger gap between tcbhead_t and struct pthread.
93dc2d
    But as far as I can tell, the port is fine with that.  The definition
93dc2d
    of TCB_OFFSET is sufficient to handle the shifted TCB scenario.
93dc2d
    
93dc2d
    This fixes commit 23c77f60181eb549f11ec2f913b4270af29eee38
93dc2d
    ("nptl: Increase default TCB alignment to 32").
93dc2d
    
93dc2d
    Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
93dc2d
93dc2d
diff --git a/csu/libc-tls.c b/csu/libc-tls.c
93dc2d
index 5515204863218163..d83e69f6257ae981 100644
93dc2d
--- a/csu/libc-tls.c
93dc2d
+++ b/csu/libc-tls.c
93dc2d
@@ -24,6 +24,7 @@
93dc2d
 #include <stdio.h>
93dc2d
 #include <sys/param.h>
93dc2d
 #include <array_length.h>
93dc2d
+#include <pthreadP.h>
93dc2d
 
93dc2d
 #ifdef SHARED
93dc2d
  #error makefile bug, this file is for static only
93dc2d
@@ -89,7 +90,7 @@ init_static_tls (size_t memsz, size_t align)
93dc2d
 {
93dc2d
   /* That is the size of the TLS memory for this object.  */
93dc2d
   GL(dl_tls_static_size) = roundup (memsz + GLRO(dl_tls_static_surplus),
93dc2d
-				    TLS_TCB_ALIGN);
93dc2d
+				    TCB_ALIGNMENT);
93dc2d
 #if TLS_TCB_AT_TP
93dc2d
   GL(dl_tls_static_size) += TLS_TCB_SIZE;
93dc2d
 #endif
93dc2d
@@ -214,5 +215,5 @@ __libc_setup_tls (void)
93dc2d
   memsz += tcb_offset;
93dc2d
 #endif
93dc2d
 
93dc2d
-  init_static_tls (memsz, MAX (TLS_TCB_ALIGN, max_align));
93dc2d
+  init_static_tls (memsz, MAX (TCB_ALIGNMENT, max_align));
93dc2d
 }
93dc2d
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
93dc2d
index 40263cf586e74c64..e2012d0cd515103b 100644
93dc2d
--- a/elf/dl-tls.c
93dc2d
+++ b/elf/dl-tls.c
93dc2d
@@ -219,7 +219,7 @@ _dl_count_modids (void)
93dc2d
 void
93dc2d
 _dl_determine_tlsoffset (void)
93dc2d
 {
93dc2d
-  size_t max_align = TLS_TCB_ALIGN;
93dc2d
+  size_t max_align = TCB_ALIGNMENT;
93dc2d
   size_t freetop = 0;
93dc2d
   size_t freebottom = 0;
93dc2d
 
93dc2d
@@ -350,7 +350,7 @@ _dl_determine_tlsoffset (void)
93dc2d
 
93dc2d
   GL(dl_tls_static_used) = offset;
93dc2d
   GLRO (dl_tls_static_size) = roundup (offset + GLRO(dl_tls_static_surplus),
93dc2d
-				       TLS_TCB_ALIGN);
93dc2d
+				       TCB_ALIGNMENT);
93dc2d
 #else
93dc2d
 # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
93dc2d
 #endif
93dc2d
diff --git a/sysdeps/aarch64/nptl/tls.h b/sysdeps/aarch64/nptl/tls.h
93dc2d
index cd9abb5d1d073593..75c469d51b532a89 100644
93dc2d
--- a/sysdeps/aarch64/nptl/tls.h
93dc2d
+++ b/sysdeps/aarch64/nptl/tls.h
93dc2d
@@ -52,18 +52,12 @@ typedef struct
93dc2d
 /* This is the size of the initial TCB.  */
93dc2d
 # define TLS_INIT_TCB_SIZE	sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN	__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE		sizeof (tcbhead_t)
93dc2d
 
93dc2d
 /* This is the size we need before TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE	sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN		__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* Install the dtv pointer.  The pointer passed is to the element with
93dc2d
    index -1 which contain the length.  */
93dc2d
 # define INSTALL_DTV(tcbp, dtvp) \
93dc2d
diff --git a/sysdeps/alpha/nptl/tls.h b/sysdeps/alpha/nptl/tls.h
93dc2d
index 5f4843b28e7f1ad1..c0b6c93891546480 100644
93dc2d
--- a/sysdeps/alpha/nptl/tls.h
93dc2d
+++ b/sysdeps/alpha/nptl/tls.h
93dc2d
@@ -46,18 +46,12 @@ typedef struct
93dc2d
 /* This is the size of the initial TCB.  */
93dc2d
 # define TLS_INIT_TCB_SIZE	sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN	16
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE		sizeof (tcbhead_t)
93dc2d
 
93dc2d
 /* This is the size we need before TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE	sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN		16
93dc2d
-
93dc2d
 /* Install the dtv pointer.  The pointer passed is to the element with
93dc2d
    index -1 which contain the length.  */
93dc2d
 # define INSTALL_DTV(tcbp, dtvp) \
93dc2d
diff --git a/sysdeps/arc/nptl/tls.h b/sysdeps/arc/nptl/tls.h
93dc2d
index d9ada2f38089e6cd..d5d282297d12ec98 100644
93dc2d
--- a/sysdeps/arc/nptl/tls.h
93dc2d
+++ b/sysdeps/arc/nptl/tls.h
93dc2d
@@ -48,17 +48,11 @@ typedef struct
93dc2d
 /* This is the size of the initial TCB.  */
93dc2d
 # define TLS_INIT_TCB_SIZE	sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN	__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 #ifndef TLS_TCB_SIZE
93dc2d
 # define TLS_TCB_SIZE		sizeof (tcbhead_t)
93dc2d
 #endif
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN		__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size we need before TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE	sizeof (struct pthread)
93dc2d
 
93dc2d
diff --git a/sysdeps/arm/nptl/tls.h b/sysdeps/arm/nptl/tls.h
93dc2d
index 354aae3318291395..8475c66588f99cae 100644
93dc2d
--- a/sysdeps/arm/nptl/tls.h
93dc2d
+++ b/sysdeps/arm/nptl/tls.h
93dc2d
@@ -50,18 +50,12 @@ typedef struct
93dc2d
 /* This is the size of the initial TCB.  */
93dc2d
 # define TLS_INIT_TCB_SIZE	sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN	16
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE		sizeof (tcbhead_t)
93dc2d
 
93dc2d
 /* This is the size we need before TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE	sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN		16
93dc2d
-
93dc2d
 /* Install the dtv pointer.  The pointer passed is to the element with
93dc2d
    index -1 which contain the length.  */
93dc2d
 # define INSTALL_DTV(tcbp, dtvp) \
93dc2d
diff --git a/sysdeps/csky/nptl/tls.h b/sysdeps/csky/nptl/tls.h
93dc2d
index f3fa3fcb02748776..e81d4552d27e0378 100644
93dc2d
--- a/sysdeps/csky/nptl/tls.h
93dc2d
+++ b/sysdeps/csky/nptl/tls.h
93dc2d
@@ -61,15 +61,9 @@ typedef struct
93dc2d
 /* This is the size of the initial TCB.  */
93dc2d
 # define TLS_INIT_TCB_SIZE	sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN	8
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE		sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN		8
93dc2d
-
93dc2d
 /* This is the size we need before TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE	sizeof (struct pthread)
93dc2d
 
93dc2d
diff --git a/sysdeps/generic/tls.h b/sysdeps/generic/tls.h
93dc2d
index e86d70e6cebba5c8..9214ed39b6383e8c 100644
93dc2d
--- a/sysdeps/generic/tls.h
93dc2d
+++ b/sysdeps/generic/tls.h
93dc2d
@@ -19,6 +19,11 @@
93dc2d
 /* An architecture-specific version of this file has to defined a
93dc2d
    number of symbols:
93dc2d
 
93dc2d
+     TCB_ALIGNMENT
93dc2d
+
93dc2d
+     Alignment of THREAD_SELF (struct pthread *) and the thread
93dc2d
+     pointer.
93dc2d
+
93dc2d
      TLS_TCB_AT_TP  or  TLS_DTV_AT_TP
93dc2d
 
93dc2d
      The presence of one of these symbols signals which variant of
93dc2d
@@ -43,15 +48,6 @@
93dc2d
      dynamic linker itself.  There are no threads in use at that time.
93dc2d
 
93dc2d
 
93dc2d
-     TLS_TCB_ALIGN
93dc2d
-
93dc2d
-     Alignment requirements for the TCB structure.
93dc2d
-
93dc2d
-     TLS_INIT_TCB_ALIGN
93dc2d
-
93dc2d
-     Similarly, but for the structure used at startup time.
93dc2d
-
93dc2d
-
93dc2d
      INSTALL_DTV(tcb, init_dtv)
93dc2d
 
93dc2d
      This macro must install the given initial DTV into the thread control
93dc2d
diff --git a/sysdeps/hppa/nptl/tls.h b/sysdeps/hppa/nptl/tls.h
93dc2d
index f0e274c45fb5e91e..88a6b902c0b7e2fd 100644
93dc2d
--- a/sysdeps/hppa/nptl/tls.h
93dc2d
+++ b/sysdeps/hppa/nptl/tls.h
93dc2d
@@ -52,15 +52,9 @@ typedef struct
93dc2d
 /* This is the size of the initial TCB.  */
93dc2d
 # define TLS_INIT_TCB_SIZE	sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN	__alignof__ (tcbhead_t)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE		sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN		__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size we need before TCB */
93dc2d
 # define TLS_PRE_TCB_SIZE	sizeof (struct pthread)
93dc2d
 
93dc2d
diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
93dc2d
index 111c9ee59df30bc3..06ab9784a5358b0b 100644
93dc2d
--- a/sysdeps/i386/nptl/tls.h
93dc2d
+++ b/sysdeps/i386/nptl/tls.h
93dc2d
@@ -102,15 +102,9 @@ union user_desc_init
93dc2d
    struct pthread even when not linked with -lpthread.  */
93dc2d
 # define TLS_INIT_TCB_SIZE sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN __alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* The TCB can have any size and the memory following the address the
93dc2d
    thread pointer points to is unspecified.  Allocate the TCB there.  */
93dc2d
 # define TLS_TCB_AT_TP	1
93dc2d
diff --git a/sysdeps/ia64/libc-tls.c b/sysdeps/ia64/libc-tls.c
93dc2d
index a01edceab36d375e..ede1e8f463b135b4 100644
93dc2d
--- a/sysdeps/ia64/libc-tls.c
93dc2d
+++ b/sysdeps/ia64/libc-tls.c
93dc2d
@@ -18,6 +18,9 @@
93dc2d
 
93dc2d
 #include <csu/libc-tls.c>
93dc2d
 
93dc2d
+_Static_assert (TLS_PRE_TCB_SIZE % __alignof (struct pthread) == 0,
93dc2d
+		"__thread_self and THREAD_SELF have same alignment");
93dc2d
+
93dc2d
 /* On IA-64, as it lacks linker optimizations, __tls_get_addr can be
93dc2d
    called even in statically linked binaries.
93dc2d
    In this case module must be always 1 and PT_TLS segment
93dc2d
diff --git a/sysdeps/ia64/nptl/tls.h b/sysdeps/ia64/nptl/tls.h
93dc2d
index 26fe555cb4b5e164..ca8f1280aeeed3d5 100644
93dc2d
--- a/sysdeps/ia64/nptl/tls.h
93dc2d
+++ b/sysdeps/ia64/nptl/tls.h
93dc2d
@@ -53,9 +53,6 @@ register struct pthread *__thread_self __asm__("r13");
93dc2d
 /* This is the size of the initial TCB.  */
93dc2d
 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE sizeof (tcbhead_t)
93dc2d
 
93dc2d
@@ -70,9 +67,6 @@ register struct pthread *__thread_self __asm__("r13");
93dc2d
 	 & ~(__alignof__ (struct pthread) - 1))				\
93dc2d
       : 0))
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN __alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* The DTV is allocated at the TP; the TCB is placed elsewhere.  */
93dc2d
 # define TLS_DTV_AT_TP	1
93dc2d
 # define TLS_TCB_AT_TP	0
93dc2d
diff --git a/sysdeps/m68k/nptl/tls.h b/sysdeps/m68k/nptl/tls.h
93dc2d
index 9f562c38288df200..b88ef0c9c74ae0b0 100644
93dc2d
--- a/sysdeps/m68k/nptl/tls.h
93dc2d
+++ b/sysdeps/m68k/nptl/tls.h
93dc2d
@@ -54,20 +54,15 @@ typedef struct
93dc2d
    pointer, we don't need this.  */
93dc2d
 # define TLS_INIT_TCB_SIZE	0
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN	__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  Because our TCB is before the thread
93dc2d
    pointer, we don't need this.  */
93dc2d
 # define TLS_TCB_SIZE		0
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN		__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size we need before TCB - actually, it includes the TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE						\
93dc2d
   (sizeof (struct pthread)						\
93dc2d
-   + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
93dc2d
+   + ((sizeof (tcbhead_t) + __alignof (struct pthread) - 1)		\
93dc2d
+      & ~(__alignof (struct pthread) - 1)))
93dc2d
 
93dc2d
 /* The thread pointer (TP) points to the end of the
93dc2d
    TCB + 0x7000, as for PowerPC and MIPS.  This implies that TCB address is
93dc2d
diff --git a/sysdeps/mach/hurd/tls.h b/sysdeps/mach/hurd/tls.h
93dc2d
index f83956d3d7ca4f9f..773a2a0c36d5d57d 100644
93dc2d
--- a/sysdeps/mach/hurd/tls.h
93dc2d
+++ b/sysdeps/mach/hurd/tls.h
93dc2d
@@ -29,20 +29,12 @@
93dc2d
 # include <mach.h>
93dc2d
 # include <atomic.h>
93dc2d
 
93dc2d
-
93dc2d
 /* This is the size of the initial TCB.  */
93dc2d
 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE TLS_INIT_TCB_SIZE	/* XXX */
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN TLS_INIT_TCB_ALIGN /* XXX */
93dc2d
-
93dc2d
-
93dc2d
 /* Install the dtv pointer.  The pointer passed is to the element with
93dc2d
    index -1 which contain the length.  */
93dc2d
 # define INSTALL_DTV(descr, dtvp) \
93dc2d
diff --git a/sysdeps/microblaze/nptl/tls.h b/sysdeps/microblaze/nptl/tls.h
93dc2d
index bfa6efa78049bb2d..b69d7b4f28f3b757 100644
93dc2d
--- a/sysdeps/microblaze/nptl/tls.h
93dc2d
+++ b/sysdeps/microblaze/nptl/tls.h
93dc2d
@@ -56,18 +56,12 @@ typedef struct
93dc2d
 /* This is the size of the initial TCB.  */
93dc2d
 # define TLS_INIT_TCB_SIZE  sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE       sizeof (tcbhead_t)
93dc2d
 
93dc2d
 /* This is the size we need before TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE   sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN      __alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* Install the dtv pointer.  The pointer passed is to the element with
93dc2d
    index -1 which contain the length.  */
93dc2d
 # define INSTALL_DTV(tcbp, dtvp) \
93dc2d
diff --git a/sysdeps/mips/nptl/tls.h b/sysdeps/mips/nptl/tls.h
93dc2d
index ef99aa646c898e76..6ccaf9804a68634a 100644
93dc2d
--- a/sysdeps/mips/nptl/tls.h
93dc2d
+++ b/sysdeps/mips/nptl/tls.h
93dc2d
@@ -83,20 +83,15 @@ typedef struct
93dc2d
    pointer, we don't need this.  */
93dc2d
 # define TLS_INIT_TCB_SIZE	0
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN	__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  Because our TCB is before the thread
93dc2d
    pointer, we don't need this.  */
93dc2d
 # define TLS_TCB_SIZE		0
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN		__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size we need before TCB - actually, it includes the TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE \
93dc2d
   (sizeof (struct pthread)						      \
93dc2d
-   + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
93dc2d
+   + ((sizeof (tcbhead_t) + __alignof (struct pthread) - 1)		      \
93dc2d
+      & ~(__alignof (struct pthread) - 1)))
93dc2d
 
93dc2d
 /* The thread pointer (in hardware register $29) points to the end of
93dc2d
    the TCB + 0x7000, as for PowerPC.  The pthread_descr structure is
93dc2d
diff --git a/sysdeps/nios2/nptl/tls.h b/sysdeps/nios2/nptl/tls.h
93dc2d
index 7110cfccad7131f4..6ab6bd27b00a70ee 100644
93dc2d
--- a/sysdeps/nios2/nptl/tls.h
93dc2d
+++ b/sysdeps/nios2/nptl/tls.h
93dc2d
@@ -59,20 +59,15 @@ register struct pthread *__thread_self __asm__("r23");
93dc2d
    pointer, we don't need this.  */
93dc2d
 # define TLS_INIT_TCB_SIZE	0
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN	__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  Because our TCB is before the thread
93dc2d
    pointer, we don't need this.  */
93dc2d
 # define TLS_TCB_SIZE		0
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN		__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size we need before TCB - actually, it includes the TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE \
93dc2d
   (sizeof (struct pthread)						      \
93dc2d
-   + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
93dc2d
+   + ((sizeof (tcbhead_t) + __alignof (struct pthread) - 1)		      \
93dc2d
+      & ~(__alignof (struct pthread) - 1)))
93dc2d
 
93dc2d
 /* The thread pointer (in hardware register r23) points to the end of
93dc2d
    the TCB + 0x7000, as for PowerPC and MIPS.  */
93dc2d
diff --git a/sysdeps/powerpc/nptl/tls.h b/sysdeps/powerpc/nptl/tls.h
93dc2d
index 110d085d30c86302..e194b334216eaa02 100644
93dc2d
--- a/sysdeps/powerpc/nptl/tls.h
93dc2d
+++ b/sysdeps/powerpc/nptl/tls.h
93dc2d
@@ -108,19 +108,14 @@ typedef struct
93dc2d
 /* This is the size of the initial TCB.  */
93dc2d
 # define TLS_INIT_TCB_SIZE	0
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN	__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE		0
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN		__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size we need before TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE \
93dc2d
   (sizeof (struct pthread)						      \
93dc2d
-   + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
93dc2d
+   + ((sizeof (tcbhead_t) + __alignof (struct pthread) - 1)		      \
93dc2d
+      & ~(__alignof (struct pthread) - 1)))
93dc2d
 
93dc2d
 /* The following assumes that TP (R2 or R13) points to the end of the
93dc2d
    TCB + 0x7000 (per the ABI).  This implies that TCB address is
93dc2d
diff --git a/sysdeps/riscv/nptl/tls.h b/sysdeps/riscv/nptl/tls.h
93dc2d
index bdc0a3a6f91b51e8..8c12d8f971adeddb 100644
93dc2d
--- a/sysdeps/riscv/nptl/tls.h
93dc2d
+++ b/sysdeps/riscv/nptl/tls.h
93dc2d
@@ -50,20 +50,15 @@ typedef struct
93dc2d
    pointer, we don't need this.  */
93dc2d
 # define TLS_INIT_TCB_SIZE	0
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN	__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  Because our TCB is before the thread
93dc2d
    pointer, we don't need this.  */
93dc2d
 # define TLS_TCB_SIZE		0
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN		__alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size we need before TCB - actually, it includes the TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE \
93dc2d
   (sizeof (struct pthread)						      \
93dc2d
-   + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1)))
93dc2d
+   + ((sizeof (tcbhead_t) + __alignof (struct pthread) - 1)		      \
93dc2d
+      & ~(__alignof (struct pthread) - 1)))
93dc2d
 
93dc2d
 /* The thread pointer tp points to the end of the TCB.
93dc2d
    The pthread_descr structure is immediately in front of the TCB.  */
93dc2d
diff --git a/sysdeps/s390/nptl/tls.h b/sysdeps/s390/nptl/tls.h
93dc2d
index 2cdd18eb2907c060..3b4c0ab32a9439a3 100644
93dc2d
--- a/sysdeps/s390/nptl/tls.h
93dc2d
+++ b/sysdeps/s390/nptl/tls.h
93dc2d
@@ -66,15 +66,9 @@ typedef struct
93dc2d
    struct pthread even when not linked with -lpthread.  */
93dc2d
 # define TLS_INIT_TCB_SIZE sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN __alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* The TCB can have any size and the memory following the address the
93dc2d
    thread pointer points to is unspecified.  Allocate the TCB there.  */
93dc2d
 # define TLS_TCB_AT_TP	1
93dc2d
diff --git a/sysdeps/sh/nptl/tls.h b/sysdeps/sh/nptl/tls.h
93dc2d
index 390640020e45f716..3e4d480b35951253 100644
93dc2d
--- a/sysdeps/sh/nptl/tls.h
93dc2d
+++ b/sysdeps/sh/nptl/tls.h
93dc2d
@@ -51,18 +51,12 @@ typedef struct
93dc2d
 /* This is the size of the initial TCB.  */
93dc2d
 # define TLS_INIT_TCB_SIZE sizeof (tcbhead_t)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE sizeof (tcbhead_t)
93dc2d
 
93dc2d
 /* This is the size we need before TCB.  */
93dc2d
 # define TLS_PRE_TCB_SIZE sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN __alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* The TLS blocks start right after the TCB.  */
93dc2d
 # define TLS_DTV_AT_TP	1
93dc2d
 # define TLS_TCB_AT_TP	0
93dc2d
diff --git a/sysdeps/sparc/nptl/tls.h b/sysdeps/sparc/nptl/tls.h
93dc2d
index 376d729989e35660..3fb4ce6e6dacf28c 100644
93dc2d
--- a/sysdeps/sparc/nptl/tls.h
93dc2d
+++ b/sysdeps/sparc/nptl/tls.h
93dc2d
@@ -63,15 +63,9 @@ register struct pthread *__thread_self __asm__("%g7");
93dc2d
    struct pthread even when not linked with -lpthread.  */
93dc2d
 # define TLS_INIT_TCB_SIZE sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN __alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* The TCB can have any size and the memory following the address the
93dc2d
    thread pointer points to is unspecified.  Allocate the TCB there.  */
93dc2d
 # define TLS_TCB_AT_TP	1
93dc2d
diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
93dc2d
index 3af1836e28b26fdb..50f7e8b544f9e6fc 100644
93dc2d
--- a/sysdeps/x86_64/nptl/tls.h
93dc2d
+++ b/sysdeps/x86_64/nptl/tls.h
93dc2d
@@ -106,15 +106,9 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
93dc2d
    struct pthread even when not linked with -lpthread.  */
93dc2d
 # define TLS_INIT_TCB_SIZE sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the initial TCB.  */
93dc2d
-# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* This is the size of the TCB.  */
93dc2d
 # define TLS_TCB_SIZE sizeof (struct pthread)
93dc2d
 
93dc2d
-/* Alignment requirements for the TCB.  */
93dc2d
-# define TLS_TCB_ALIGN __alignof__ (struct pthread)
93dc2d
-
93dc2d
 /* The TCB can have any size and the memory following the address the
93dc2d
    thread pointer points to is unspecified.  Allocate the TCB there.  */
93dc2d
 # define TLS_TCB_AT_TP	1