Remove second argument from TLS_INIT_TP macro
authorAndreas Schwab <schwab@suse.de>
Tue, 13 May 2014 14:40:41 +0000 (16:40 +0200)
committerAndreas Schwab <schwab@suse.de>
Tue, 27 May 2014 12:48:46 +0000 (14:48 +0200)
21 files changed:
ChangeLog
csu/libc-tls.c
elf/dl-load.c
elf/rtld.c
nptl/sysdeps/i386/tls.h
nptl/sysdeps/powerpc/tls.h
nptl/sysdeps/s390/tls.h
nptl/sysdeps/sh/tls.h
nptl/sysdeps/sparc/tls.h
nptl/sysdeps/x86_64/tls.h
sysdeps/aarch64/nptl/tls.h
sysdeps/alpha/nptl/tls.h
sysdeps/arm/nptl/tls.h
sysdeps/generic/tls.h
sysdeps/hppa/nptl/tls.h
sysdeps/ia64/nptl/tls.h
sysdeps/m68k/nptl/tls.h
sysdeps/mach/hurd/i386/tls.h
sysdeps/microblaze/nptl/tls.h
sysdeps/mips/nptl/tls.h
sysdeps/tile/nptl/tls.h

index 0396d3b..9d1ae9c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2014-05-27  Andreas Schwab  <schwab@suse.de>
+
+       * csu/libc-tls.c (__libc_setup_tls): Remove second argument from
+       TLS_INIT_TP macro.
+       * elf/dl-load.c (_dl_map_object_from_fd): Likewise.
+       * elf/rtld.c (init_tls, dl_main): Likewise.
+       * nptl/sysdeps/i386/tls.h (TLS_INIT_TP): Likewise.
+       * nptl/sysdeps/powerpc/tls.h (TLS_INIT_TP): Likewise.
+       * nptl/sysdeps/s390/tls.h (TLS_INIT_TP): Likewise.
+       * nptl/sysdeps/sh/tls.h (TLS_INIT_TP): Likewise.
+       * nptl/sysdeps/sparc/tls.h (TLS_INIT_TP): Likewise.
+       * nptl/sysdeps/x86_64/tls.h (TLS_INIT_TP): Likewise.
+       * sysdeps/aarch64/nptl/tls.h (TLS_INIT_TP): Likewise.
+       * sysdeps/alpha/nptl/tls.h (TLS_INIT_TP): Likewise.
+       * sysdeps/arm/nptl/tls.h (TLS_INIT_TP): Likewise.
+       * sysdeps/hppa/nptl/tls.h (TLS_INIT_TP): Likewise.
+       * sysdeps/ia64/nptl/tls.h (TLS_INIT_TP): Likewise.
+       * sysdeps/m68k/nptl/tls.h (TLS_INIT_TP): Likewise.
+       * sysdeps/mach/hurd/i386/tls.h (_hurd_tls_init): Likewise.
+       * sysdeps/microblaze/nptl/tls.h (TLS_INIT_TP): Likewise.
+       * sysdeps/mips/nptl/tls.h (TLS_INIT_TP): Likewise.
+       * sysdeps/tile/nptl/tls.h (TLS_INIT_TP): Likewise.
+       * sysdeps/generic/tls.h: Update description.
+
 2014-05-27  Will Newton  <will.newton@linaro.org>
 
        [BZ #16990]
index c18b888..dcb607c 100644 (file)
@@ -182,10 +182,10 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign)
 #if TLS_TCB_AT_TP
   INSTALL_DTV ((char *) tlsblock + tcb_offset, _dl_static_dtv);
 
-  const char *lossage = TLS_INIT_TP ((char *) tlsblock + tcb_offset, 0);
+  const char *lossage = TLS_INIT_TP ((char *) tlsblock + tcb_offset);
 #elif TLS_DTV_AT_TP
   INSTALL_DTV (tlsblock, _dl_static_dtv);
-  const char *lossage = TLS_INIT_TP (tlsblock, 0);
+  const char *lossage = TLS_INIT_TP (tlsblock);
 #else
 # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
 #endif
