]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: Export __libc_multiple_threads from libc as an internal symbol
authorFlorian Weimer <fweimer@redhat.com>
Mon, 10 May 2021 08:31:41 +0000 (10:31 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 10 May 2021 08:31:41 +0000 (10:31 +0200)
This allows the elimination of the __libc_multiple_threads_ptr
variable in libpthread and its initialization procedure.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
nptl/Versions
nptl/allocatestack.c
nptl/libc_multiple_threads.c
nptl/libc_pthread_init.c
nptl/nptl-init.c
nptl/pthreadP.h
nptl/pthread_cancel.c
sysdeps/unix/sysv/linux/single-thread.h

index f950b77969667da3f641eed3959d8b37ca7c575c..fb15a7e8eb12120a1371eb44806fdce5282fbdfe 100644 (file)
@@ -305,6 +305,7 @@ libc {
     __libc_cleanup_pop_restore;
     __libc_cleanup_push_defer;
     __libc_dl_error_tsd;
+    __libc_multiple_threads;
     __libc_pthread_init;
     __lll_clocklock_elision;
     __lll_lock_elision;
index 8aaba088b1c0dd298be77e0b892ad9b6b9e78997..059786192e22920a19ecf1ec832470d187768328 100644 (file)
@@ -477,7 +477,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
       /* This is at least the second thread.  */
       pd->header.multiple_threads = 1;
 #ifndef TLS_MULTIPLE_THREADS_IN_TCB
-      __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
+      __pthread_multiple_threads = __libc_multiple_threads = 1;
 #endif
 
 #ifdef NEED_DL_SYSINFO
@@ -598,7 +598,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
          /* This is at least the second thread.  */
          pd->header.multiple_threads = 1;
 #ifndef TLS_MULTIPLE_THREADS_IN_TCB
-         __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
+         __pthread_multiple_threads = __libc_multiple_threads = 1;
 #endif
 
 #ifdef NEED_DL_SYSINFO
index 60328023cd3ef94cbd10ef98a3159d56e6122a58..a0e7932c26e81b2c57d54c25210db7f3f622cdf5 100644 (file)
@@ -23,6 +23,7 @@
 /* Variable set to a nonzero value either if more than one thread runs or ran,
    or if a single-threaded process is trying to cancel itself.  See
    nptl/descr.h for more context on the single-threaded process case.  */
-int __libc_multiple_threads attribute_hidden;
+int __libc_multiple_threads __attribute__ ((nocommon));
+libc_hidden_data_def (__libc_multiple_threads)
 # endif
 #endif
index 397b83beb65546ac95ec128f36356241593e1412..75f5d28ed6976b276e364c8b66fd1dc1ffa66b41 100644 (file)
 #include <sysdep.h>
 #include <ldsodefs.h>
 
-
-#ifdef TLS_MULTIPLE_THREADS_IN_TCB
 void
-#else
-extern int __libc_multiple_threads attribute_hidden;
-
-int *
-#endif
 __libc_pthread_init (void (*reclaim) (void))
 {
   /* Called by a child after fork.  */
   __register_atfork (NULL, NULL, reclaim, NULL);
-
-#ifndef TLS_MULTIPLE_THREADS_IN_TCB
-  return &__libc_multiple_threads;
-#endif
 }
index 2724770533ae692c46554363df458f088630ac82..2fb1117f3eb80a57bd2a77e6fa5763af50c61fe9 100644 (file)
 #include <libc-pointer-arith.h>
 #include <pthread_mutex_conf.h>
 
-#ifndef TLS_MULTIPLE_THREADS_IN_TCB
-/* Pointer to the corresponding variable in libc.  */
-int *__libc_multiple_threads_ptr attribute_hidden;
-#endif
-
 /* Size and alignment of static TLS block.  */
 size_t __static_tls_size;
 size_t __static_tls_align_m1;
@@ -183,10 +178,7 @@ __pthread_initialize_minimal_internal (void)
 #endif
 
   /* Register the fork generation counter with the libc.  */
-#ifndef TLS_MULTIPLE_THREADS_IN_TCB
-  __libc_multiple_threads_ptr =
-#endif
-    __libc_pthread_init (__reclaim_stacks);
+  __libc_pthread_init (__reclaim_stacks);
 }
 strong_alias (__pthread_initialize_minimal_internal,
              __pthread_initialize_minimal)
index 6b52ca158e1de4c03715de697e43854ed5fc9b01..dd6d6c6342da875e4f4689013d015559fdf7e346 100644 (file)
@@ -368,17 +368,13 @@ extern unsigned long int __fork_generation attribute_hidden;
 extern unsigned long int *__fork_generation_pointer attribute_hidden;
 
 /* Register the generation counter in the libpthread with the libc.  */
-#ifdef TLS_MULTIPLE_THREADS_IN_TCB
 extern void __libc_pthread_init (void (*reclaim) (void));
-#else
-extern int *__libc_pthread_init (void (*reclaim) (void));
 
+#ifndef TLS_MULTIPLE_THREADS_IN_TCB
 /* Variable set to a nonzero value either if more than one thread runs or ran,
    or if a single-threaded process is trying to cancel itself.  See
    nptl/descr.h for more context on the single-threaded process case.  */
 extern int __pthread_multiple_threads attribute_hidden;
-/* Pointer to the corresponding variable in libc.  */
-extern int *__libc_multiple_threads_ptr attribute_hidden;
 #endif
 
 extern size_t __pthread_get_minstack (const pthread_attr_t *attr);
index 060484cdc8919e7306d3bbff0da5cd83c2c29583..2cab8f0a34d3790b491a551d89e8b753db1d7ffe 100644 (file)
@@ -90,7 +90,7 @@ __pthread_cancel (pthread_t th)
           points get executed.  */
        THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1);
 #ifndef TLS_MULTIPLE_THREADS_IN_TCB
-       __pthread_multiple_threads = *__libc_multiple_threads_ptr = 1;
+       __pthread_multiple_threads = __libc_multiple_threads = 1;
 #endif
     }
   /* Mark the thread as canceled.  This has to be done
index a28aaed04dfc9bd0cb01be42074892bc1bcf9971..841f8c69d58a33de519faa1819311d2d4a5db1c1 100644 (file)
    The ABI might define SINGLE_THREAD_BY_GLOBAL to enable the single thread
    check to use global variables instead of the pthread_t field.  */
 
+#ifndef __ASSEMBLER__
+extern int __libc_multiple_threads;
+libc_hidden_proto (__libc_multiple_threads)
+#endif
+
 #ifdef SINGLE_THREAD_BY_GLOBAL
 # if IS_IN (libc)
-extern int __libc_multiple_threads;
 #  define SINGLE_THREAD_P \
   __glibc_likely (__libc_multiple_threads == 0)
 # elif IS_IN (libpthread)