From patchwork Mon Mar 16 12:04:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 131790 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 9A4AB4B7A1CA for ; Mon, 16 Mar 2026 12:04:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A4AB4B7A1CA X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 047134B9DB6E for ; Mon, 16 Mar 2026 12:04:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 047134B9DB6E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 047134B9DB6E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773662658; cv=none; b=Cy6kYQJm3u10nYwe18amHloeNui35DURwujDZlCu8iCBhPGxTdY/5wxQRFnlWtY7EDjpqkCq/13fdPOclPS4eNn1lFDDVi2t52kyMhUSdjB/gSavywO9YbHGSvflfGbpxRulW3NrU28jk7CKkCGyNQwyJNeJ+KBTUIUPwbBX4E8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773662658; c=relaxed/simple; bh=kwvxDhiRlIS2h8ssxVSjczGkHb2QZ3+PwrBAl7OLzac=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=x/5Gkax6QEL3QzR7htxXV3UdaBdgqlYU3jLCb8rR3M6aeGIRNZm719w0o+ZxJRXFG7GhJpXziLQYOFYc9pj2SeurdwGi9QMIclXlFowjj62/OavT4Ch56T9sIfTFkw7RtKcvqAab3p5vM/sAh2PZE6D1ApSnivNyz56iEU8Bw1o= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 047134B9DB6E Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 580E1A01EF; Mon, 16 Mar 2026 13:04:15 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cYFdzt5NucGL; Mon, 16 Mar 2026 13:04:15 +0100 (CET) Received: from end (unknown [212.133.41.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 16578A014A; Mon, 16 Mar 2026 13:04:15 +0100 (CET) Received: from samy by end with local (Exim 4.99.1) (envelope-from ) id 1w26gA-0000000Bk0r-14cU; Mon, 16 Mar 2026 13:04:14 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited] nptl/htl: Fix confusion over PTHREAD_IN_LIBC and __PTHREAD_NPTL/HTL Date: Mon, 16 Mar 2026 13:04:12 +0100 Message-ID: <20260316120412.2798474-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org 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 #include -#ifdef __PTHREAD_NPTL +#if __PTHREAD_NPTL # include #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 . 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 #include #include 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 #include #include 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;