The last uses of PTHREAD_IN_LIBC is where it should have been
__PTHREAD_NPTL/HTL. The latter was not conveniently available everywhere.
Defining it from config.h makes things simpler.
---
config.h.in | 7 +++++--
config.make.in | 1 -
configure | 8 --------
configure.ac | 6 ------
elf/dl-support.c | 2 +-
elf/dl-tls.c | 4 ++--
rt/aio_suspend.c | 2 +-
sysdeps/generic/ldsodefs.h | 17 ++++++++---------
sysdeps/htl/configure | 1 +
sysdeps/htl/configure.ac | 1 +
sysdeps/htl/pthreadP.h | 2 --
sysdeps/mach/hurd/configure | 2 --
sysdeps/mach/hurd/configure.ac | 2 --
sysdeps/nptl/configure | 1 +
sysdeps/nptl/configure.ac | 1 +
sysdeps/nptl/pthreadP.h | 2 --
sysdeps/pthread/sem_close.c | 6 ++++--
sysdeps/pthread/sem_open.c | 6 ++++--
sysdeps/pthread/sem_unlink.c | 6 ++++--
sysdeps/pthread/tst-pthread_kill-exited.c | 4 ++--
sysdeps/pthread/tst-robust8.c | 2 +-
21 files changed, 36 insertions(+), 47 deletions(-)
create mode 100755 sysdeps/htl/configure
create mode 100644 sysdeps/htl/configure.ac
create mode 100755 sysdeps/nptl/configure
create mode 100644 sysdeps/nptl/configure.ac
diff --git a/config.h.in b/config.h.in
index 125532ec6b..b53731c393 100644
--- a/config.h.in
+++ b/config.h.in
@@ -216,8 +216,11 @@
multiple symbol versions for one symbol. */
#define SYMVER_NEEDS_ALIAS 0
-/* Define to 1 if libpthread actually resides in libc. */
-#define PTHREAD_IN_LIBC 0
+/* Define to 1 if libpthread is provided by nptl. */
+#define __PTHREAD_NPTL 0
+
+/* Define to 1 if libpthread is provided by htl. */
+#define __PTHREAD_HTL 0
/* An integer used to scale the timeout of test programs. */
#define TIMEOUTFACTOR 1
diff --git a/config.make.in b/config.make.in
index 42889716e4..856363d0cd 100644
--- a/config.make.in
+++ b/config.make.in
@@ -90,7 +90,6 @@ build-nscd = @build_nscd@
use-nscd = @use_nscd@
build-hardcoded-path-in-tests= @hardcoded_path_in_tests@
build-pt-chown = @build_pt_chown@
-pthread-in-libc = @pthread_in_libc@
man-pages-version = @man_pages_version@
# Build tools.
diff --git a/configure b/configure
index 3296e04c42..c84d283bd5 100755
--- a/configure
+++ b/configure
@@ -612,7 +612,6 @@ ac_unique_file="include/features.h"
enable_option_checking=no
ac_subst_vars='LTLIBOBJS
LIBOBJS
-pthread_in_libc
RELEASE
VERSION
mach_interface_list
@@ -9005,7 +9004,6 @@ libc_cv_sysconfdir=$sysconfdir
libc_cv_localstatedir=$localstatedir
libc_cv_gcc_unwind_find_fde=no
libc_cv_idn=no
-pthread_in_libc=yes
abort_in_ld=no
# Iterate over all the sysdep directories we will use, running their
@@ -9668,12 +9666,6 @@ RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p'
< $srcdir/version.h`
-if test "$pthread_in_libc" = yes; then
- printf "%s\n" "#define PTHREAD_IN_LIBC 1" >>confdefs.h
-
-fi
-
-
# Some symbols that might be auto-generated by the compiler are redefined
# to internal alias (for instance mempcpy to __mempcpy). However, if fortify
# is enabled, the fortify wrapper is define before the alias re-defined and
diff --git a/configure.ac b/configure.ac
index 488af1142b..280ec8e5b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1949,7 +1949,6 @@ libc_cv_sysconfdir=$sysconfdir
libc_cv_localstatedir=$localstatedir
libc_cv_gcc_unwind_find_fde=no
libc_cv_idn=no
-pthread_in_libc=yes
abort_in_ld=no
# Iterate over all the sysdep directories we will use, running their
@@ -2244,11 +2243,6 @@ RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p'
< $srcdir/version.h`
AC_SUBST(VERSION)
AC_SUBST(RELEASE)
-if test "$pthread_in_libc" = yes; then
- AC_DEFINE(PTHREAD_IN_LIBC)
-fi
-AC_SUBST(pthread_in_libc)
-
# Some symbols that might be auto-generated by the compiler are redefined
# to internal alias (for instance mempcpy to __mempcpy). However, if fortify
# is enabled, the fortify wrapper is define before the alias re-defined and
diff --git a/elf/dl-support.c b/elf/dl-support.c
index a782c09c94..0508d6113b 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -169,7 +169,7 @@ fpu_control_t _dl_fpu_control = _FPU_DEFAULT;
/* Required flags used for stack allocation. */
int _dl_stack_prot_flags = DEFAULT_STACK_PROT_PERMS;
-#if !defined (__PTHREAD_HTL)
+#if __PTHREAD_NPTL
list_t _dl_stack_used;
list_t _dl_stack_user;
list_t _dl_stack_cache;
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index 21fb5b5ed7..edf31383b2 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -31,7 +31,7 @@
#include <dl-tls_block_align.h>
#include <pthreadP.h>
-#ifdef __PTHREAD_NPTL
+#if __PTHREAD_NPTL
# include <list.h>
#endif
@@ -1301,7 +1301,7 @@ cannot create TLS data structures"));
return true;
}
-#ifdef __PTHREAD_NPTL
+#if __PTHREAD_NPTL
static inline void __attribute__((always_inline))
init_one_static_tls (struct pthread *curp, struct link_map *map)
{
diff --git a/rt/aio_suspend.c b/rt/aio_suspend.c
index 10eb3dc59d..ec751ca128 100644
--- a/rt/aio_suspend.c
+++ b/rt/aio_suspend.c
@@ -251,7 +251,7 @@ ___aio_suspend_time64 (const struct aiocb *const list[],
int nent,
strong_alias (___aio_suspend_time64, __aio_suspend)
#else /* __TIMESIZE != 64 */
libc_hidden_ver (___aio_suspend_time64, __aio_suspend_time64)
-#ifndef __PTHREAD_HTL
+#if __PTHREAD_NPTL
versioned_symbol (libc, ___aio_suspend_time64, __aio_suspend_time64,
RT_IN_LIBC);
#endif
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index cbb8273a7d..15c4659853 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -447,7 +447,7 @@ struct rtld_global
size_t count;
void *list[50];
} *_dl_scope_free_list;
-#if !defined __PTHREAD_HTL
+#if __PTHREAD_NPTL
/* List of active thread stacks, with memory managed by glibc. */
EXTERN list_t _dl_stack_used;
@@ -467,7 +467,8 @@ struct rtld_global
/* Mutex protecting the stack lists. */
EXTERN int _dl_stack_cache_lock;
-#else
+#endif
+#if __PTHREAD_HTL
/* The total number of thread IDs currently in use, or on the list of
available thread IDs. */
EXTERN int _dl_pthread_num_threads;
@@ -1435,13 +1436,11 @@ _dl_audit_objclose (struct link_map *l)
}
#endif /* !SHARED */
-#if PTHREAD_IN_LIBC && defined SHARED
+#if __PTHREAD_NPTL && defined SHARED
/* Recursive locking implementation for use within the dynamic loader.
Used to define the __rtld_lock_lock_recursive and
__rtld_lock_unlock_recursive via <libc-lock.h>. Initialized to a
- no-op dummy implementation early. Similar
- to GL (dl_rtld_lock_recursive) and GL (dl_rtld_unlock_recursive)
- in !PTHREAD_IN_LIBC builds. */
+ no-op dummy implementation early. */
extern int (*___rtld_mutex_lock) (pthread_mutex_t *) attribute_hidden;
extern int (*___rtld_mutex_unlock) (pthread_mutex_t *lock) attribute_hidden;
@@ -1449,14 +1448,14 @@ extern int (*___rtld_mutex_unlock) (pthread_mutex_t
*lock) attribute_hidden;
Used to initialize the function pointers to the actual
implementations. */
void __rtld_mutex_init (void) attribute_hidden;
-#else /* !PTHREAD_IN_LIBC */
+#else /* !__PHREAD_NPTL */
static inline void
__rtld_mutex_init (void)
{
- /* The initialization happens later (!PTHREAD_IN_LIBC) or is not
+ /* The initialization happens later (!__PHREAD_NPTL) or is not
needed at all (!SHARED). */
}
-#endif /* !PTHREAD_IN_LIBC */
+#endif /* !__PHREAD_NPTL */
/* Implementation of GL (dl_libc_freeres). */
void __rtld_libc_freeres (void) attribute_hidden;
diff --git a/sysdeps/htl/configure b/sysdeps/htl/configure
new file mode 100755
index 0000000000..4c84d3732d
--- /dev/null
+++ b/sysdeps/htl/configure
@@ -0,0 +1 @@
+printf "%s\n" "#define __PTHREAD_HTL 1" >>confdefs.h
diff --git a/sysdeps/htl/configure.ac b/sysdeps/htl/configure.ac
new file mode 100644
index 0000000000..114aea7a18
--- /dev/null
+++ b/sysdeps/htl/configure.ac
@@ -0,0 +1 @@
+AC_DEFINE(__PTHREAD_HTL)
diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h
index 2ae24074e9..a8058dfad3 100644
--- a/sysdeps/htl/pthreadP.h
+++ b/sysdeps/htl/pthreadP.h
@@ -19,8 +19,6 @@
#ifndef _PTHREADP_H
#define _PTHREADP_H 1
-#define __PTHREAD_HTL
-
#include <pthread.h>
#include <link.h>
#include <bits/cancelation.h>
diff --git a/sysdeps/mach/hurd/configure b/sysdeps/mach/hurd/configure
index 743bad5fcb..b00af8aa8b 100644
--- a/sysdeps/mach/hurd/configure
+++ b/sysdeps/mach/hurd/configure
@@ -218,8 +218,6 @@ if test -n "$sysheaders"; then
CPPFLAGS=$OLD_CPPFLAGS
fi
-# Hurd has libpthread as a separate library.
-pthread_in_libc=no
# Hurd already provides abort implementation for the loader
abort_in_ld=yes
diff --git a/sysdeps/mach/hurd/configure.ac b/sysdeps/mach/hurd/configure.ac
index 6d33feed0e..7af525b06f 100644
--- a/sysdeps/mach/hurd/configure.ac
+++ b/sysdeps/mach/hurd/configure.ac
@@ -46,7 +46,5 @@ if test -n "$sysheaders"; then
CPPFLAGS=$OLD_CPPFLAGS
fi
-# Hurd has libpthread as a separate library.
-pthread_in_libc=no
# Hurd already provides abort implementation for the loader
abort_in_ld=yes
diff --git a/sysdeps/nptl/configure b/sysdeps/nptl/configure
new file mode 100755
index 0000000000..f0870a5e14
--- /dev/null
+++ b/sysdeps/nptl/configure
@@ -0,0 +1 @@
+printf "%s\n" "#define __PTHREAD_NPTL 1" >>confdefs.h
diff --git a/sysdeps/nptl/configure.ac b/sysdeps/nptl/configure.ac
new file mode 100644
index 0000000000..0602270df1
--- /dev/null
+++ b/sysdeps/nptl/configure.ac
@@ -0,0 +1 @@
+AC_DEFINE(__PTHREAD_NPTL)
diff --git a/sysdeps/nptl/pthreadP.h b/sysdeps/nptl/pthreadP.h
index e78d2638bd..de432d4032 100644
--- a/sysdeps/nptl/pthreadP.h
+++ b/sysdeps/nptl/pthreadP.h
@@ -18,8 +18,6 @@
#ifndef _PTHREADP_H
#define _PTHREADP_H 1
-#define __PTHREAD_NPTL
-
#include <pthread.h>
#include <setjmp.h>
#include <stdbool.h>
diff --git a/sysdeps/pthread/sem_close.c b/sysdeps/pthread/sem_close.c
index 5d5278d7cd..81be1be7e1 100644
--- a/sysdeps/pthread/sem_close.c
+++ b/sysdeps/pthread/sem_close.c
@@ -31,12 +31,14 @@ __sem_close (sem_t *sem)
return 0;
}
-#ifndef __PTHREAD_HTL
+#if __PTHREAD_NPTL
versioned_symbol (libc, __sem_close, sem_close, GLIBC_2_34);
# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_1_1, GLIBC_2_34)
compat_symbol (libpthread, __sem_close, sem_close, GLIBC_2_1_1);
# endif
-#else /* __PTHREAD_HTL */
+#endif
+
+#if __PTHREAD_HTL
versioned_symbol (libc, __sem_close, sem_close, GLIBC_2_43);
# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
compat_symbol (libpthread, __sem_close, sem_close, GLIBC_2_12);
diff --git a/sysdeps/pthread/sem_open.c b/sysdeps/pthread/sem_open.c
index be16e55a2d..58e11a4411 100644
--- a/sysdeps/pthread/sem_open.c
+++ b/sysdeps/pthread/sem_open.c
@@ -201,12 +201,14 @@ out:
return result;
}
-#ifndef __PTHREAD_HTL
+#if __PTHREAD_NPTL
versioned_symbol (libc, __sem_open, sem_open, GLIBC_2_34);
# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_1_1, GLIBC_2_34)
compat_symbol (libpthread, __sem_open, sem_open, GLIBC_2_1_1);
# endif
-#else /* __PTHREAD_HTL */
+#endif
+
+#if __PTHREAD_HTL
versioned_symbol (libc, __sem_open, sem_open, GLIBC_2_43);
# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
compat_symbol (libpthread, __sem_open, sem_open, GLIBC_2_12);
diff --git a/sysdeps/pthread/sem_unlink.c b/sysdeps/pthread/sem_unlink.c
index cc98963bd8..94ddef3eea 100644
--- a/sysdeps/pthread/sem_unlink.c
+++ b/sysdeps/pthread/sem_unlink.c
@@ -40,12 +40,14 @@ __sem_unlink (const char *name)
__set_errno (EACCES);
return ret;
}
-#ifndef __PTHREAD_HTL
+#if __PTHREAD_NPTL
versioned_symbol (libc, __sem_unlink, sem_unlink, GLIBC_2_34);
# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_1_1, GLIBC_2_34)
compat_symbol (libpthread, __sem_unlink, sem_unlink, GLIBC_2_1_1);
# endif
-#else /* __PTHREAD_HTL */
+#endif
+
+#if __PTHREAD_HTL
versioned_symbol (libc, __sem_unlink, sem_unlink, GLIBC_2_43);
# if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_43)
compat_symbol (libpthread, __sem_unlink, sem_unlink, GLIBC_2_12);
diff --git a/sysdeps/pthread/tst-pthread_kill-exited.c
b/sysdeps/pthread/tst-pthread_kill-exited.c
index 422789c1d4..709b6ce2c2 100644
--- a/sysdeps/pthread/tst-pthread_kill-exited.c
+++ b/sysdeps/pthread/tst-pthread_kill-exited.c
@@ -34,7 +34,7 @@ noop_thread (void *closure)
return NULL;
}
-#if TEST_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34) && PTHREAD_IN_LIBC
+#if TEST_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34) && __PTHREAD_NPTL
extern __typeof (pthread_kill) compat_pthread_kill;
compat_symbol_reference (libpthread, compat_pthread_kill, pthread_kill,
GLIBC_2_0);
@@ -50,7 +50,7 @@ do_test (void)
/* NB: Always uses the default symbol due to separate compilation. */
xpthread_kill (thr, SIGUSR1);
-#if TEST_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34) && PTHREAD_IN_LIBC
+#if TEST_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_34) && __PTHREAD_NPTL
/* Old binaries need the non-conforming ESRCH error code. */
TEST_COMPARE (compat_pthread_kill (thr, SIGUSR1), ESRCH);
#endif
diff --git a/sysdeps/pthread/tst-robust8.c b/sysdeps/pthread/tst-robust8.c
index 4c8a20e916..65f37feddf 100644
--- a/sysdeps/pthread/tst-robust8.c
+++ b/sysdeps/pthread/tst-robust8.c
@@ -253,7 +253,7 @@ do_test (void)
{
printf ("mutex_destroy %d in round %d failed with %d\n",
n + 1, round, e);
-#ifdef __PTHREAD_NPTL
+#if __PTHREAD_NPTL
printf("nusers = %d\n", (int) map[n].__data.__nusers);
#endif
return 1;
--
2.51.0