From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 7530E3896824 for ; Thu, 12 Nov 2020 17:27:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7530E3896824 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-361-Ynp8VEIYPCSwg_kcVna2Lw-1; Thu, 12 Nov 2020 12:27:04 -0500 X-MC-Unique: Ynp8VEIYPCSwg_kcVna2Lw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 930B1803F60; Thu, 12 Nov 2020 17:27:03 +0000 (UTC) Received: from localhost (unknown [10.33.36.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1927D19C66; Thu, 12 Nov 2020 17:27:02 +0000 (UTC) Date: Thu, 12 Nov 2020 17:27:02 +0000 From: Jonathan Wakely To: Thomas Rodgers Cc: trodgers@redhat.com, libstdc++ , gcc-patches List Subject: Re: [PATCH] libstdc++: Add support for C++20 barriers Message-ID: <20201112172702.GD503596@redhat.com> References: <20201104172910.3112415-1-rodgert@appliantology.com> <20201104184144.3131153-1-rodgert@appliantology.com> <20201104185259.GD503596@redhat.com> <2D0C6C01-38A5-439C-B72C-4373E1DA1EB1@appliantology.com> MIME-Version: 1.0 In-Reply-To: <2D0C6C01-38A5-439C-B72C-4373E1DA1EB1@appliantology.com> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2020 17:27:11 -0000 On 04/11/20 10:55 -0800, Thomas Rodgers wrote: >>> --- a/libstdc++-v3/include/bits/atomic_base.h >>> +++ b/libstdc++-v3/include/bits/atomic_base.h >>> @@ -603,13 +603,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >>> } >>> >>> #if __cplusplus > 201703L >>> + template >>> + _GLIBCXX_ALWAYS_INLINE void >>> + _M_wait(__int_type __old, const _Func& __fn) const noexcept >>> + { std::__atomic_wait(&_M_i, __old, __fn); } >>> + >>> _GLIBCXX_ALWAYS_INLINE void >>> wait(__int_type __old, >>> memory_order __m = memory_order_seq_cst) const noexcept >>> { >>> - std::__atomic_wait(&_M_i, __old, >>> - [__m, this, __old] >>> - { return this->load(__m) != __old; }); >>> + _M_wait(__old, >>> + [__m, this, __old] >>> + { return this->load(__m) != __old; }); >>> } >> >> This looks like it's not meant to be part of this patch. >> >> It also looks wrong for any patch, because it adds _M_wait as a public >> member. >> >> Not sure what this piece is for :-) >> > >It is used at include/std/barrier:197 to keep the implementation as close as possible to the libc++ version upon which it is based. So the caller in can't use __atomic_wait directly because it can't access the _M_i member of the atomic. Would it be possible to use atomic_ref instead of atomic, so that the barrier code has access to the underlying object and can use it directly with __atomic_wait?