From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH v3 37/37] nptl: Remove remnants of the libc/libpthread forwarder interface
Date: Fri, 26 Mar 2021 15:19:42 -0300 [thread overview]
Message-ID: <d607a38d-61ab-c84d-072c-57398388c241@linaro.org> (raw)
In-Reply-To: <452f10ce207ae27d4d3ce76054b03f9778080550.1615914632.git.fweimer@redhat.com>
On 16/03/2021 14:31, Florian Weimer via Libc-alpha wrote:
> All previously forwarded functions are now implemented in libc.
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> 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 \
Ok.
> 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 <drepper@redhat.com>, 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <dlfcn.h>
> -#include <pthreadP.h>
> -#include <signal.h>
> -#include <stdlib.h>
> -
> -#include <shlib-compat.h>
> -#include <atomic.h>
> -#include <safe-fatal.h>
> -
> -
> -/* Pointers to the libc functions. */
> -struct pthread_functions __libc_pthread_functions attribute_hidden;
> -int __libc_pthread_functions_init attribute_hidden;
Ok.
> 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
Ok.
> 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)
Ok.
> @@ -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)
Ok.
> 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 <lowlevellock.h>
> #include <stackinfo.h>
> #include <internaltypes.h>
> -#include <pthread-functions.h>
> #include <atomic.h>
> #include <kernel-features.h>
> #include <errno.h>
> @@ -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
Maybe move the __libc_pthread_init prototype out of TLS_MULTIPLE_THREADS_IN_TCB
since it is duplicated.
> 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 <lowlevellock.h>
> #include <tls.h>
> -#include <pthread-functions.h>
>
> #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. */
Ok.
> 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 <drepper@redhat.com>, 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#ifndef _PTHREAD_FUNCTIONS_H
> -#define _PTHREAD_FUNCTIONS_H 1
> -
> -#include <pthread.h>
> -#include <setjmp.h>
> -#include <internaltypes.h>
> -#include <sysdep.h>
> -
> -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 */
>
Ok.
next prev parent reply other threads:[~2021-03-26 18:19 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 17:27 [PATCH v3 00/37] libpthread removal: NPTL forwarders are gone Florian Weimer
2021-03-16 17:27 ` [PATCH v3 01/37] nptl: Move pthread_mutex_consistent into libc Florian Weimer
2021-03-17 11:36 ` Adhemerval Zanella
2021-03-16 17:27 ` [PATCH v3 02/37] nptl: Move __pthread_cleanup_routine " Florian Weimer
2021-03-16 17:27 ` [PATCH v3 03/37] nptl: Move legacy unwinding implementation " Florian Weimer
2021-03-16 17:27 ` [PATCH v3 04/37] nptl: Move legacy cancelation handling into libc as compat symbols Florian Weimer
2021-03-16 17:27 ` [PATCH v3 05/37] nptl: Remove longjmp, siglongjmp from libpthread Florian Weimer
2021-03-17 11:38 ` Adhemerval Zanella
2021-03-16 17:28 ` [PATCH v3 06/37] x86: Restore compile-time check for shadow stack pointer in longjmp Florian Weimer
2021-03-16 17:28 ` [PATCH v3 07/37] nptl: Move __pthread_cleanup_upto into libc Florian Weimer
2021-03-16 17:28 ` [PATCH v3 08/37] nptl: Move pthread_once and __pthread_once " Florian Weimer
2021-03-17 13:30 ` Adhemerval Zanella
2021-03-17 13:37 ` Adhemerval Zanella
2021-03-17 14:45 ` Florian Weimer
2021-03-17 16:39 ` Adhemerval Zanella
2021-03-17 16:56 ` Florian Weimer
2021-03-17 17:22 ` Adhemerval Zanella
2021-03-17 17:43 ` Florian Weimer
2021-03-17 19:09 ` Adhemerval Zanella
2021-03-16 17:29 ` [PATCH v3 09/37] nptl: Move __pthread_unwind_next " Florian Weimer
2021-03-17 19:42 ` Adhemerval Zanella
2021-03-17 19:54 ` Florian Weimer
2021-03-17 20:16 ` Adhemerval Zanella
2021-03-17 20:33 ` Florian Weimer
2021-03-17 20:44 ` Adhemerval Zanella
2021-03-16 17:29 ` [PATCH v3 10/37] csu: Move calling main out of __libc_start_main_impl Florian Weimer
2021-03-17 20:45 ` Adhemerval Zanella
2021-03-16 17:29 ` [PATCH v3 11/37] nptl: Move internal __nptl_nthreads variable into libc Florian Weimer
2021-03-18 12:42 ` Adhemerval Zanella
2021-03-16 17:29 ` [PATCH v3 12/37] nptl_db: Introduce DB_MAIN_ARRAY_VARIABLE Florian Weimer
2021-03-18 12:43 ` Adhemerval Zanella
2021-03-16 17:29 ` [PATCH v3 13/37] nptl: Move __pthread_keys global variable into libc Florian Weimer
2021-03-18 12:44 ` Adhemerval Zanella
2021-03-16 17:29 ` [PATCH v3 14/37] nptl: Move __nptl_deallocate_tsd " Florian Weimer
2021-03-18 12:46 ` Adhemerval Zanella
2021-03-18 17:16 ` Florian Weimer
2021-03-18 17:54 ` Adhemerval Zanella
2021-03-16 17:29 ` [PATCH v3 15/37] nptl: Move pthread_exit " Florian Weimer
2021-03-18 12:49 ` Adhemerval Zanella
2021-03-16 17:29 ` [PATCH v3 16/37] nptl: Move pthread_setcancelstate " Florian Weimer
2021-03-18 12:52 ` Adhemerval Zanella
2021-03-16 17:29 ` [PATCH v3 17/37] nptl: Move pthread_setcanceltype " Florian Weimer
2021-03-18 12:53 ` Adhemerval Zanella
2021-03-16 17:29 ` [PATCH v3 18/37] nptl: Invoke the set_robust_list system call directly in fork Florian Weimer
2021-03-18 12:54 ` Adhemerval Zanella
2021-03-16 17:30 ` [PATCH v3 19/37] dlfcn: Failures after dlmopen should not terminate process [BZ #24772] Florian Weimer
2021-03-19 19:56 ` Adhemerval Zanella
2021-03-27 16:57 ` Florian Weimer
2021-03-16 17:30 ` [PATCH v3 20/37] dlfcn: dlerror needs to call free from the base namespace [BZ #24773] Florian Weimer
2021-03-23 14:47 ` Adhemerval Zanella
2021-03-16 17:30 ` [PATCH v3 21/37] Remove pthread_key_create-related internals from libc-lock.h Florian Weimer
2021-03-23 16:39 ` Adhemerval Zanella
2021-03-16 17:30 ` [PATCH v3 22/37] elf: Introduce __tls_init_tp for second-phase TCB initialization Florian Weimer
2021-03-23 18:25 ` Adhemerval Zanella
2021-03-16 17:30 ` [PATCH v3 23/37] nptl: Move part of TCB initialization from libpthread to __tls_init_tp Florian Weimer
2021-03-24 13:56 ` Adhemerval Zanella
2021-03-27 17:19 ` Florian Weimer
2021-03-16 17:30 ` [PATCH v3 24/37] nptl: Move pthread_key_create, __pthread_key_create into libc Florian Weimer
2021-03-24 14:09 ` Adhemerval Zanella
2021-03-24 14:32 ` Florian Weimer
2021-03-24 14:42 ` Adhemerval Zanella
2021-03-24 15:08 ` Florian Weimer
2021-03-24 15:46 ` Adhemerval Zanella
2021-03-16 17:30 ` [PATCH v3 25/37] nptl: Move pthread_getspecific, __pthread_getspecific " Florian Weimer
2021-03-24 14:12 ` Adhemerval Zanella
2021-03-24 14:38 ` Florian Weimer
2021-03-24 14:43 ` Adhemerval Zanella
2021-03-16 17:30 ` [PATCH v3 26/37] nptl: Move pthread_setspecific, __pthread_setspecific " Florian Weimer
2021-03-24 14:26 ` Adhemerval Zanella
2021-03-16 17:30 ` [PATCH v3 27/37] nptl: Move pthread_key_delete " Florian Weimer
2021-03-24 14:45 ` Adhemerval Zanella
2021-03-16 17:31 ` [PATCH v3 28/37] nptl: Move rwlock functions with forwarders " Florian Weimer
2021-03-25 19:52 ` Adhemerval Zanella
2021-03-27 21:41 ` Florian Weimer
2021-03-16 17:31 ` [PATCH v3 29/37] nptl: Move the internal thread priority protection symbols " Florian Weimer
2021-03-25 20:21 ` Adhemerval Zanella
2021-03-16 17:31 ` [PATCH v3 30/37] pthread: Introduce __pthread_early_init Florian Weimer
2021-03-25 20:22 ` Adhemerval Zanella
2021-03-16 17:31 ` [PATCH v3 31/37] nptl: Move internal symbol __mutex_aconf into libc Florian Weimer
2021-03-25 20:24 ` Adhemerval Zanella
2021-03-16 17:31 ` [PATCH v3 32/37] nptl: pthread_mutex_lock, pthread_mutex_unock single-threaded optimization Florian Weimer
2021-03-26 18:00 ` Adhemerval Zanella
2021-03-16 17:31 ` [PATCH v3 33/37] x86: Remove low-level lock optimization Florian Weimer
2021-03-25 20:30 ` Adhemerval Zanella
2021-03-16 17:31 ` [PATCH v3 34/37] nptl: Move core mutex functions into libc Florian Weimer
2021-03-25 20:46 ` Adhemerval Zanella
2021-03-16 17:31 ` [PATCH v3 35/37] nptl: Move core condition variable " Florian Weimer
2021-03-26 17:14 ` Adhemerval Zanella
2021-03-16 17:31 ` [PATCH v3 36/37] nptl: Move setxid broadcast implementation " Florian Weimer
2021-03-26 18:15 ` Adhemerval Zanella
2021-04-06 18:41 ` Florian Weimer
2021-04-06 18:54 ` Adhemerval Zanella
2021-04-06 19:23 ` Florian Weimer
2021-04-06 19:40 ` Adhemerval Zanella
2021-03-16 17:31 ` [PATCH v3 37/37] nptl: Remove remnants of the libc/libpthread forwarder interface Florian Weimer
2021-03-26 18:19 ` Adhemerval Zanella [this message]
2021-03-18 22:06 ` [PATCH v3 00/37] libpthread removal: NPTL forwarders are gone Florian Weimer
2021-03-26 18:25 ` Adhemerval Zanella
2021-03-31 10:18 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d607a38d-61ab-c84d-072c-57398388c241@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).