From patchwork Thu Aug 1 21:11:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1968044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TeUTiqPE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WZhYL6Qdtz1yZl for ; Fri, 2 Aug 2024 07:14:30 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6331C3858D20 for ; Thu, 1 Aug 2024 21:14:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 685AF386101E for ; Thu, 1 Aug 2024 21:12:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 685AF386101E 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 685AF386101E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722546771; cv=none; b=HqlrxtYVLv+PRn1x6E1BnygoT5T76tA7q1cN3Lc6xVaAnFCOjxgohuhUYftZ5g+AduzgTPK65WKNA8nQ79dfgkIshXHRr4F1hSbcDeQzo973txg+29iuRMjF5CfftNn0NILKEpobZBGFyJi6Nc7NP2ZlaZz3O2uHmLvHuihGDTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722546771; c=relaxed/simple; bh=Vo6Jsxgb+Sw+eqr3gKlWT9tnm5t01oj3ONNqCIzVFiY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wAcIc0jSRfDeFrghrivx2ZoH/WXfjGKnIfrJIDom+D7zYOZrBH3vrC5O3yiuOGKZGlbwUkG9hMXaSbfC0adtAN1zhj1+OPQG8Q8tYkOT0Zi9K6x5+bIH4TzgD492ZG597b3qi3ZlxXjL/0qOqSmVGAdUXapUevPGCqt0v+qXoR4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722546769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1y2yX0jQvWCp9BA5YaoPn4p/3VfYQIvYtbjVDYqhT7M=; b=TeUTiqPEnDLJaFtMwb11obxW02YfysE/JRObmNeDqtZ8scTJlTNBPYMg9JK8T9y+suycmh 6Tfrky8Cx+0/zN6f7LgSKd/+QhXqTLhAiHMoyXrThLkYdKw9oR7fUthW27ljmFXiIxFKJA ifx3OdYMRGFYoC9NNRcXusFPuoMoyd4= Received: from mx-prod-mc-02.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-407-C5vwtTkUOZmmEwonsssjMA-1; Thu, 01 Aug 2024 17:12:47 -0400 X-MC-Unique: C5vwtTkUOZmmEwonsssjMA-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2FAB31955F3D; Thu, 1 Aug 2024 21:12:46 +0000 (UTC) Received: from localhost (unknown [10.42.28.21]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 677E31955D42; Thu, 1 Aug 2024 21:12:45 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Remove unnecessary uses of Date: Thu, 1 Aug 2024 22:11:59 +0100 Message-ID: <20240801211243.386472-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org This will probably need a gcc-15/porting_to.html entry at some point. Every time we remove transitive includes of it breaks somebody! Tested x86_64-linux. Pushed to trunk. -- >8 -- We don't need to include all of when we only need uintptr_t from it. By using GCC's internal macro we avoid unnecessarily declaring everything in . This helps users to avoid accidentally relying on those names being declared without explicitly including the header. libstdc++-v3/ChangeLog: * include/bits/align.h (align, assume_aligned): Use __UINTPTR_TYPE__ instead of uintptr_t. Do not include . * include/bits/atomic_base.h (__atomic_ref): Likewise. * include/bits/atomic_wait.h (__waiter_pool_base::_S_for): Likewise. * include/std/atomic: Include . --- libstdc++-v3/include/bits/align.h | 5 ++--- libstdc++-v3/include/bits/atomic_base.h | 17 ++++++++++++----- libstdc++-v3/include/bits/atomic_wait.h | 4 ++-- libstdc++-v3/include/std/atomic | 1 + 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libstdc++-v3/include/bits/align.h b/libstdc++-v3/include/bits/align.h index 1a06b814fbb..0c64584b27f 100644 --- a/libstdc++-v3/include/bits/align.h +++ b/libstdc++-v3/include/bits/align.h @@ -31,7 +31,6 @@ #define _GLIBCXX_ALIGN_H 1 #include // std::has_single_bit -#include // uintptr_t #include // _GLIBCXX_DEBUG_ASSERT #include @@ -62,7 +61,7 @@ align(size_t __align, size_t __size, void*& __ptr, size_t& __space) noexcept { if (__space < __size) return nullptr; - const auto __intptr = reinterpret_cast(__ptr); + const auto __intptr = reinterpret_cast<__UINTPTR_TYPE__>(__ptr); const auto __aligned = (__intptr - 1u + __align) & -__align; const auto __diff = __aligned - __intptr; if (__diff > (__space - __size)) @@ -97,7 +96,7 @@ align(size_t __align, size_t __size, void*& __ptr, size_t& __space) noexcept { // This function is expected to be used in hot code, where // __glibcxx_assert would add unwanted overhead. - _GLIBCXX_DEBUG_ASSERT((uintptr_t)__ptr % _Align == 0); + _GLIBCXX_DEBUG_ASSERT((__UINTPTR_TYPE__)__ptr % _Align == 0); return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Align)); } } diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index ae6819f119b..7c27bd8c951 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -34,7 +34,6 @@ #include #include // For placement new -#include #include #include @@ -1504,7 +1503,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit __atomic_ref(_Tp& __t) : _M_ptr(std::__addressof(__t)) - { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + { + __glibcxx_assert(((__UINTPTR_TYPE__)_M_ptr % required_alignment) == 0); + } __atomic_ref(const __atomic_ref&) noexcept = default; @@ -1615,7 +1616,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit __atomic_ref(_Tp& __t) : _M_ptr(&__t) - { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + { + __glibcxx_assert(((__UINTPTR_TYPE__)_M_ptr % required_alignment) == 0); + } __atomic_ref(const __atomic_ref&) noexcept = default; @@ -1788,7 +1791,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit __atomic_ref(_Fp& __t) : _M_ptr(&__t) - { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + { + __glibcxx_assert(((__UINTPTR_TYPE__)_M_ptr % required_alignment) == 0); + } __atomic_ref(const __atomic_ref&) noexcept = default; @@ -1915,7 +1920,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit __atomic_ref(_Tp*& __t) : _M_ptr(std::__addressof(__t)) - { __glibcxx_assert(((uintptr_t)_M_ptr % required_alignment) == 0); } + { + __glibcxx_assert(((__UINTPTR_TYPE__)_M_ptr % required_alignment) == 0); + } __atomic_ref(const __atomic_ref&) noexcept = default; diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h index 6c98f3963ad..f1c183f9dbb 100644 --- a/libstdc++-v3/include/bits/atomic_wait.h +++ b/libstdc++-v3/include/bits/atomic_wait.h @@ -250,9 +250,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static __waiter_pool_base& _S_for(const void* __addr) noexcept { - constexpr uintptr_t __ct = 16; + constexpr __UINTPTR_TYPE__ __ct = 16; static __waiter_pool_base __w[__ct]; - auto __key = (uintptr_t(__addr) >> 2) % __ct; + auto __key = ((__UINTPTR_TYPE__)__addr >> 2) % __ct; return __w[__key]; } }; diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index 1462cf5ec23..36ff89a146c 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -48,6 +48,7 @@ #include #include +#include namespace std _GLIBCXX_VISIBILITY(default) {