From patchwork Tue Mar 16 17:31:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 42628 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A079A384A882; Tue, 16 Mar 2021 17:31:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A079A384A882 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1615915915; bh=ubOFxTluNqbjIkBDs3JYIPOO/cjctfWdpAXdTgCmdQQ=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=guqGBsWyMEB9QyA97bnpu8rX4cZ+MViIIzUm/4NzAMjnZuQ9//38toNX5+JihZ0Xd 4nEppIPDlY3EtU21Mfz26SraIiyFKT5ZWVKNVttGfh1HAORkzDLRRLeaR0gzo7m2vF cMd0bIMjtpTSiW99OPQJbNvJFBlqVXjK2ojTUh94= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id E23D9384BC11 for ; Tue, 16 Mar 2021 17:31:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E23D9384BC11 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-469-Fa__nl-6OH2yzaxpkU8aog-1; Tue, 16 Mar 2021 13:31:50 -0400 X-MC-Unique: Fa__nl-6OH2yzaxpkU8aog-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 722AC809AC7 for ; Tue, 16 Mar 2021 17:31:49 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-254.ams2.redhat.com [10.36.112.254]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 929F76268D for ; Tue, 16 Mar 2021 17:31:48 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH v3 37/37] nptl: Remove remnants of the libc/libpthread forwarder interface In-Reply-To: References: Message-Id: <452f10ce207ae27d4d3ce76054b03f9778080550.1615914632.git.fweimer@redhat.com> Date: Tue, 16 Mar 2021 18:31:57 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" All previously forwarded functions are now implemented in libc. Reviewed-by: Adhemerval Zanella --- nptl/Makefile | 1 - nptl/forward.c | 31 -------------------- nptl/libc_pthread_init.c | 29 +----------------- nptl/nptl-init.c | 11 +------ nptl/pthreadP.h | 7 ++--- sysdeps/nptl/libc-lockP.h | 28 ++++-------------- sysdeps/nptl/pthread-functions.h | 50 -------------------------------- 7 files changed, 10 insertions(+), 147 deletions(-) delete mode 100644 nptl/forward.c delete mode 100644 sysdeps/nptl/pthread-functions.h diff --git a/nptl/Makefile b/nptl/Makefile index 1b5038485d..7423967cd2 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -38,7 +38,6 @@ routines = \ elision-timed \ elision-trylock \ elision-unlock \ - forward \ futex-internal \ libc-cancellation \ libc-cleanup \ diff --git a/nptl/forward.c b/nptl/forward.c deleted file mode 100644 index c819ab6f2a..0000000000 --- a/nptl/forward.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 2002-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2002. - - 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 -#include -#include -#include - -#include -#include -#include - - -/* Pointers to the libc functions. */ -struct pthread_functions __libc_pthread_functions attribute_hidden; -int __libc_pthread_functions_init attribute_hidden; diff --git a/nptl/libc_pthread_init.c b/nptl/libc_pthread_init.c index 85fceff930..c951332666 100644 --- a/nptl/libc_pthread_init.c +++ b/nptl/libc_pthread_init.c @@ -34,38 +34,11 @@ extern int __libc_multiple_threads attribute_hidden; int * #endif -__libc_pthread_init (void (*reclaim) (void), - const struct pthread_functions *functions) +__libc_pthread_init (void (*reclaim) (void)) { /* Called by a child after fork. */ __register_atfork (NULL, NULL, reclaim, NULL); -#ifdef SHARED - /* Copy the function pointers into an array in libc. This enables - access with just one memory reference but moreso, it prevents - hijacking the function pointers with just one pointer change. We - "encrypt" the function pointers since we cannot write-protect the - array easily enough. */ - union ptrhack - { - struct pthread_functions pf; -# define NPTRS (sizeof (struct pthread_functions) / sizeof (void *)) - void *parr[NPTRS]; - } __attribute__ ((may_alias)) const *src; - union ptrhack *dest; - - src = (const void *) functions; - dest = (void *) &__libc_pthread_functions; - - for (size_t cnt = 0; cnt < NPTRS; ++cnt) - { - void *p = src->parr[cnt]; - PTR_MANGLE (p); - dest->parr[cnt] = p; - } - __libc_pthread_functions_init = 1; -#endif - #ifndef TLS_MULTIPLE_THREADS_IN_TCB return &__libc_multiple_threads; #endif diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index f4a603b32d..061e3ff8d7 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -50,15 +50,6 @@ size_t __static_tls_align_m1; /* Version of the library, used in libthread_db to detect mismatches. */ static const char nptl_version[] __attribute_used__ = VERSION; -#ifdef SHARED -static const struct pthread_functions pthread_functions = - { - }; -# define ptr_pthread_functions &pthread_functions -#else -# define ptr_pthread_functions NULL -#endif - /* For asynchronous cancellation we use a signal. This is the handler. */ static void sigcancel_handler (int sig, siginfo_t *si, void *ctx) @@ -207,7 +198,7 @@ __pthread_initialize_minimal_internal (void) #ifndef TLS_MULTIPLE_THREADS_IN_TCB __libc_multiple_threads_ptr = #endif - __libc_pthread_init (__reclaim_stacks, ptr_pthread_functions); + __libc_pthread_init (__reclaim_stacks); } strong_alias (__pthread_initialize_minimal_internal, __pthread_initialize_minimal) diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 9852906b3a..a1d34d5ff1 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -364,11 +363,9 @@ hidden_proto (__nptl_death_event) /* Register the generation counter in the libpthread with the libc. */ #ifdef TLS_MULTIPLE_THREADS_IN_TCB -extern void __libc_pthread_init (void (*reclaim) (void), - const struct pthread_functions *functions); +extern void __libc_pthread_init (void (*reclaim) (void)); #else -extern int *__libc_pthread_init (void (*reclaim) (void), - const struct pthread_functions *functions); +extern int *__libc_pthread_init (void (*reclaim) (void)); /* 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 diff --git a/sysdeps/nptl/libc-lockP.h b/sysdeps/nptl/libc-lockP.h index 0dd2ea1147..e573689799 100644 --- a/sysdeps/nptl/libc-lockP.h +++ b/sysdeps/nptl/libc-lockP.h @@ -32,7 +32,6 @@ ld.so might be used on old kernels with a different libc.so. */ #include #include -#include #if IS_IN (libpthread) /* This gets us the declarations of the __pthread_* internal names, @@ -100,27 +99,12 @@ _Static_assert (LLL_LOCK_INITIALIZER == 0, "LLL_LOCK_INITIALIZER != 0"); (FUNC != NULL ? FUNC ARGS : ELSE) #endif -/* Call thread functions through the function pointer table. */ -#if defined SHARED && IS_IN (libc) -# define PTFAVAIL(NAME) __libc_pthread_functions_init -# define __libc_ptf_call(FUNC, ARGS, ELSE) \ - (__libc_pthread_functions_init ? PTHFCT_CALL (ptr_##FUNC, ARGS) : ELSE) -# define __libc_ptf_call_always(FUNC, ARGS) \ - PTHFCT_CALL (ptr_##FUNC, ARGS) -#elif IS_IN (libpthread) -# define PTFAVAIL(NAME) 1 -# define __libc_ptf_call(FUNC, ARGS, ELSE) \ - FUNC ARGS -# define __libc_ptf_call_always(FUNC, ARGS) \ - FUNC ARGS -#else -# define PTFAVAIL(NAME) (NAME != NULL) -# define __libc_ptf_call(FUNC, ARGS, ELSE) \ - __libc_maybe_call (FUNC, ARGS, ELSE) -# define __libc_ptf_call_always(FUNC, ARGS) \ - FUNC ARGS -#endif - +/* All previously forwarded functions are now called directly (either + via local call in libc, or through a __export), but __libc_ptf_call + is still used in generic code shared with Hurd. */ +#define PTFAVAIL(NAME) 1 +#define __libc_ptf_call(FUNC, ARGS, ELSE) FUNC ARGS +#define __libc_ptf_call_always(FUNC, ARGS) FUNC ARGS /* Initialize the named lock variable, leaving it in a consistent, unlocked state. */ diff --git a/sysdeps/nptl/pthread-functions.h b/sysdeps/nptl/pthread-functions.h deleted file mode 100644 index d76b2cdecf..0000000000 --- a/sysdeps/nptl/pthread-functions.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2003-2021 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 2003. - - 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 - . */ - -#ifndef _PTHREAD_FUNCTIONS_H -#define _PTHREAD_FUNCTIONS_H 1 - -#include -#include -#include -#include - -struct xid_command; - -/* Data type shared with libc. The libc uses it to pass on calls to - the thread functions. */ -struct pthread_functions -{ -}; - -/* Variable in libc.so. */ -extern struct pthread_functions __libc_pthread_functions attribute_hidden; -extern int __libc_pthread_functions_init attribute_hidden; - -#ifdef PTR_DEMANGLE -# define PTHFCT_CALL(fct, params) \ - ({ __typeof (__libc_pthread_functions.fct) __p; \ - __p = __libc_pthread_functions.fct; \ - PTR_DEMANGLE (__p); \ - __p params; }) -#else -# define PTHFCT_CALL(fct, params) \ - __libc_pthread_functions.fct params -#endif - -#endif /* pthread-functions.h */