From patchwork Sun Nov 11 22:35:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 996200 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-489670-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=axis.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="qCP892ux"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42tTHn30CMz9sR1 for ; Mon, 12 Nov 2018 09:35:46 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=NbEdmKQIXYRSexi+ +/CgZG/meqKCW3MiYDKUe7VJM/xAqHsdB1btrurdeNc1m5raNUUjF6URbtIj1vQB BHg/DFr2dIw1JTqEQ2ZeExXWBG9N1n/F2QIXwk14KjO9RUBd95xtev7ZYdJ0fnIA 2jHEfFoDjk+JmJr5ZTPaoE6Biyg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject:mime-version:content-type :content-transfer-encoding; s=default; bh=VGFgtBL2fdRygk2QSIhPhu cd6cM=; b=qCP892uxDR43zzCQfAFy/UpZtn0IzBzz2w32KYYjdue9iPNuNaPhm/ jjuhc9hLTNNLzuN31XjjJrWFea6im/KI+V4siw2OZX0kJNIeXGTWkeyU3/E2KrOj WkgsYNFGUJkqVoCekZYe0opRApjkaycZdUJ/qDfbNgbne+eqBxvII= Received: (qmail 58605 invoked by alias); 11 Nov 2018 22:35:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 58585 invoked by uid 89); 11 Nov 2018 22:35:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HP, Better, alignas, hp X-HELO: bastet.se.axis.com Received: from bastet.se.axis.com (HELO bastet.se.axis.com) (195.60.68.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 11 Nov 2018 22:35:34 +0000 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 6BEE118305; Sun, 11 Nov 2018 23:35:31 +0100 (CET) Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id IDk9rael-RAg; Sun, 11 Nov 2018 23:35:30 +0100 (CET) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id C593A18136; Sun, 11 Nov 2018 23:35:30 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB1451A05D; Sun, 11 Nov 2018 23:35:30 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9FF461A05C; Sun, 11 Nov 2018 23:35:30 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder02.se.axis.com (Postfix) with ESMTP; Sun, 11 Nov 2018 23:35:30 +0100 (CET) Received: from ignucius.se.axis.com (ignucius.se.axis.com [10.88.21.50]) by thoth.se.axis.com (Postfix) with ESMTP id 932C72EE8; Sun, 11 Nov 2018 23:35:30 +0100 (CET) Received: from ignucius.se.axis.com (localhost [127.0.0.1]) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) with ESMTP id wABMZUmr005086; Sun, 11 Nov 2018 23:35:30 +0100 Received: (from hp@localhost) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) id wABMZUrD005082; Sun, 11 Nov 2018 23:35:30 +0100 Date: Sun, 11 Nov 2018 23:35:30 +0100 Message-Id: <201811112235.wABMZUrD005082@ignucius.se.axis.com> From: Hans-Peter Nilsson To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: libstdc++ PR54005M is_lock_free; consistently avoid referring to object MIME-Version: 1.0 This patch should have no visible effect. It was approved in the BZ and is what remains of PR54005. _M_i is declared "alignas(_S_alignment) _Tp _M_i;" and is_lock_free is supposed to refer to the *type* not the specific *object*. (Note how the actual address of the object is not used in the __atomic_is_lock_free call.) Better then also not refer to the object indirectly like that, even though the alignas-declaration *should* make it the same number. Now I don't have to write tests to assert that being true. For an earlier version that also replaced __atomic_is_lock_free with __atomic_always_lock_free I wrote some tests that are posted in the PR, but as they aren't related to the effect of the patch anymore, it doesn't seem useful to add them. Belatedly committed. PR libstdc++-v3/54005 * include/bits/atomic_base.h (__atomic_base<_TTp>::is_lock_free(), __atomic_base<_PTp*>::is_lock_free()): Call __atomic_is_lock_free with the type-derived _S_alignment instead of __alignof the object. * include/std/atomic (atomic::is_lock_free()): Likewise. brgds, H-P Index: libstdc++-v3/include/std/atomic =================================================================== --- libstdc++-v3/include/std/atomic (revision 265027) +++ libstdc++-v3/include/std/atomic (working copy) @@ -222,7 +222,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // Produce a fake, minimally aligned pointer. return __atomic_is_lock_free(sizeof(_M_i), - reinterpret_cast(-__alignof(_M_i))); + reinterpret_cast(-_S_alignment)); } bool @@ -230,7 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // Produce a fake, minimally aligned pointer. return __atomic_is_lock_free(sizeof(_M_i), - reinterpret_cast(-__alignof(_M_i))); + reinterpret_cast(-_S_alignment)); } #if __cplusplus >= 201703L Index: libstdc++-v3/include/bits/atomic_base.h =================================================================== --- libstdc++-v3/include/bits/atomic_base.h (revision 265027) +++ libstdc++-v3/include/bits/atomic_base.h (working copy) @@ -355,7 +355,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // Use a fake, minimally aligned pointer. return __atomic_is_lock_free(sizeof(_M_i), - reinterpret_cast(-__alignof(_M_i))); + reinterpret_cast(-_S_alignment)); } bool @@ -363,7 +363,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { // Use a fake, minimally aligned pointer. return __atomic_is_lock_free(sizeof(_M_i), - reinterpret_cast(-__alignof(_M_i))); + reinterpret_cast(-_S_alignment)); } _GLIBCXX_ALWAYS_INLINE void