From e070501d12b47e88c1ff8c313f887976fb578938 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Tue, 7 Jun 2022 13:09:40 -0300 Subject: Replace __libc_multiple_threads with __libc_single_threaded And also fixes the SINGLE_THREAD_P macro for SINGLE_THREAD_BY_GLOBAL, since header inclusion single-thread.h is in the wrong order, the define needs to come before including sysdeps/unix/sysdep.h. The macro is now moved to a per-arch single-threade.h header. The SINGLE_THREAD_P is used on some more places. Checked on aarch64-linux-gnu and x86_64-linux-gnu. --- nptl/Makefile | 1 - nptl/allocatestack.c | 6 ------ nptl/libc_multiple_threads.c | 28 ---------------------------- nptl/pthread_cancel.c | 2 +- 4 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 nptl/libc_multiple_threads.c (limited to 'nptl') diff --git a/nptl/Makefile b/nptl/Makefile index b585663974..3d2ce8af8a 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -50,7 +50,6 @@ routines = \ events \ futex-internal \ libc-cleanup \ - libc_multiple_threads \ lowlevellock \ nptl-stack \ nptl_deallocate_tsd \ diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 01a282f3f6..98f5f6dd85 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -292,9 +292,6 @@ 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 - __libc_multiple_threads = 1; -#endif #ifdef NEED_DL_SYSINFO SETUP_THREAD_SYSINFO (pd); @@ -413,9 +410,6 @@ 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 - __libc_multiple_threads = 1; -#endif #ifdef NEED_DL_SYSINFO SETUP_THREAD_SYSINFO (pd); diff --git a/nptl/libc_multiple_threads.c b/nptl/libc_multiple_threads.c deleted file mode 100644 index 0c2dc33d0d..0000000000 --- a/nptl/libc_multiple_threads.c +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2002-2022 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 - . */ - -#include - -#if IS_IN (libc) -# 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. */ -int __libc_multiple_threads; -libc_hidden_data_def (__libc_multiple_threads) -# endif -#endif diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c index e67b2df5cc..459317df49 100644 --- a/nptl/pthread_cancel.c +++ b/nptl/pthread_cancel.c @@ -161,7 +161,7 @@ __pthread_cancel (pthread_t th) points get executed. */ THREAD_SETMEM (THREAD_SELF, header.multiple_threads, 1); #ifndef TLS_MULTIPLE_THREADS_IN_TCB - __libc_multiple_threads = 1; + __libc_single_threaded_internal = 0; #endif } while (!atomic_compare_exchange_weak_acquire (&pd->cancelhandling, &oldval, -- cgit 1.4.1