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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E0CE33858D35 for ; Fri, 10 Dec 2021 14:08:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E0CE33858D35 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-461-ZZWY3FTCONiVPeeRxGlfIw-1; Fri, 10 Dec 2021 09:08:57 -0500 X-MC-Unique: ZZWY3FTCONiVPeeRxGlfIw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79A6A100CCC2; Fri, 10 Dec 2021 14:08:56 +0000 (UTC) Received: from localhost (unknown [10.33.36.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2827C68D94; Fri, 10 Dec 2021 14:08:56 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Guard mutex and condvar with gthreads macro [PR103638] Date: Fri, 10 Dec 2021 14:08:55 +0000 Message-Id: <20211210140855.1654052-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-13.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_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 10 Dec 2021 14:09:00 -0000 Tested powerpc64le-linux --enable-threads={posix,single}, pushed to trunk. The testsuite is now clean for --enable-threads=single (apart from the expected abi-check failures, because the baselines are for the posix thread model). A mutex and condition variable is used for timed waits on atomics if there is no "platform wait" (e.g. futex) supported. But the use of those types wasn't guarded by the _GLIBCXX_HAS_GTHREADS macro, causing errors for --disable-threads builds. This fix allows to work on targets with futexes but no gthreads. libstdc++-v3/ChangeLog: PR libstdc++/103638 * include/bits/atomic_timed_wait.h: Check _GLIBCXX_HAS_GTHREADS before using std::mutex and std::__condvar. --- libstdc++-v3/include/bits/atomic_timed_wait.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libstdc++-v3/include/bits/atomic_timed_wait.h b/libstdc++-v3/include/bits/atomic_timed_wait.h index efbe3da8b6c..ba83398285c 100644 --- a/libstdc++-v3/include/bits/atomic_timed_wait.h +++ b/libstdc++-v3/include/bits/atomic_timed_wait.h @@ -137,6 +137,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // (e.g. __ulock_wait())which is better than pthread_cond_clockwait #endif // ! PLATFORM_TIMED_WAIT +#ifdef _GLIBCXX_HAS_GTHREADS // Returns true if wait ended before timeout. // _Clock must be either steady_clock or system_clock. template @@ -192,6 +193,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return false; } } +#endif // _GLIBCXX_HAS_GTHREADS struct __timed_waiter_pool : __waiter_pool_base { @@ -239,6 +241,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (_M_deadline <= __now) return false; + // FIXME: this_thread::sleep_for not available #ifdef _GLIBCXX_NO_SLEEP + auto __elapsed = __now - _M_t0; if (__elapsed > 128ms) { -- 2.31.1