From patchwork Fri Dec 20 06:16:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 103489 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 55F443858C60 for ; Fri, 20 Dec 2024 06:17:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55F443858C60 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=N+82zzAj X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id C0FA73858D3C for ; Fri, 20 Dec 2024 06:16:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C0FA73858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C0FA73858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734675381; cv=none; b=qwqyPKIUsLZNN21p+sNEnb5XMEtx0lqO9c6E3CyNf4G0aKlK4oMqcFQ5PGqnEUJSQ57FR0WEJXfVlW+TOdj/BvUqlW3NqKNtse1z8XLTYMAMuotPRfhqZCtlXHRXpzc2Ep4s7/YPMO/77v+8SpLM7c98wUcuqexkLTc8CQPz4ts= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734675381; c=relaxed/simple; bh=lF0/bll2r7KpB4ZO92alWErSBMMZayzgHEj9m8anO+Q=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=iEj/wYTFSdqw07kWecJ367VbCi9j5sB1e0SK42mFr2L23/0wqeUijJhpYC1WI93g6wOLgO5LT8NVy52PYyBJOQF/4AWw+NigxNDXB5RH5h6mdhyHRl431UHLuav5jDKBGfnjhlfzTJvyk3y4/YVSnvzhL3W/Y5KCyB9R6aTqP+E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C0FA73858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734675381; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YPtSiH+9PMv85l0UETif+bNVf17/F3zoPXeNT8YHjOI=; b=N+82zzAjSTMlOESI6TmD1V5/Tdzw3bqY40B8BtTpV35e4cgGDw877idnzkHazOW6+XIofI rbnZlaQXt866ajUmkG4nhRMjsKPElv9KZxlvxGvDwKlEqUA7AuJXjkTkrJ04c1Aqar/wUz XuPue9jWXZiXuTZVB96dFR3ELCokk3U= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-e_MjzMa0M9aU3g7CLDAI2w-1; Fri, 20 Dec 2024 01:16:20 -0500 X-MC-Unique: e_MjzMa0M9aU3g7CLDAI2w-1 X-Mimecast-MFC-AGG-ID: e_MjzMa0M9aU3g7CLDAI2w Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 395001956096 for ; Fri, 20 Dec 2024 06:16:19 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 44D0E19560A2 for ; Fri, 20 Dec 2024 06:16:17 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v2 1/4] Remove In-Reply-To: Message-ID: <952160066e42492443d0e2e47fa334024f16886c.1734675268.git.fweimer@redhat.com> References: X-From-Line: 952160066e42492443d0e2e47fa334024f16886c Mon Sep 17 00:00:00 2001 Date: Fri, 20 Dec 2024 07:16:15 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MmCWE73aeGCLK5aJNurhuqjolbEHzU7QPUyP0ocZF0c_1734675379 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 Use __thread variables directly instead. The macros do not save any typing. It seems unlikely that a future port will lack __thread variable support. Some of the __libc_tsd_* variables are referenced from assembler files, so keep their names. Previously, included , which in turn included , so a few direct includes of are now required. --- ctype/ctype-info.c | 18 +++++------ include/ctype.h | 13 ++++---- include/rpc/rpc.h | 4 +-- locale/lc-ctype.c | 9 ++---- locale/localeinfo.h | 6 ++-- locale/uselocale.c | 10 +++--- stdio-common/printf-parsemb.c | 1 + string/strerror.c | 2 +- sunrpc/rpc_thread.c | 1 - sysdeps/generic/libc-tsd.h | 60 ----------------------------------- time/strftime_l.c | 1 + 11 files changed, 28 insertions(+), 97 deletions(-) delete mode 100644 sysdeps/generic/libc-tsd.h diff --git a/ctype/ctype-info.c b/ctype/ctype-info.c index 9032547567..71d1c8e3b4 100644 --- a/ctype/ctype-info.c +++ b/ctype/ctype-info.c @@ -19,20 +19,20 @@ #include #include -__libc_tsd_define (, const uint16_t *, CTYPE_B) -__libc_tsd_define (, const int32_t *, CTYPE_TOLOWER) -__libc_tsd_define (, const int32_t *, CTYPE_TOUPPER) +__thread const uint16_t * __libc_tsd_CTYPE_B; +__thread const int32_t * __libc_tsd_CTYPE_TOLOWER; +__thread const int32_t * __libc_tsd_CTYPE_TOUPPER; void __ctype_init (void) { - const uint16_t **bp = __libc_tsd_address (const uint16_t *, CTYPE_B); - *bp = (const uint16_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS) + 128; - const int32_t **up = __libc_tsd_address (const int32_t *, CTYPE_TOUPPER); - *up = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER) + 128); - const int32_t **lp = __libc_tsd_address (const int32_t *, CTYPE_TOLOWER); - *lp = ((int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER) + 128); + __libc_tsd_CTYPE_B + = ((const uint16_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_CLASS)) + 128; + __libc_tsd_CTYPE_TOUPPER + = ((const int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOUPPER)) + 128; + __libc_tsd_CTYPE_TOLOWER = + ((const int32_t *) _NL_CURRENT (LC_CTYPE, _NL_CTYPE_TOLOWER)) + 128; } libc_hidden_def (__ctype_init) diff --git a/include/ctype.h b/include/ctype.h index 493a6f80ce..e993adc86d 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -24,33 +24,32 @@ libc_hidden_proto (toupper) NL_CURRENT_INDIRECT. */ # include "../locale/localeinfo.h" -# include # ifndef CTYPE_EXTERN_INLINE /* Used by ctype/ctype-info.c, which see. */ # define CTYPE_EXTERN_INLINE extern inline # endif -__libc_tsd_define (extern, const uint16_t *, CTYPE_B) -__libc_tsd_define (extern, const int32_t *, CTYPE_TOUPPER) -__libc_tsd_define (extern, const int32_t *, CTYPE_TOLOWER) +extern __thread const uint16_t * __libc_tsd_CTYPE_B; +extern __thread const int32_t * __libc_tsd_CTYPE_TOUPPER; +extern __thread const int32_t * __libc_tsd_CTYPE_TOLOWER; CTYPE_EXTERN_INLINE const uint16_t ** __attribute__ ((const)) __ctype_b_loc (void) { - return __libc_tsd_address (const uint16_t *, CTYPE_B); + return &__libc_tsd_CTYPE_B; } CTYPE_EXTERN_INLINE const int32_t ** __attribute__ ((const)) __ctype_toupper_loc (void) { - return __libc_tsd_address (const int32_t *, CTYPE_TOUPPER); + return &__libc_tsd_CTYPE_TOUPPER; } CTYPE_EXTERN_INLINE const int32_t ** __attribute__ ((const)) __ctype_tolower_loc (void) { - return __libc_tsd_address (const int32_t *, CTYPE_TOLOWER); + return &__libc_tsd_CTYPE_TOLOWER; } # ifndef __NO_CTYPE diff --git a/include/rpc/rpc.h b/include/rpc/rpc.h index f5cee6caef..936ea3cebb 100644 --- a/include/rpc/rpc.h +++ b/include/rpc/rpc.h @@ -3,8 +3,6 @@ # ifndef _ISOMAC -#include - /* Now define the internal interfaces. */ extern unsigned long _create_xid (void); @@ -47,7 +45,7 @@ extern void __rpc_thread_key_cleanup (void) attribute_hidden; extern void __rpc_thread_destroy (void) attribute_hidden; -__libc_tsd_define (extern, struct rpc_thread_variables *, RPC_VARS) +extern __thread struct rpc_thread_variables *__libc_tsd_RPC_VARS; #define RPC_THREAD_VARIABLE(x) (__rpc_thread_variables()->x) diff --git a/locale/lc-ctype.c b/locale/lc-ctype.c index c77ec51cb8..70556acaf0 100644 --- a/locale/lc-ctype.c +++ b/locale/lc-ctype.c @@ -64,12 +64,9 @@ _nl_postload_ctype (void) in fact using the global locale. */ if (_NL_CURRENT_LOCALE == &_nl_global_locale) { - __libc_tsd_set (const uint16_t *, CTYPE_B, - (void *) _nl_global_locale.__ctype_b); - __libc_tsd_set (const int32_t *, CTYPE_TOUPPER, - (void *) _nl_global_locale.__ctype_toupper); - __libc_tsd_set (const int32_t *, CTYPE_TOLOWER, - (void *) _nl_global_locale.__ctype_tolower); + __libc_tsd_CTYPE_B = _nl_global_locale.__ctype_b; + __libc_tsd_CTYPE_TOUPPER = _nl_global_locale.__ctype_toupper; + __libc_tsd_CTYPE_TOLOWER = _nl_global_locale.__ctype_tolower; } #include diff --git a/locale/localeinfo.h b/locale/localeinfo.h index ed698faef1..bc8e92e4dc 100644 --- a/locale/localeinfo.h +++ b/locale/localeinfo.h @@ -236,10 +236,8 @@ extern struct __locale_struct _nl_global_locale attribute_hidden; /* This fetches the thread-local locale_t pointer, either one set with uselocale or &_nl_global_locale. */ -#define _NL_CURRENT_LOCALE (__libc_tsd_get (locale_t, LOCALE)) -#include -__libc_tsd_define (extern, locale_t, LOCALE) - +#define _NL_CURRENT_LOCALE __libc_tsd_LOCALE +extern __thread locale_t __libc_tsd_LOCALE; /* For static linking it is desireable to avoid always linking in the code and data for every category when we can tell at link time that they are diff --git a/locale/uselocale.c b/locale/uselocale.c index 5c7c1ad66b..a2b7a1a522 100644 --- a/locale/uselocale.c +++ b/locale/uselocale.c @@ -34,7 +34,7 @@ __uselocale (locale_t newloc) { const locale_t locobj = newloc == LC_GLOBAL_LOCALE ? &_nl_global_locale : newloc; - __libc_tsd_set (locale_t, LOCALE, locobj); + __libc_tsd_LOCALE = locobj; #ifdef NL_CURRENT_INDIRECT /* Now we must update all the per-category thread-local variables to @@ -62,11 +62,9 @@ __uselocale (locale_t newloc) #endif /* Update the special tsd cache of some locale data. */ - __libc_tsd_set (const uint16_t *, CTYPE_B, (void *) locobj->__ctype_b); - __libc_tsd_set (const int32_t *, CTYPE_TOLOWER, - (void *) locobj->__ctype_tolower); - __libc_tsd_set (const int32_t *, CTYPE_TOUPPER, - (void *) locobj->__ctype_toupper); + __libc_tsd_CTYPE_B = locobj->__ctype_b; + __libc_tsd_CTYPE_TOLOWER = locobj->__ctype_tolower; + __libc_tsd_CTYPE_TOUPPER = locobj->__ctype_toupper; } return oldloc == &_nl_global_locale ? LC_GLOBAL_LOCALE : oldloc; diff --git a/stdio-common/printf-parsemb.c b/stdio-common/printf-parsemb.c index ab9fafb5ec..8db18f11b3 100644 --- a/stdio-common/printf-parsemb.c +++ b/stdio-common/printf-parsemb.c @@ -17,6 +17,7 @@ . */ #include +#include #include #include #include diff --git a/string/strerror.c b/string/strerror.c index 107d9d39c2..efa4e903ea 100644 --- a/string/strerror.c +++ b/string/strerror.c @@ -21,5 +21,5 @@ char * strerror (int errnum) { - return __strerror_l (errnum, __libc_tsd_get (locale_t, LOCALE)); + return __strerror_l (errnum, __libc_tsd_LOCALE); } diff --git a/sunrpc/rpc_thread.c b/sunrpc/rpc_thread.c index a04b7ec47f..e20f0a6230 100644 --- a/sunrpc/rpc_thread.c +++ b/sunrpc/rpc_thread.c @@ -3,7 +3,6 @@ #include #include -#include #include #include diff --git a/sysdeps/generic/libc-tsd.h b/sysdeps/generic/libc-tsd.h deleted file mode 100644 index ac0e99e14b..0000000000 --- a/sysdeps/generic/libc-tsd.h +++ /dev/null @@ -1,60 +0,0 @@ -/* libc-internal interface for thread-specific data. Stub or TLS version. - Copyright (C) 1998-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - 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 - . */ - -#ifndef _GENERIC_LIBC_TSD_H -#define _GENERIC_LIBC_TSD_H 1 - -/* This file defines the following macros for accessing a small fixed - set of thread-specific `void *' data used only internally by libc. - - __libc_tsd_define(CLASS, TYPE, KEY) -- Define or declare a datum with TYPE - for KEY. CLASS can be `static' for - keys used in only one source file, - empty for global definitions, or - `extern' for global declarations. - __libc_tsd_address(TYPE, KEY) -- Return the `TYPE *' pointing to - the current thread's datum for KEY. - __libc_tsd_get(TYPE, KEY) -- Return the `TYPE' datum for KEY. - __libc_tsd_set(TYPE, KEY, VALUE) -- Set the datum for KEY to VALUE. - - The set of available KEY's will usually be provided as an enum, - and contains (at least): - _LIBC_TSD_KEY_MALLOC - _LIBC_TSD_KEY_DL_ERROR - _LIBC_TSD_KEY_RPC_VARS - All uses must be the literal _LIBC_TSD_* name in the __libc_tsd_* macros. - Some implementations may not provide any enum at all and instead - using string pasting in the macros. */ - -#include - -/* When full support for __thread variables is available, this interface is - just a trivial wrapper for it. Without TLS, this is the generic/stub - implementation for wholly single-threaded systems. - - We don't define an enum for the possible key values, because the KEYs - translate directly into variables by macro magic. */ - -#define __libc_tsd_define(CLASS, TYPE, KEY) \ - CLASS __thread TYPE __libc_tsd_##KEY attribute_tls_model_ie; - -#define __libc_tsd_address(TYPE, KEY) (&__libc_tsd_##KEY) -#define __libc_tsd_get(TYPE, KEY) (__libc_tsd_##KEY) -#define __libc_tsd_set(TYPE, KEY, VALUE) (__libc_tsd_##KEY = (VALUE)) - -#endif /* libc-tsd.h */ diff --git a/time/strftime_l.c b/time/strftime_l.c index 77adec9050..066c839c2f 100644 --- a/time/strftime_l.c +++ b/time/strftime_l.c @@ -40,6 +40,7 @@ #endif #include +#include #include /* Some systems define `time_t' here. */ #ifdef TIME_WITH_SYS_TIME