From patchwork Tue Feb 27 11:42:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 86439 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 9E28A3858C35 for ; Tue, 27 Feb 2024 11:50:37 +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.133.124]) by sourceware.org (Postfix) with ESMTPS id EBE6A3858292 for ; Tue, 27 Feb 2024 11:45:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EBE6A3858292 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 EBE6A3858292 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=1709034342; cv=none; b=JIp9rlp6dAxv6ggIBel4wSuymOGDJA9L8rrAFiZzKvE3KLl6ffEgGzYdTv1DybdR/IVqRWCYr8w3JGSli9gDa+rLFafigL43XUC7WvvB5Kk5KkGQXJr64yI9dKE0pp9MP3iGDxs0OPvSAkjK8bEQbMwBKzsTpt/h76fwMDuGr7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709034342; c=relaxed/simple; bh=nI+hQJIGoxfPmppy51RRDZqSU5rNq3wpxDFYUEXidVY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tJKubrup/qx7WLfnbwQM1nb+JGtysDtag07G4p5RPjDPgCFJlnl1h9/xXUaRP7zzxrZyF/ovZuJhPfAv+unRdfLw0/ujYY22ns7XsbGWrUFc0DVJqCBNUDqQcoXekPl+uILroJavGYeSeDykht3O9nad8FAfbYCNT5jOp51nJX8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709034338; 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=KpZ/mnAwGB0Zt+fNe62/bM2BnZxfEbHV8c/tiTBzONA=; b=O5RsL5X70EGM05u9+nJaEMXGtRq8lG/QewBQrpjJtDqWwmZDIxc2kt7NC8GkFasiIVEG9b EaDGvZ+XIAuD1SflplsYBV/Yf4CKXzTBd2q93trK3qF5/jbeDh9zJc2yuRpm62DFcQhMZu tSRVmXv1Bc4MQI9VTLOE8btGNYgl7BI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-350-ZUDFVj85NwuOgrGPWtLHRg-1; Tue, 27 Feb 2024 06:45:35 -0500 X-MC-Unique: ZUDFVj85NwuOgrGPWtLHRg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F88388B760; Tue, 27 Feb 2024 11:45:35 +0000 (UTC) Received: from localhost (unknown [10.42.28.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DB0E40C122C; Tue, 27 Feb 2024 11:45:35 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH 8/8] libstdc++: Do not define lock-free atomic aliases if not fully lock-free [PR114103] Date: Tue, 27 Feb 2024 11:42:05 +0000 Message-ID: <20240227114528.1350601-8-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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+patchwork=sourceware.org@gcc.gnu.org Tested x86_64-linux. I think we should make this change, because otherwise we define the typedefs for platforms with no lock-free atomics, like hppa-hpux. Instead of lying, those typedefs should be absent on that target. -- >8 -- libstdc++-v3/ChangeLog: PR libstdc++/114103 * include/bits/version.def (atomic_lock_free_type_aliases): Add extra_cond to check for at least one always-lock-free type. * include/bits/version.h: Regenerate. * include/std/atomic (atomic_signed_lock_free) (atomic_unsigned_lock_free): Only use always-lock-free types. --- libstdc++-v3/include/bits/version.def | 1 + libstdc++-v3/include/bits/version.h | 2 +- libstdc++-v3/include/std/atomic | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index 502961eb269..d298420121b 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -739,6 +739,7 @@ ftms = { values = { v = 201907; cxxmin = 20; + extra_cond = "(__GCC_ATOMIC_INT_LOCK_FREE | __GCC_ATOMIC_LONG_LOCK_FREE | __GCC_ATOMIC_CHAR_LOCK_FREE) & 2"; }; }; diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index 7a6fbd35e2e..9107b45a484 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -819,7 +819,7 @@ #undef __glibcxx_want_atomic_float #if !defined(__cpp_lib_atomic_lock_free_type_aliases) -# if (__cplusplus >= 202002L) +# if (__cplusplus >= 202002L) && ((__GCC_ATOMIC_INT_LOCK_FREE | __GCC_ATOMIC_LONG_LOCK_FREE | __GCC_ATOMIC_CHAR_LOCK_FREE) & 2) # define __glibcxx_atomic_lock_free_type_aliases 201907L # if defined(__glibcxx_want_all) || defined(__glibcxx_want_atomic_lock_free_type_aliases) # define __cpp_lib_atomic_lock_free_type_aliases 201907L diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index 559f8370459..1462cf5ec23 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -1774,13 +1774,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION = atomic>; using atomic_unsigned_lock_free = atomic>; -# elif ATOMIC_INT_LOCK_FREE || !(ATOMIC_LONG_LOCK_FREE || ATOMIC_CHAR_LOCK_FREE) +# elif ATOMIC_INT_LOCK_FREE == 2 using atomic_signed_lock_free = atomic; using atomic_unsigned_lock_free = atomic; -# elif ATOMIC_LONG_LOCK_FREE +# elif ATOMIC_LONG_LOCK_FREE == 2 using atomic_signed_lock_free = atomic; using atomic_unsigned_lock_free = atomic; -# elif ATOMIC_CHAR_LOCK_FREE +# elif ATOMIC_CHAR_LOCK_FREE == 2 using atomic_signed_lock_free = atomic; using atomic_unsigned_lock_free = atomic; # else