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 2460E3839C79 for ; Thu, 22 Apr 2021 12:27:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2460E3839C79 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-101-yLMaLPMGPjyhd-Frcal5bg-1; Thu, 22 Apr 2021 08:27:43 -0400 X-MC-Unique: yLMaLPMGPjyhd-Frcal5bg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0E6683DD22; Thu, 22 Apr 2021 12:27:41 +0000 (UTC) Received: from localhost (unknown [10.33.36.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49D2F63634; Thu, 22 Apr 2021 12:27:41 +0000 (UTC) Date: Thu, 22 Apr 2021 13:27:40 +0100 From: Jonathan Wakely To: Thomas Rodgers Cc: David Edelsohn , Jakub Jelinek , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: GCC 11.1 Release Candidate available from gcc.gnu.org Message-ID: <20210422122740.GC3008@redhat.com> References: <6ac731c557415b46b04613d9b908df2f@appliantology.com> <45de03629a536c0000c9b47bb79d6601@appliantology.com> <20210421113804.GU3008@redhat.com> <20210421121218.GV3008@redhat.com> <20210421143019.GY3008@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210421143019.GY3008@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="qhD8kUEc5MK9MdKG" Content-Disposition: inline X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, 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, 22 Apr 2021 12:27:50 -0000 --qhD8kUEc5MK9MdKG Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline On 21/04/21 15:30 +0100, Jonathan Wakely wrote: >On 21/04/21 13:12 +0100, Jonathan Wakely wrote: >>On 21/04/21 12:38 +0100, Jonathan Wakely wrote: >>>On 20/04/21 22:12 -0700, Thomas Rodgers wrote: >>>>@@ -86,6 +88,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >>>> } >>>> } >>>> >>>>+ _GLIBCXX_ALWAYS_INLINE bool >>>>+ _M_try_acquire() noexcept >>>>+ { >>>>+ for (;;) >>>>+ { >>>>+ auto __err = sem_trywait(&_M_semaphore); >>>>+ if (__err && (errno == EINTR)) >>>>+ continue; >>>>+ else if (__err && (errno == EAGAIN)) >>>>+ return false; >>>>+ else if (__err) >>>>+ std::terminate(); >>>>+ else >>>>+ break; >>>>+ } >>>>+ return true; >>>>+ } >>>>+ >>>> _GLIBCXX_ALWAYS_INLINE void >>>> _M_release(std::ptrdiff_t __update) noexcept >>>> { >>> >>>Please just commit this part to trunk and gcc-11, not the macro >>>renaming (as that's been fixed by Jakub already). >> >>I think on trunk I'd prefer to do the attached. WDYT? > >In fact I think something like this is neded even on gcc-11 branch, >otherwise anything that tries to include without atomics >or sem_t gets hard errors: >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100179 > >And includes which includes , meaning > is unusable on those targets. > >So I think removing this #error is essential: >>-// Note: the _GLIBCXX_REQUIRE_POSIX_SEMAPHORE macro can be used to force the >>-// use of Posix semaphores (sem_t). Doing so however, alters the ABI. >>-#if defined __cpp_lib_atomic_wait && !_GLIBCXX_REQUIRE_POSIX_SEMAPHORE >> using __semaphore_impl = __atomic_semaphore; >>-#elif _GLIBCXX_HAVE_POSIX_SEMAPHORE >>- using __semaphore_impl = __platform_semaphore; >>-#else >>-# error "No suitable semaphore implementation available" >>-#endif >>+#endif // __cpp_lib_atomic_wait Here's a simpler patch which just removes the #error and renames the REQUIRE macro to USE. This still dumps the whole of and in the global namespace when is included, but we'll have to live with that for the 11.1 release. I'm just finishing testing this on various targets and will push to trunk. I'd like to backport it to gcc-11 too, to fix PR100179. --qhD8kUEc5MK9MdKG Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit 50070d8602a07160cece5890899929e9f210244d Author: Jonathan Wakely Date: Thu Apr 22 11:10:06 2021 libstdc++: Remove #error from implementation [PR 100179] This removes the #error from for the case where neither __atomic_semaphore nor __platform_semaphore is defined. Also rename the _GLIBCXX_REQUIRE_POSIX_SEMAPHORE macro to _GLIBCXX_USE_POSIX_SEMAPHORE for consistency with the similar _GLIBCXX_USE_CXX11_ABI macro that can be used to request an alternative (ABI-changing) implementation. libstdc++-v3/ChangeLog: PR libstdc++/100179 * include/bits/semaphore_base.h: Remove #error. * include/std/semaphore: Do not define anything unless one of the implementations is available. diff --git a/libstdc++-v3/include/bits/semaphore_base.h b/libstdc++-v3/include/bits/semaphore_base.h index 84b33423fff..4948f0fd0bc 100644 --- a/libstdc++-v3/include/bits/semaphore_base.h +++ b/libstdc++-v3/include/bits/semaphore_base.h @@ -263,14 +263,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; #endif // __cpp_lib_atomic_wait -// Note: the _GLIBCXX_REQUIRE_POSIX_SEMAPHORE macro can be used to force the +// Note: the _GLIBCXX_USE_POSIX_SEMAPHORE macro can be used to force the // use of Posix semaphores (sem_t). Doing so however, alters the ABI. -#if defined __cpp_lib_atomic_wait && !_GLIBCXX_REQUIRE_POSIX_SEMAPHORE +#if defined __cpp_lib_atomic_wait && !_GLIBCXX_USE_POSIX_SEMAPHORE using __semaphore_impl = __atomic_semaphore; #elif _GLIBCXX_HAVE_POSIX_SEMAPHORE using __semaphore_impl = __platform_semaphore; -#else -# error "No suitable semaphore implementation available" #endif _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/std/semaphore b/libstdc++-v3/include/std/semaphore index a1560915d83..52addca742c 100644 --- a/libstdc++-v3/include/std/semaphore +++ b/libstdc++-v3/include/std/semaphore @@ -34,6 +34,7 @@ #if __cplusplus > 201703L #include +#if __cpp_lib_atomic_wait || _GLIBCXX_HAVE_POSIX_SEMAPHORE namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -89,5 +90,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } // namespace +#endif // cpp_lib_atomic_wait || _GLIBCXX_HAVE_POSIX_SEMAPHORE #endif // C++20 #endif // _GLIBCXX_SEMAPHORE --qhD8kUEc5MK9MdKG--