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