nptl: Remove remnants of the libc/libpthread forwarder interface

All previously forwarded functions are now implemented in libc.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
This commit is contained in:
Florian Weimer 2021-04-21 19:49:51 +02:00
parent 486010a3c8
commit 1d67cf9e8a
7 changed files with 10 additions and 147 deletions

View File

@ -38,7 +38,6 @@ routines = \
elision-timed \
elision-trylock \
elision-unlock \
forward \
futex-internal \
libc-cancellation \
libc-cleanup \

View File

@ -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;

View File

@ -35,38 +35,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

View File

@ -49,15 +49,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)
@ -206,7 +197,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)

View File

@ -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>
@ -370,11 +369,9 @@ 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),
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

View File

@ -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. */

View File

@ -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 */