From patchwork Sat Aug 16 00:14:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 118448 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 98CF93858C2A for ; Sat, 16 Aug 2025 00:25:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98CF93858C2A 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 0163F3858413 for ; Sat, 16 Aug 2025 00:14:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0163F3858413 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 0163F3858413 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=1755303266; cv=none; b=H+/FDtR9bIy+QjLdXjyseLUBJnzrLig2yb+TjoqmORk1GHTqL7OFgK86WhR5CztTUrEYQdSqja+i+DQ5kZ0H/6t61YZqGKc9WFWUGd7a0NWbsnX3kbqaE3nmvhJ/AGbDwAVhOtqE+Vbi41J33L8DPM8s3NnzqzDBukTCeq9Vq2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1755303266; c=relaxed/simple; bh=IjNw2AjV8vVZyYaO7soYykVYmcaF07MGuSNBZWQRpD0=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=oFHovUlzj660yOMc198C8M/0VB7bKdmbBZ2GKIpN1WZRj6/uJha59vbxlbQlykwgDzh8b7lpffKnbvl/2TqFQ/DEhUhWdRQiK/GWv278AucmqgI+w9P3IVCNNZvHFcAWG9zkA6w2gYbAB6OQjMKpi9heRLJfb8lYRU624KjgxVk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0163F3858413 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 992B4A5DFF; Sat, 16 Aug 2025 02:14:08 +0200 (CEST) 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 HHacW5rKa_ts; Sat, 16 Aug 2025 02:14:08 +0200 (CEST) Received: from begin (165.21.205.77.rev.sfr.net [77.205.21.165]) (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 BD52EA49BC; Sat, 16 Aug 2025 02:14:07 +0200 (CEST) Received: from samy by begin with local (Exim 4.98.2) (envelope-from ) id 1un4Yg-00000000WyU-3a8f; Sat, 16 Aug 2025 02:14:06 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: gfleury , commit-hurd@gnu.org Subject: [hurd,commited 16/19] htl: move pthread_exit into libc. Date: Sat, 16 Aug 2025 02:14:02 +0200 Message-ID: <20250816001405.126154-17-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250816001405.126154-1-samuel.thibault@ens-lyon.org> References: <20250816001405.126154-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.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 From: gfleury Message-ID: <20250815181500.107433-17-gfleury@disroot.org> --- htl/Makefile | 2 +- htl/Versions | 4 ++- htl/forward.c | 30 --------------------- htl/pt-exit.c | 9 +++++-- htl/pt-initialize.c | 1 - htl/pt-setcancelstate.c | 2 +- htl/pt-setcanceltype.c | 2 +- sysdeps/htl/pthread-functions.h | 3 --- sysdeps/htl/pthreadP.h | 9 +------ sysdeps/mach/hurd/i386/libc.abilist | 1 + sysdeps/mach/hurd/i386/libpthread.abilist | 1 - sysdeps/mach/hurd/x86_64/libpthread.abilist | 1 - 12 files changed, 15 insertions(+), 50 deletions(-) diff --git a/htl/Makefile b/htl/Makefile index 4982409c77..8530098a71 100644 --- a/htl/Makefile +++ b/htl/Makefile @@ -26,7 +26,6 @@ LCLHDRS := libpthread-routines := \ pt-create \ - pt-exit \ pt-initialize \ pt-join \ pt-spin-inlines \ @@ -141,6 +140,7 @@ routines := \ pt-destroy-specific \ pt-detach \ pt-docancel \ + pt-exit \ pt-getattr \ pt-getconcurrency \ pt-getcpuclockid \ diff --git a/htl/Versions b/htl/Versions index 322c09f908..44af006b74 100644 --- a/htl/Versions +++ b/htl/Versions @@ -58,6 +58,7 @@ libc { pthread_key_create; pthread_key_delete; pthread_kill; + pthread_exit; pthread_mutex_destroy; pthread_mutex_getprioceiling; pthread_mutex_init; @@ -245,6 +246,7 @@ libc { __pthread_condattr_init; __pthread_default_condattr; __pthread_destroy_specific; + __pthread_exit; __pthread_getspecific; __pthread_key_delete; __pthread_max_threads; @@ -297,7 +299,7 @@ libpthread { pthread_atfork; - pthread_create; pthread_exit; + pthread_create; pthread_join; diff --git a/htl/forward.c b/htl/forward.c index 21acf664f4..9294d25724 100644 --- a/htl/forward.c +++ b/htl/forward.c @@ -27,33 +27,3 @@ /* Pointers to the libc functions. */ struct pthread_functions __libc_pthread_functions attribute_hidden; int __libc_pthread_functions_init attribute_hidden; - - -#define FORWARD2(name, rettype, decl, params, defaction) \ -rettype \ -name decl \ -{ \ - if (!__libc_pthread_functions_init) \ - defaction; \ - \ - return PTHFCT_CALL (ptr_##name, params); \ -} - -/* Same as FORWARD2, only without return. */ -#define FORWARD_NORETURN(name, rettype, decl, params, defaction) \ -rettype \ -name decl \ -{ \ - if (!__libc_pthread_functions_init) \ - defaction; \ - \ - PTHFCT_CALL (ptr_##name, params); \ -} - -#define FORWARD(name, decl, params, defretval) \ - FORWARD2 (name, int, decl, params, return defretval) - -/* Use an alias to avoid warning, as pthread_exit is declared noreturn. */ -FORWARD_NORETURN (__pthread_exit, void, (void *retval), (retval), - exit (EXIT_SUCCESS)) -strong_alias (__pthread_exit, pthread_exit); diff --git a/htl/pt-exit.c b/htl/pt-exit.c index 2aba043381..9d331d0d81 100644 --- a/htl/pt-exit.c +++ b/htl/pt-exit.c @@ -25,7 +25,7 @@ #include #include - +#include /* Terminate the current thread and make STATUS available to any thread that might join it. */ @@ -112,4 +112,9 @@ __pthread_exit (void *status) abort (); } -weak_alias (__pthread_exit, pthread_exit); +libc_hidden_def (__pthread_exit) +versioned_symbol (libc, __pthread_exit, pthread_exit, GLIBC_2_21); + +#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_21) +compat_symbol (libpthread, __pthread_exit, pthread_exit, GLIBC_2_12); +#endif diff --git a/htl/pt-initialize.c b/htl/pt-initialize.c index b4e8b15b47..a4e49edfa6 100644 --- a/htl/pt-initialize.c +++ b/htl/pt-initialize.c @@ -27,7 +27,6 @@ #if IS_IN (libpthread) static const struct pthread_functions pthread_functions = { - .ptr___pthread_exit = __pthread_exit, .ptr__IO_flockfile = _cthreads_flockfile, .ptr__IO_funlockfile = _cthreads_funlockfile, .ptr__IO_ftrylockfile = _cthreads_ftrylockfile, diff --git a/htl/pt-setcancelstate.c b/htl/pt-setcancelstate.c index 0d5692e661..d1f14de854 100644 --- a/htl/pt-setcancelstate.c +++ b/htl/pt-setcancelstate.c @@ -45,7 +45,7 @@ __pthread_setcancelstate (int state, int *oldstate) p->cancel_pending = 2; __pthread_mutex_unlock (&p->cancel_lock); - if (cancelled && __pthread_exit) + if (cancelled) __pthread_exit (PTHREAD_CANCELED); return 0; diff --git a/htl/pt-setcanceltype.c b/htl/pt-setcanceltype.c index b33931c468..73aac5fd3c 100644 --- a/htl/pt-setcanceltype.c +++ b/htl/pt-setcanceltype.c @@ -42,7 +42,7 @@ __pthread_setcanceltype (int type, int *oldtype) cancelled = (p->cancel_state == PTHREAD_CANCEL_ENABLE) && p->cancel_pending && (p->cancel_type == PTHREAD_CANCEL_ASYNCHRONOUS); __pthread_mutex_unlock (&p->cancel_lock); - if (cancelled && __pthread_exit) + if (cancelled) __pthread_exit (PTHREAD_CANCELED); return 0; diff --git a/sysdeps/htl/pthread-functions.h b/sysdeps/htl/pthread-functions.h index aec13a6022..1fde0aeaa3 100644 --- a/sysdeps/htl/pthread-functions.h +++ b/sysdeps/htl/pthread-functions.h @@ -21,8 +21,6 @@ #include -void __pthread_exit (void *) __attribute__ ((__noreturn__)); - void _cthreads_flockfile (FILE *); void _cthreads_funlockfile (FILE *); int _cthreads_ftrylockfile (FILE *); @@ -32,7 +30,6 @@ int _cthreads_ftrylockfile (FILE *); so if possible avoid breaking it and append new hooks to the end. */ struct pthread_functions { - void (*ptr___pthread_exit) (void *) __attribute__ ((__noreturn__)); void (*ptr__IO_flockfile) (FILE *); void (*ptr__IO_funlockfile) (FILE *); int (*ptr__IO_ftrylockfile) (FILE *); diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h index 98850e9f1d..e0f0f7d45d 100644 --- a/sysdeps/htl/pthreadP.h +++ b/sysdeps/htl/pthreadP.h @@ -182,6 +182,7 @@ void __cthread_detach (__cthread_t); int __pthread_detach (pthread_t __threadp); libc_hidden_proto (__pthread_detach) void __pthread_exit (void *value) __attribute__ ((__noreturn__)); +libc_hidden_proto (__pthread_exit) int __pthread_join (pthread_t, void **); int __cthread_keycreate (__cthread_key_t *); int __cthread_getspecific (__cthread_key_t, void **); @@ -233,14 +234,6 @@ libc_hidden_proto (__pthread_get_cleanup_stack) hidden_proto (__pthread_create) #endif -#if !defined(__NO_WEAK_PTHREAD_ALIASES) && !IS_IN (libpthread) -# ifdef weak_extern -weak_extern (__pthread_exit) -# else -# pragma weak __pthread_exit -# endif -#endif - #define ASSERT_TYPE_SIZE(type, size) \ _Static_assert (sizeof (type) == size, \ "sizeof (" #type ") != " #size) diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index da2ad4ae66..2ec557b26d 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -75,6 +75,7 @@ GLIBC_2.12 pthread_condattr_setclock F GLIBC_2.12 pthread_condattr_setpshared F GLIBC_2.12 pthread_detach F GLIBC_2.12 pthread_equal F +GLIBC_2.12 pthread_exit F GLIBC_2.12 pthread_getattr_np F GLIBC_2.12 pthread_getconcurrency F GLIBC_2.12 pthread_getcpuclockid F diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist index 094f7de25f..3f3c17c15e 100644 --- a/sysdeps/mach/hurd/i386/libpthread.abilist +++ b/sysdeps/mach/hurd/i386/libpthread.abilist @@ -19,7 +19,6 @@ GLIBC_2.12 ftrylockfile F GLIBC_2.12 funlockfile F GLIBC_2.12 pthread_atfork F GLIBC_2.12 pthread_create F -GLIBC_2.12 pthread_exit F GLIBC_2.12 pthread_join F GLIBC_2.12 pthread_spin_destroy F GLIBC_2.12 pthread_spin_init F diff --git a/sysdeps/mach/hurd/x86_64/libpthread.abilist b/sysdeps/mach/hurd/x86_64/libpthread.abilist index 926d31b9cf..6dfca3f44d 100644 --- a/sysdeps/mach/hurd/x86_64/libpthread.abilist +++ b/sysdeps/mach/hurd/x86_64/libpthread.abilist @@ -37,7 +37,6 @@ GLIBC_2.38 mtx_trylock F GLIBC_2.38 mtx_unlock F GLIBC_2.38 pthread_clockjoin_np F GLIBC_2.38 pthread_create F -GLIBC_2.38 pthread_exit F GLIBC_2.38 pthread_hurd_cond_timedwait_np F GLIBC_2.38 pthread_hurd_cond_wait_np F GLIBC_2.38 pthread_join F