From patchwork Sat Sep 21 13:20:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1988142 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=HFz6jnou; 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 4X9qhJ5H2Hz1xrD for ; Sat, 21 Sep 2024 23:23:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6805E385840B for ; Sat, 21 Sep 2024 13:23:26 +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 ESMTP id 8087B3858D39 for ; Sat, 21 Sep 2024 13:23:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8087B3858D39 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 8087B3858D39 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=1726924987; cv=none; b=n5S/8jhoIh45lMVWqDLpQLGBgOrzF1PFEL72PtOQhrqfVbUricsdw27L7lQwDONpWeccYgj72fGU7UkP0Bik+HfZ7eZYRYep8RJEx9obPTec32iZchVLPKlYc3B7pl/F8gKA2dKCtnI0ZVKyCm1EOsc+mW1Gdm2l/yYuhOZ5nFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726924987; c=relaxed/simple; bh=yLY7pl1HfGP/LqZkRi54c/4bvALblqNUkI6mpuCwSig=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=VNVwIhoADOMWMFCLRpQkKU0H9kYu0v04GzE4MI9KyUFpFSlyGszSKgXA4DOErSYGWs2FR7OY3mDE0xs3xiYR2ChoOpJ0PEWbO1J/V0YdXFEd4njUOh3ApTE2zyXwUjZSV8Tn+ucjoYg6odDybiwgsv+3ctFaUQZhG2TrWMK8mVU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726924984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=BlJZggmkU5GKzEG1ZjCgYU2gBn+niV+G59kp3KZeHzw=; b=HFz6jnouHyQ0GKLM4c10mbAV0nbVGtIJuKwZzVkwTEKGlC/uSs0VoqyHRwu9JT4W44j2Hd ZnXHPTyGSfG7q9/cYv59t/7LgY7XM8cOX+/noX/uhzTWtYwF4pa+/ga77dN5c8AEHCFE4Y A7cdQuo8CIyN1MjXh1+Gl3K2EXUU6Ps= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-582-IG2-uOr2PvCVOwbgrxpp3g-1; Sat, 21 Sep 2024 09:23:02 -0400 X-MC-Unique: IG2-uOr2PvCVOwbgrxpp3g-1 Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-7cd9ac1fa89so3562786a12.1 for ; Sat, 21 Sep 2024 06:23:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726924981; x=1727529781; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BlJZggmkU5GKzEG1ZjCgYU2gBn+niV+G59kp3KZeHzw=; b=VhcKzY3w/XIdgPqmpKmJe1R5ElLU/agJYWcaXjHRBiV+awbnJIHweCcoT3SXYXh38L gTh4HB9tX6muNgj3lgyG32az/43iXtui734zjvVDzsZom/V+EyFVKmDsk7MoCkbD8+2g dgTANjJsir0wdHF2GJNEZKJnuyvyEhERMLMbewEELBzRIESzxu41OcAvvVP9eLBYqGTU YdmPcHQaqyyc/VWj9lIaCGaQ4U/pG8LIg9pFUqbH8AI0bdC91iF3nF2w2Jj1J5pxW6Yp k7FCuNWQ4kKTx8/gSpFw5yAqEa+kCUnbJsj20+GIDtNaqFmcmBtZ2SssXUlYhT+OWI8+ nxcg== X-Gm-Message-State: AOJu0YwjSv/qAvkfhYyEKThqIfnpZUu0kplpwPbFfFnvDB4asMLJVPSC VzHUlqT4bIH91SItte/+JDymRK/OHZdJOjElvCByZJw8Rtkg+L96IZwEhhHF7HP3qF6iqm/C/BM SSTQ0952rBtRaWUIPRD45/YSuGGFMqWAbzGa4C96LuEXMDoP8OpFZtAJtd1TdM2pDuz2D9V2zLg iP9BKEvUfoCPZIyFB0Il/uAbW0ex6SesY7rgQ= X-Received: by 2002:a17:90a:8d17:b0:2d8:7a29:838f with SMTP id 98e67ed59e1d1-2dd80c19a2bmr8423980a91.10.1726924981316; Sat, 21 Sep 2024 06:23:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoR3/YL1URb8RHsyev0MtxgPTFvv/jDleK66JurckV+cKQ+UAA8R28SGLKme+TcvFtusuvuQ== X-Received: by 2002:a17:90a:8d17:b0:2d8:7a29:838f with SMTP id 98e67ed59e1d1-2dd80c19a2bmr8423951a91.10.1726924980829; Sat, 21 Sep 2024 06:23:00 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dd7f877e08sm3875032a91.24.2024.09.21.06.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Sep 2024 06:23:00 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org Subject: [PATCH] libstdc++: operator new/delete are transaction_safe Date: Sat, 21 Sep 2024 09:20:56 -0400 Message-ID: <20240921132253.934099-1-jason@redhat.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 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 Tested x86_64-pc-linux-gnu, OK for trunk? -- 8< -- With the changes to #pragma system_header, g++.dg/tm/pr46270.C was failing because didn't implement the N4514 change to [new.delete] that says "The library versions of the global allocation and deallocation functions are declared transaction_safe (8.3.5 dcl.fct)." We already have the _GLIBCXX_TXN_SAFE macro, just need to add it. libstdc++-v3/ChangeLog: * libsupc++/new: Add _GLIBCXX_TXN_SAFE. --- libstdc++-v3/libsupc++/new | 56 ++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 18 deletions(-) base-commit: 2484ba167e1c4a52d4989b71e1f5d4d27755500f diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new index 7e1eee8f9d6..e9a3d9b49a3 100644 --- a/libstdc++-v3/libsupc++/new +++ b/libstdc++-v3/libsupc++/new @@ -134,49 +134,63 @@ namespace std * Placement new and delete signatures (take a memory address argument, * does nothing) may not be replaced by a user's program. */ -_GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) +_GLIBCXX_NODISCARD void* operator new(std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_THROW (std::bad_alloc) __attribute__((__externally_visible__)); -_GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) +_GLIBCXX_NODISCARD void* operator new[](std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_THROW (std::bad_alloc) __attribute__((__externally_visible__)); -void operator delete(void*) _GLIBCXX_USE_NOEXCEPT +void operator delete(void*) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT +void operator delete[](void*) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #if __cpp_sized_deallocation -void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT +void operator delete(void*, std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT +void operator delete[](void*, std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #endif -_GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +_GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -_GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +_GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +void operator delete(void*, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +void operator delete[](void*, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #if __cpp_aligned_new _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) + _GLIBCXX_TXN_SAFE __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -void operator delete(void*, std::align_val_t) +void operator delete(void*, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void operator delete(void*, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) + _GLIBCXX_TXN_SAFE __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -void operator delete[](void*, std::align_val_t) +void operator delete[](void*, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void operator delete[](void*, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #if __cpp_sized_deallocation -void operator delete(void*, std::size_t, std::align_val_t) +void operator delete(void*, std::size_t, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*, std::size_t, std::align_val_t) +void operator delete[](void*, std::size_t, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #endif // __cpp_sized_deallocation #endif // __cpp_aligned_new @@ -189,17 +203,23 @@ void operator delete[](void*, std::size_t, std::align_val_t) // Default placement versions of operator new. _GLIBCXX_NODISCARD _GLIBCXX_PLACEMENT_CONSTEXPR -void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT +void* operator new(std::size_t, void* __p) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT { return __p; } _GLIBCXX_NODISCARD _GLIBCXX_PLACEMENT_CONSTEXPR -void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT +void* operator new[](std::size_t, void* __p) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT { return __p; } #undef _GLIBCXX_PLACEMENT_CONSTEXPR // Default placement versions of operator delete. -inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } -inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } +inline void operator delete (void*, void*) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT +{ } +inline void operator delete[](void*, void*) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT +{ } //@} } // extern "C++"