index cfa7f25..016a99c 100644 (file)
@@ -1176,7 +1176,7 @@ cannot allocate TLS data structures for initial thread");
                }
 
              /* Now we install the TCB in the thread register.  */
-             errstring = TLS_INIT_TP (tcb, 0);
+             errstring = TLS_INIT_TP (tcb);
              if (__glibc_likely (errstring == NULL))
                {
                  /* Now we are all good.  */
index 87c5ffa..71cc0db 100644 (file)
@@ -641,7 +641,7 @@ cannot allocate TLS data structures for initial thread");
   GL(dl_initial_dtv) = GET_DTV (tcbp);
 
   /* And finally install it for the main thread.  */
-  const char *lossage = TLS_INIT_TP (tcbp, 0);
+  const char *lossage = TLS_INIT_TP (tcbp);
   if (__glibc_unlikely (lossage != NULL))
     _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage);
   tls_init_tp_called = true;
@@ -2114,7 +2114,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
   /* And finally install it for the main thread.  */
   if (! tls_init_tp_called)
     {
-      const char *lossage = TLS_INIT_TP (tcbp, 0);
+      const char *lossage = TLS_INIT_TP (tcbp);
       if (__glibc_unlikely (lossage != NULL))
        _dl_fatal_printf ("cannot set up thread-local storage: %s\n",
                          lossage);
index 4183ee8..2f8d11d 100644 (file)
@@ -195,7 +195,7 @@ union user_desc_init
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(thrdescr, secondcall) \
+# define TLS_INIT_TP(thrdescr) \
   ({ void *_thrdescr = (thrdescr);                                           \
      tcbhead_t *_head = _thrdescr;                                           \
      union user_desc_init _segdescr;                                         \
@@ -208,10 +208,7 @@ union user_desc_init
      INIT_SYSINFO;                                                           \
                                                                              \
      /* The 'entry_number' field.  Let the kernel pick a value.  */          \
-     if (secondcall)                                                         \
-       _segdescr.vals[0] = TLS_GET_GS () >> 3;                               \
-     else                                                                    \
-       _segdescr.vals[0] = -1;                                               \
+     _segdescr.vals[0] = -1;                                                 \
      /* The 'base_addr' field.  Pointer to the TCB.  */                              \
      _segdescr.vals[1] = (unsigned long int) _thrdescr;                              \
      /* The 'limit' field.  We use 4GB which is 0xfffff pages.  */           \
index 556c8d5..91cc6f3 100644 (file)
@@ -129,7 +129,7 @@ register void *__thread_register __asm__ ("r13");
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(tcbp, secondcall) \
+# define TLS_INIT_TP(tcbp) \
     (__thread_register = (void *) (tcbp) + TLS_TCB_OFFSET, NULL)
 
 /* Return the address of the dtv for the current thread.  */
index 2019882..bb7c339 100644 (file)
@@ -119,7 +119,7 @@ typedef struct
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(thrdescr, secondcall) \
+# define TLS_INIT_TP(thrdescr) \
   ({ void *_thrdescr = (thrdescr);                                           \
      tcbhead_t *_head = _thrdescr;                                           \
                                                                              \
index 84e464c..a0660d2 100644 (file)
@@ -99,7 +99,7 @@ typedef struct
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(tcbp, secondcall) \
+# define TLS_INIT_TP(tcbp) \
   ({ __asm __volatile ("ldc %0,gbr" : : "r" (tcbp)); 0; })
 
 /* Return the address of the dtv for the current thread.  */
index 755bc23..4a1dce7 100644 (file)
@@ -107,7 +107,7 @@ register struct pthread *__thread_self __asm__("%g7");
   (((tcbhead_t *) (descr))->dtv)
 
 /* Code to initially initialize the thread pointer.  */
-# define TLS_INIT_TP(descr, secondcall) \
+# define TLS_INIT_TP(descr) \
   (__thread_self = (__typeof (__thread_self)) (descr), NULL)
 
 /* Return the address of the dtv for the current thread.  */
index 30bd449..fb671f4 100644 (file)
@@ -144,7 +144,7 @@ typedef struct
 
    We have to make the syscall for both uses of the macro since the
    address might be (and probably is) different.  */
-# define TLS_INIT_TP(thrdescr, secondcall) \
+# define TLS_INIT_TP(thrdescr) \
   ({ void *_thrdescr = (thrdescr);                                           \
      tcbhead_t *_head = _thrdescr;                                           \
      int _result;                                                            \
index 8b260a1..ef8f3af 100644 (file)
@@ -90,7 +90,7 @@ typedef struct
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(tcbp, secondcall) \
+# define TLS_INIT_TP(tcbp) \
   ({ __asm __volatile ("msr tpidr_el0, %0" : : "r" (tcbp)); NULL; })
 
 /* Return the address of the dtv for the current thread.  */
index b2e082d..fbc579a 100644 (file)
@@ -84,7 +84,7 @@ typedef struct
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(tcbp, secondcall) \
+# define TLS_INIT_TP(tcbp) \
   (__builtin_set_thread_pointer ((void *)(tcbp)), NULL)
 
 /* Return the address of the dtv for the current thread.  */
index 1a2d606..fc828d2 100644 (file)
@@ -91,7 +91,7 @@ typedef struct
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(tcbp, secondcall) \
+# define TLS_INIT_TP(tcbp) \
   ({ INTERNAL_SYSCALL_DECL (err);                                      \
      long result_var;                                                  \
      result_var = INTERNAL_SYSCALL_ARM (set_tls, err, 1, (tcbp));      \
index fb3d965..1c55f26 100644 (file)
      use the value.
 
 
-     TLS_INIT_TP(tcb, firstcall)
+     TLS_INIT_TP(tcb)
 
      This macro must initialize the thread pointer to enable normal TLS
-     operation.  The first parameter is a pointer to the thread control
-     block.  The second parameter specifies whether this is the first
-     call for the TCB.  ld.so calls this macro more than once.
+     operation.  The parameter is a pointer to the thread control block.
+     ld.so calls this macro once.
 
 
      THREAD_DTV()
index e4dc197..6c721e0 100644 (file)
@@ -95,7 +95,7 @@ typedef struct
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(tcbp, secondcall) \
+# define TLS_INIT_TP(tcbp) \
   ({ __set_cr27(tcbp); NULL; })
 
 /* Return the address of the dtv for the current thread.  */
index 3f9225a..3eca4e6 100644 (file)
@@ -118,7 +118,7 @@ register struct pthread *__thread_self __asm__("r13");
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(thrdescr, secondcall) \
+# define TLS_INIT_TP(thrdescr) \
   (__thread_self = (thrdescr), INIT_SYSINFO, NULL)
 
 /* Return the address of the dtv for the current thread.  */
index 471775a..c1df875 100644 (file)
@@ -103,7 +103,7 @@ typedef struct
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(tcbp, secondcall)                                 \
+# define TLS_INIT_TP(tcbp)                                             \
   ({                                                                   \
     INTERNAL_SYSCALL_DECL (err);                                       \
     int _sys_result;                                                   \
index 03741cd..5b7abd0 100644 (file)
@@ -90,69 +90,46 @@ typedef struct
 
 
 static inline const char * __attribute__ ((unused))
-_hurd_tls_init (tcbhead_t *tcb, int secondcall)
+_hurd_tls_init (tcbhead_t *tcb)
 {
   HURD_TLS_DESC_DECL (desc, tcb);
 
-  if (!secondcall)
+  /* This field is used by TLS accesses to get our "thread pointer"
+     from the TLS point of view.  */
+  tcb->tcb = tcb;
+
+  /* Cache our thread port.  */
+  tcb->self = __mach_thread_self ();
+
+  /* Get the first available selector.  */
+  int sel = -1;
+  error_t err = __i386_set_gdt (tcb->self, &sel, desc);
+  if (err == MIG_BAD_ID)
     {
-      /* This field is used by TLS accesses to get our "thread pointer"
-        from the TLS point of view.  */
-      tcb->tcb = tcb;
-
-      /* Cache our thread port.  */
-      tcb->self = __mach_thread_self ();
-
-      /* Get the first available selector.  */
-      int sel = -1;
-      error_t err = __i386_set_gdt (tcb->self, &sel, desc);
-      if (err == MIG_BAD_ID)
-       {
-         /* Old kernel, use a per-thread LDT.  */
-         sel = 0x27;
-         err = __i386_set_ldt (tcb->self, sel, &desc, 1);
-         assert_perror (err);
-         if (err)
-           return "i386_set_ldt failed";
-       }
-      else if (err)
-       {
-         assert_perror (err); /* Separate from above with different line #. */
-         return "i386_set_gdt failed";
-       }
-
-      /* Now install the new selector.  */
-      asm volatile ("mov %w0, %%gs" :: "q" (sel));
+      /* Old kernel, use a per-thread LDT.  */
+      sel = 0x27;
+      err = __i386_set_ldt (tcb->self, sel, &desc, 1);
+      assert_perror (err);
+      if (err)
+       return "i386_set_ldt failed";
     }
-  else
+  else if (err)
     {
-      /* Fetch the selector set by the first call.  */
-      int sel;
-      asm ("mov %%gs, %w0" : "=q" (sel) : "0" (0));
-      if (__builtin_expect (sel, 0x50) & 4) /* LDT selector */
-       {
-         error_t err = __i386_set_ldt (tcb->self, sel, &desc, 1);
-         assert_perror (err);
-         if (err)
-           return "i386_set_ldt failed";
-       }
-      else
-       {
-         error_t err = __i386_set_gdt (tcb->self, &sel, desc);
-         assert_perror (err);
-         if (err)
-           return "i386_set_gdt failed";
-       }
+      assert_perror (err); /* Separate from above with different line #. */
+      return "i386_set_gdt failed";
     }
 
+  /* Now install the new selector.  */
+  asm volatile ("mov %w0, %%gs" :: "q" (sel));
+
   return 0;
 }
 
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(descr, secondcall) \
-    _hurd_tls_init ((tcbhead_t *) (descr), (secondcall))
+# define TLS_INIT_TP(descr) \
+    _hurd_tls_init ((tcbhead_t *) (descr))
 
 /* Return the TCB address of the current thread.  */
 # define THREAD_SELF                                                         \
index 71f1dd9..e75a30c 100644 (file)
@@ -98,7 +98,7 @@ static inline void *__microblaze_get_thread_area (void)
 
 /* Code to initially initialize the thread pointer.
    r21 is reserved for thread pointer.  */
-# define TLS_INIT_TP(tcbp, secondcall) \
+# define TLS_INIT_TP(tcbp) \
   ({ __asm __volatile ("or r21,r0,%0" : : "r" ((void *)tcbp)); 0; })
 
 /* Return the address of the dtv for the current thread.  */
index 754d4e4..d6fd83d 100644 (file)
@@ -118,7 +118,7 @@ typedef struct
 /* Code to initially initialize the thread pointer.  This might need
    special attention since 'errno' is not yet available and if the
    operation can cause a failure 'errno' must not be touched.  */
-# define TLS_INIT_TP(tcbp, secondcall) \
+# define TLS_INIT_TP(tcbp) \
   ({ INTERNAL_SYSCALL_DECL (err);                                      \
      long result_var;                                                  \
      result_var = INTERNAL_SYSCALL (set_thread_area, err, 1,           \
index 2a9bbc1..c93e8a8 100644 (file)
@@ -106,7 +106,7 @@ register void *__thread_pointer asm ("tp");
 # define GET_DTV(tcbp) (((tcbhead_t *) (tcbp))[-1].dtv)
 
 /* Code to initially initialize the thread pointer (tp).  */
-# define TLS_INIT_TP(tcbp, secondcall) \
+# define TLS_INIT_TP(tcbp) \
     (__thread_pointer = (char *)(tcbp) + TLS_TCB_OFFSET, NULL)
 
 /* Return the address of the dtv for the current thread.  */